Skip to content

v4.1 #607

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Nov 27, 2019
Merged

v4.1 #607

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [email protected]. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: node_js
node_js:
- "8.3"
- "10"
os:
- osx
osx_image: xcode61
Expand Down
81 changes: 81 additions & 0 deletions Examples/ExampleDiscoveryV2.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
using IBM.Watson.Discovery.V2;
using IBM.Watson.Discovery.V2.Model;
using IBM.Cloud.SDK.Utilities;
using IBM.Cloud.SDK.Authentication;
using IBM.Cloud.SDK.Authentication.Bearer;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using IBM.Cloud.SDK;

public class ExampleDiscoveryV2 : MonoBehaviour
{
#region PLEASE SET THESE VARIABLES IN THE INSPECTOR
[Space(10)]
[Tooltip("The Bearer Token.")]
[SerializeField]
private string bearerToken;
[Tooltip("The service URL (optional). This defaults to \"https://gateway.watsonplatform.net/discovery/api\"")]
[SerializeField]
private string serviceUrl;
[Tooltip("The version date with which you would like to use the service in the form YYYY-MM-DD.")]
[SerializeField]
private string versionDate;
#endregion

private DiscoveryService service;
// Start is called before the first frame update
void Start()
{
LogSystem.InstallDefaultReactors();
Runnable.Run(CreateService());
}

// Update is called once per frame
public IEnumerator CreateService()
{
if (string.IsNullOrEmpty(bearerToken))
{
throw new IBMException("Plesae provide Bearer Token for the service.");
}

// Option 1
// Create credential and instantiate service using bearer token
BearerTokenAuthenticator authenticator = new BearerTokenAuthenticator(bearerToken: bearerToken);

// Option 2
// Create credential and instantiate service using username/password
// var authenticator = new CloudPakForDataAuthenticator(
// url: "https://{cpd_cluster_host}{:port}",
// username: "{username}",
// password: "{password}"
// );

// Wait for tokendata
while (!authenticator.CanAuthenticate())
yield return null;

service = new DiscoveryService(versionDate, authenticator);
service.SetServiceUrl("service_url");


Runnable.Run(ExampleListCollections());
}

private IEnumerator ExampleListCollections()
{
Log.Debug("DiscoveryServiceV2", "ListCollections");
ListCollectionsResponse listCollectionsResponse = null;
service.ListCollections(
callback: (DetailedResponse<ListCollectionsResponse> response, IBMError error) =>
{
Log.Debug("DiscoveryServiceV2", "ListCollections result: {0}", response.Response);
listCollectionsResponse = response.Result;
},
projectId: "{project_id}"
);

while (listCollectionsResponse == null)
yield return null;
}
}
11 changes: 11 additions & 0 deletions Examples/ExampleDiscoveryV2.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Use this SDK to build Watson-powered applications in Unity.
* [Before you begin](#before-you-begin)
* [Getting the Watson SDK and adding it to Unity](#getting-the-watson-sdk-and-adding-it-to-unity)
* [Installing the SDK source into your Unity project](#installing-the-sdk-source-into-your-unity-project)
* [Discovery v2 only on CP4D](#discovery-v2-only-on-cp4d)
* [Configuring your service credentials](#configuring-your-service-credentials)
* [Authentication](#authentication)
* [Watson Services](#watson-services)
Expand Down Expand Up @@ -43,6 +44,9 @@ You can get the latest SDK release by clicking [here][latest_release_sdk]. **You
### Installing the SDK source into your Unity project
Move the **`unity-sdk`** and **`unity-sdk-core`** directories into the **`Assets`** directory of your Unity project. _Optional: rename the SDK directory from `unity-sdk` to `Watson` and the Core directory from `unity-sdk-core` to `IBMSdkCore`_.

## Discovery v2 only on CP4D

Discovery v2 is only available on Cloud Pak for Data.

## Configuring your service credentials
To create instances of Watson services and their credentials, follow the steps below.
Expand Down
27 changes: 21 additions & 6 deletions Scripts/Services/Assistant/V1/AssistantService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,9 @@ private void OnListWorkspacesResponse(RESTConnector.Request req, RESTConnector.R
/// (optional)</param>
/// <param name="counterexamples">An array of objects defining input examples that have been marked as
/// irrelevant input. (optional)</param>
/// <param name="webhooks"> (optional)</param>
/// <returns><see cref="Workspace" />Workspace</returns>
public bool CreateWorkspace(Callback<Workspace> callback, string name = null, string description = null, string language = null, Dictionary<string, object> metadata = null, bool? learningOptOut = null, WorkspaceSystemSettings systemSettings = null, List<CreateIntent> intents = null, List<CreateEntity> entities = null, List<DialogNode> dialogNodes = null, List<Counterexample> counterexamples = null)
public bool CreateWorkspace(Callback<Workspace> callback, string name = null, string description = null, string language = null, Dictionary<string, object> metadata = null, bool? learningOptOut = null, WorkspaceSystemSettings systemSettings = null, List<CreateIntent> intents = null, List<CreateEntity> entities = null, List<DialogNode> dialogNodes = null, List<Counterexample> counterexamples = null, List<Webhook> webhooks = null)
{
if (callback == null)
throw new ArgumentNullException("`callback` is required for `CreateWorkspace`");
Expand Down Expand Up @@ -363,6 +364,8 @@ public bool CreateWorkspace(Callback<Workspace> callback, string name = null, st
bodyObject["dialog_nodes"] = JToken.FromObject(dialogNodes);
if (counterexamples != null && counterexamples.Count > 0)
bodyObject["counterexamples"] = JToken.FromObject(counterexamples);
if (webhooks != null && webhooks.Count > 0)
bodyObject["webhooks"] = JToken.FromObject(webhooks);
req.Send = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(bodyObject));

req.OnResponse = OnCreateWorkspaceResponse;
Expand Down Expand Up @@ -521,8 +524,9 @@ private void OnGetWorkspaceResponse(RESTConnector.Request req, RESTConnector.Res
///
/// If **append**=`true`, existing elements are preserved, and the new elements are added. If any elements in
/// the new data collide with existing elements, the update request fails. (optional, default to false)</param>
/// <param name="webhooks"> (optional)</param>
/// <returns><see cref="Workspace" />Workspace</returns>
public bool UpdateWorkspace(Callback<Workspace> callback, string workspaceId, string name = null, string description = null, string language = null, Dictionary<string, object> metadata = null, bool? learningOptOut = null, WorkspaceSystemSettings systemSettings = null, List<CreateIntent> intents = null, List<CreateEntity> entities = null, List<DialogNode> dialogNodes = null, List<Counterexample> counterexamples = null, bool? append = null)
public bool UpdateWorkspace(Callback<Workspace> callback, string workspaceId, string name = null, string description = null, string language = null, Dictionary<string, object> metadata = null, bool? learningOptOut = null, WorkspaceSystemSettings systemSettings = null, List<CreateIntent> intents = null, List<CreateEntity> entities = null, List<DialogNode> dialogNodes = null, List<Counterexample> counterexamples = null, bool? append = null, List<Webhook> webhooks = null)
{
if (callback == null)
throw new ArgumentNullException("`callback` is required for `UpdateWorkspace`");
Expand Down Expand Up @@ -577,6 +581,8 @@ public bool UpdateWorkspace(Callback<Workspace> callback, string workspaceId, st
bodyObject["dialog_nodes"] = JToken.FromObject(dialogNodes);
if (counterexamples != null && counterexamples.Count > 0)
bodyObject["counterexamples"] = JToken.FromObject(counterexamples);
if (webhooks != null && webhooks.Count > 0)
bodyObject["webhooks"] = JToken.FromObject(webhooks);
req.Send = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(bodyObject));

req.OnResponse = OnUpdateWorkspaceResponse;
Expand Down Expand Up @@ -3595,8 +3601,10 @@ private void OnListDialogNodesResponse(RESTConnector.Request req, RESTConnector.
/// (optional)</param>
/// <param name="userLabel">A label that can be displayed externally to describe the purpose of the node to
/// users. (optional)</param>
/// <param name="disambiguationOptOut">Whether the dialog node should be excluded from disambiguation
/// suggestions. (optional, default to false)</param>
/// <returns><see cref="DialogNode" />DialogNode</returns>
public bool CreateDialogNode(Callback<DialogNode> callback, string workspaceId, string dialogNode, string description = null, string conditions = null, string parent = null, string previousSibling = null, DialogNodeOutput output = null, Dictionary<string, object> context = null, Dictionary<string, object> metadata = null, DialogNodeNextStep nextStep = null, string title = null, string type = null, string eventName = null, string variable = null, List<DialogNodeAction> actions = null, string digressIn = null, string digressOut = null, string digressOutSlots = null, string userLabel = null)
public bool CreateDialogNode(Callback<DialogNode> callback, string workspaceId, string dialogNode, string description = null, string conditions = null, string parent = null, string previousSibling = null, DialogNodeOutput output = null, Dictionary<string, object> context = null, Dictionary<string, object> metadata = null, DialogNodeNextStep nextStep = null, string title = null, string type = null, string eventName = null, string variable = null, List<DialogNodeAction> actions = null, string digressIn = null, string digressOut = null, string digressOutSlots = null, string userLabel = null, bool? disambiguationOptOut = null)
{
if (callback == null)
throw new ArgumentNullException("`callback` is required for `CreateDialogNode`");
Expand Down Expand Up @@ -3665,6 +3673,8 @@ public bool CreateDialogNode(Callback<DialogNode> callback, string workspaceId,
bodyObject["digress_out_slots"] = digressOutSlots;
if (!string.IsNullOrEmpty(userLabel))
bodyObject["user_label"] = userLabel;
if (disambiguationOptOut != null)
bodyObject["disambiguation_opt_out"] = JToken.FromObject(disambiguationOptOut);
req.Send = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(bodyObject));

req.OnResponse = OnCreateDialogNodeResponse;
Expand Down Expand Up @@ -3825,8 +3835,10 @@ private void OnGetDialogNodeResponse(RESTConnector.Request req, RESTConnector.Re
/// (optional)</param>
/// <param name="newUserLabel">A label that can be displayed externally to describe the purpose of the node to
/// users. (optional)</param>
/// <param name="newDisambiguationOptOut">Whether the dialog node should be excluded from disambiguation
/// suggestions. (optional, default to false)</param>
/// <returns><see cref="DialogNode" />DialogNode</returns>
public bool UpdateDialogNode(Callback<DialogNode> callback, string workspaceId, string dialogNode, string newDialogNode = null, string newDescription = null, string newConditions = null, string newParent = null, string newPreviousSibling = null, DialogNodeOutput newOutput = null, Dictionary<string, object> newContext = null, Dictionary<string, object> newMetadata = null, DialogNodeNextStep newNextStep = null, string newTitle = null, string newType = null, string newEventName = null, string newVariable = null, List<DialogNodeAction> newActions = null, string newDigressIn = null, string newDigressOut = null, string newDigressOutSlots = null, string newUserLabel = null)
public bool UpdateDialogNode(Callback<DialogNode> callback, string workspaceId, string dialogNode, string newDialogNode = null, string newDescription = null, string newConditions = null, string newParent = null, string newPreviousSibling = null, DialogNodeOutput newOutput = null, Dictionary<string, object> newContext = null, Dictionary<string, object> newMetadata = null, DialogNodeNextStep newNextStep = null, string newTitle = null, string newType = null, string newEventName = null, string newVariable = null, List<DialogNodeAction> newActions = null, string newDigressIn = null, string newDigressOut = null, string newDigressOutSlots = null, string newUserLabel = null, bool? newDisambiguationOptOut = null)
{
if (callback == null)
throw new ArgumentNullException("`callback` is required for `UpdateDialogNode`");
Expand Down Expand Up @@ -3895,6 +3907,8 @@ public bool UpdateDialogNode(Callback<DialogNode> callback, string workspaceId,
bodyObject["digress_out_slots"] = newDigressOutSlots;
if (!string.IsNullOrEmpty(newUserLabel))
bodyObject["user_label"] = newUserLabel;
if (newDisambiguationOptOut != null)
bodyObject["disambiguation_opt_out"] = JToken.FromObject(newDisambiguationOptOut);
req.Send = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(bodyObject));

req.OnResponse = OnUpdateDialogNodeResponse;
Expand Down Expand Up @@ -4107,8 +4121,9 @@ private void OnListLogsResponse(RESTConnector.Request req, RESTConnector.Respons
/// </summary>
/// <param name="callback">The callback function that is invoked when the operation completes.</param>
/// <param name="filter">A cacheable parameter that limits the results to those matching the specified filter.
/// You must specify a filter query that includes a value for `language`, as well as a value for `workspace_id`
/// or `request.context.metadata.deployment`. For more information, see the
/// You must specify a filter query that includes a value for `language`, as well as a value for
/// `request.context.system.assistant_id`, `workspace_id`, or `request.context.metadata.deployment`. For more
/// information, see the
/// [documentation](https://cloud.ibm.com/docs/services/assistant?topic=assistant-filter-reference#filter-reference).</param>
/// <param name="sort">How to sort the returned log events. You can sort by **request_timestamp**. To reverse
/// the sort order, prefix the parameter value with a minus sign (`-`). (optional)</param>
Expand Down
5 changes: 5 additions & 0 deletions Scripts/Services/Assistant/V1/Model/DialogNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,11 @@ public class DigressOutSlotsValue
[JsonProperty("user_label", NullValueHandling = NullValueHandling.Ignore)]
public string UserLabel { get; set; }
/// <summary>
/// Whether the dialog node should be excluded from disambiguation suggestions.
/// </summary>
[JsonProperty("disambiguation_opt_out", NullValueHandling = NullValueHandling.Ignore)]
public bool? DisambiguationOptOut { get; set; }
/// <summary>
/// For internal use only.
/// </summary>
[JsonProperty("disabled", NullValueHandling = NullValueHandling.Ignore)]
Expand Down
4 changes: 4 additions & 0 deletions Scripts/Services/Assistant/V1/Model/DialogNodeAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ public class TypeValue
/// Constant WEB_ACTION for web_action
/// </summary>
public const string WEB_ACTION = "web_action";
/// <summary>
/// Constant WEBHOOK for webhook
/// </summary>
public const string WEBHOOK = "webhook";

}

Expand Down
4 changes: 2 additions & 2 deletions Scripts/Services/Assistant/V1/Model/DialogSuggestion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ namespace IBM.Watson.Assistant.V1.Model
public class DialogSuggestion
{
/// <summary>
/// The user-facing label for the disambiguation option. This label is taken from the **user_label** property of
/// the corresponding dialog node.
/// The user-facing label for the disambiguation option. This label is taken from the **title** or
/// **user_label** property of the corresponding dialog node, depending on the disambiguation options.
/// </summary>
[JsonProperty("label", NullValueHandling = NullValueHandling.Ignore)]
public string Label { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public class PreferenceValue
/// An array of objects describing the possible matching dialog nodes from which the user can choose.
///
/// **Note:** The **suggestions** property is part of the disambiguation feature, which is only available for
/// Premium users.
/// Plus and Premium users.
/// </summary>
[JsonProperty("suggestions", NullValueHandling = NullValueHandling.Ignore)]
public List<DialogSuggestion> Suggestions { get; set; }
Expand Down
Loading