Skip to content

Feat/release 4 2020 #640

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 5 commits into from
Jun 3, 2020
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,15 @@ public class QueryTypeValue
/// The text of the search query. This can be either a natural-language query or a query that uses the Discovery
/// query language syntax, depending on the value of the **query_type** property. For more information, see the
/// [Discovery service
/// documentation](https://cloud.ibm.com/docs/discovery?topic=discovery-query-operators#query-operators). Required when
/// **response_type**=`search_skill`.
/// documentation](https://cloud.ibm.com/docs/discovery?topic=discovery-query-operators#query-operators).
/// Required when **response_type**=`search_skill`.
/// </summary>
[JsonProperty("query", NullValueHandling = NullValueHandling.Ignore)]
public string Query { get; set; }
/// <summary>
/// An optional filter that narrows the set of documents to be searched. For more information, see the
/// [Discovery service documentation]([Discovery service
/// documentation](`https://cloud.ibm.com/docs/discovery?topic=discovery-query-parameters#filter).
/// documentation](https://cloud.ibm.com/docs/discovery?topic=discovery-query-parameters#filter).
/// </summary>
[JsonProperty("filter", NullValueHandling = NullValueHandling.Ignore)]
public string Filter { get; set; }
Expand Down
29 changes: 28 additions & 1 deletion Scripts/Services/Assistant/V1/Model/MessageInput.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2018, 2019 IBM Corp. All Rights Reserved.
* (C) Copyright IBM Corp. 2018, 2020.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -30,5 +30,32 @@ public class MessageInput: DynamicModel<object>
/// </summary>
[JsonProperty("text", NullValueHandling = NullValueHandling.Ignore)]
public string Text { get; set; }
/// <summary>
/// Whether to use spelling correction when processing the input. This property overrides the value of the
/// **spelling_suggestions** property in the workspace settings.
/// </summary>
[JsonProperty("spelling_suggestions", NullValueHandling = NullValueHandling.Ignore)]
public bool? SpellingSuggestions { get; set; }
/// <summary>
/// Whether to use autocorrection when processing the input. If spelling correction is used and this property is
/// `false`, any suggested corrections are returned in the **suggested_text** property of the message response.
/// If this property is `true`, any corrections are automatically applied to the user input, and the original
/// text is returned in the **original_text** property of the message response. This property overrides the
/// value of the **spelling_auto_correct** property in the workspace settings.
/// </summary>
[JsonProperty("spelling_auto_correct", NullValueHandling = NullValueHandling.Ignore)]
public bool? SpellingAutoCorrect { get; set; }
/// <summary>
/// Any suggested corrections of the input text. This property is returned only if spelling correction is
/// enabled and autocorrection is disabled.
/// </summary>
[JsonProperty("suggested_text", NullValueHandling = NullValueHandling.Ignore)]
public virtual string SuggestedText { get; private set; }
/// <summary>
/// The original user input text. This property is returned only if autocorrection is enabled and the user input
/// was corrected.
/// </summary>
[JsonProperty("original_text", NullValueHandling = NullValueHandling.Ignore)]
public virtual string OriginalText { get; private set; }
}
}
13 changes: 13 additions & 0 deletions Scripts/Services/Assistant/V1/Model/WorkspaceSystemSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,19 @@ public class WorkspaceSystemSettings
[JsonProperty("human_agent_assist", NullValueHandling = NullValueHandling.Ignore)]
public Dictionary<string, object> HumanAgentAssist { get; set; }
/// <summary>
/// Whether spelling correction is enabled for the workspace.
/// </summary>
[JsonProperty("spelling_suggestions", NullValueHandling = NullValueHandling.Ignore)]
public bool? SpellingSuggestions { get; set; }
/// <summary>
/// Whether autocorrection is enabled for the workspace. If spelling correction is enabled and this property is
/// `false`, any suggested corrections are returned in the **suggested_text** property of the message response.
/// If this property is `true`, any corrections are automatically applied to the user input, and the original
/// text is returned in the **original_text** property of the message response.
/// </summary>
[JsonProperty("spelling_auto_correct", NullValueHandling = NullValueHandling.Ignore)]
public bool? SpellingAutoCorrect { get; set; }
/// <summary>
/// Workspace settings related to the behavior of system entities.
/// </summary>
[JsonProperty("system_entities", NullValueHandling = NullValueHandling.Ignore)]
Expand Down
105 changes: 100 additions & 5 deletions Scripts/Services/Assistant/V2/AssistantService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,10 @@ private void OnDeleteSessionResponse(RESTConnector.Request req, RESTConnector.Re
((RequestObject<object>)req).Callback(response, resp.Error);
}
/// <summary>
/// Send user input to assistant.
/// Send user input to assistant (stateful).
///
/// Send user input to an assistant and receive a response.
/// Send user input to an assistant and receive a response, with conversation state (including context data)
/// stored by Watson Assistant for the duration of the session.
///
/// There is no rate limit for this operation.
/// </summary>
Expand All @@ -257,9 +258,12 @@ private void OnDeleteSessionResponse(RESTConnector.Request req, RESTConnector.Re
/// **Note:** Currently, the v2 API does not support creating assistants.</param>
/// <param name="sessionId">Unique identifier of the session.</param>
/// <param name="input">An input object that includes the input text. (optional)</param>
/// <param name="context">State information for the conversation. The context is stored by the assistant on a
/// per-session basis. You can use this property to set or modify context variables, which can also be accessed
/// by dialog nodes. (optional)</param>
/// <param name="context">Context data for the conversation. You can use this property to set or modify context
/// variables, which can also be accessed by dialog nodes. The context is stored by the assistant on a
/// per-session basis.
///
/// **Note:** The total size of the context data stored for a stateful session cannot exceed 100KB.
/// (optional)</param>
/// <returns><see cref="MessageResponse" />MessageResponse</returns>
public bool Message(Callback<MessageResponse> callback, string assistantId, string sessionId, MessageInput input = null, MessageContext context = null)
{
Expand Down Expand Up @@ -332,5 +336,96 @@ private void OnMessageResponse(RESTConnector.Request req, RESTConnector.Response
if (((RequestObject<MessageResponse>)req).Callback != null)
((RequestObject<MessageResponse>)req).Callback(response, resp.Error);
}
/// <summary>
/// Send user input to assistant (stateless).
///
/// Send user input to an assistant and receive a response, with conversation state (including context data)
/// managed by your application.
///
/// There is no rate limit for this operation.
/// </summary>
/// <param name="callback">The callback function that is invoked when the operation completes.</param>
/// <param name="assistantId">Unique identifier of the assistant. To find the assistant ID in the Watson
/// Assistant user interface, open the assistant settings and click **API Details**. For information about
/// creating assistants, see the
/// [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-assistant-add#assistant-add-task).
///
/// **Note:** Currently, the v2 API does not support creating assistants.</param>
/// <param name="input">An input object that includes the input text. (optional)</param>
/// <param name="context">Context data for the conversation. You can use this property to set or modify context
/// variables, which can also be accessed by dialog nodes. The context is not stored by the assistant. To
/// maintain session state, include the context from the previous response.
///
/// **Note:** The total size of the context data for a stateless session cannot exceed 250KB. (optional)</param>
/// <returns><see cref="MessageResponseStateless" />MessageResponseStateless</returns>
public bool MessageStateless(Callback<MessageResponseStateless> callback, string assistantId, MessageInputStateless input = null, MessageContextStateless context = null)
{
if (callback == null)
throw new ArgumentNullException("`callback` is required for `MessageStateless`");
if (string.IsNullOrEmpty(assistantId))
throw new ArgumentNullException("`assistantId` is required for `MessageStateless`");

RequestObject<MessageResponseStateless> req = new RequestObject<MessageResponseStateless>
{
Callback = callback,
HttpMethod = UnityWebRequest.kHttpVerbPOST,
DisableSslVerification = DisableSslVerification
};

foreach (KeyValuePair<string, string> kvp in customRequestHeaders)
{
req.Headers.Add(kvp.Key, kvp.Value);
}

ClearCustomRequestHeaders();

foreach (KeyValuePair<string, string> kvp in Common.GetSdkHeaders("conversation", "V2", "MessageStateless"))
{
req.Headers.Add(kvp.Key, kvp.Value);
}

req.Parameters["version"] = VersionDate;
req.Headers["Content-Type"] = "application/json";
req.Headers["Accept"] = "application/json";

JObject bodyObject = new JObject();
if (input != null)
bodyObject["input"] = JToken.FromObject(input);
if (context != null)
bodyObject["context"] = JToken.FromObject(context);
req.Send = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(bodyObject));

req.OnResponse = OnMessageStatelessResponse;

Connector.URL = GetServiceUrl() + string.Format("/v2/assistants/{0}/message", assistantId);
Authenticator.Authenticate(Connector);

return Connector.Send(req);
}

private void OnMessageStatelessResponse(RESTConnector.Request req, RESTConnector.Response resp)
{
DetailedResponse<MessageResponseStateless> response = new DetailedResponse<MessageResponseStateless>();
foreach (KeyValuePair<string, string> kvp in resp.Headers)
{
response.Headers.Add(kvp.Key, kvp.Value);
}
response.StatusCode = resp.HttpResponseCode;

try
{
string json = Encoding.UTF8.GetString(resp.Data);
response.Result = JsonConvert.DeserializeObject<MessageResponseStateless>(json);
response.Response = json;
}
catch (Exception e)
{
Log.Error("AssistantService.OnMessageStatelessResponse()", "Exception: {0}", e.ToString());
resp.Success = false;
}

if (((RequestObject<MessageResponseStateless>)req).Callback != null)
((RequestObject<MessageResponseStateless>)req).Callback(response, resp.Error);
}
}
}
10 changes: 5 additions & 5 deletions Scripts/Services/Assistant/V2/Model/MessageContext.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2018, 2019 IBM Corp. All Rights Reserved.
* (C) Copyright IBM Corp. 2018, 2020.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -25,15 +25,15 @@ namespace IBM.Watson.Assistant.V2.Model
public class MessageContext
{
/// <summary>
/// Information that is shared by all skills used by the Assistant.
/// Session context data that is shared by all skills used by the Assistant.
/// </summary>
[JsonProperty("global", NullValueHandling = NullValueHandling.Ignore)]
public MessageContextGlobal Global { get; set; }
/// <summary>
/// Information specific to particular skills used by the Assistant.
/// Information specific to particular skills used by the assistant.
///
/// **Note:** Currently, only a single property named `main skill` is supported. This object contains variables
/// that apply to the dialog skill used by the assistant.
/// **Note:** Currently, only a single child property is supported, containing variables that apply to the
/// dialog skill used by the assistant.
/// </summary>
[JsonProperty("skills", NullValueHandling = NullValueHandling.Ignore)]
public MessageContextSkills Skills { get; set; }
Expand Down
9 changes: 7 additions & 2 deletions Scripts/Services/Assistant/V2/Model/MessageContextGlobal.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2018, 2019 IBM Corp. All Rights Reserved.
* (C) Copyright IBM Corp. 2018, 2020.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,7 +20,7 @@
namespace IBM.Watson.Assistant.V2.Model
{
/// <summary>
/// Information that is shared by all skills used by the Assistant.
/// Session context data that is shared by all skills used by the Assistant.
/// </summary>
public class MessageContextGlobal
{
Expand All @@ -29,5 +29,10 @@ public class MessageContextGlobal
/// </summary>
[JsonProperty("system", NullValueHandling = NullValueHandling.Ignore)]
public MessageContextGlobalSystem System { get; set; }
/// <summary>
/// The session ID.
/// </summary>
[JsonProperty("session_id", NullValueHandling = NullValueHandling.Ignore)]
public virtual string SessionId { get; private set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* (C) Copyright IBM Corp. 2018, 2020.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

using Newtonsoft.Json;

namespace IBM.Watson.Assistant.V2.Model
{
/// <summary>
/// Session context data that is shared by all skills used by the Assistant.
/// </summary>
public class MessageContextGlobalStateless
{
/// <summary>
/// Built-in system properties that apply to all skills used by the assistant.
/// </summary>
[JsonProperty("system", NullValueHandling = NullValueHandling.Ignore)]
public MessageContextGlobalSystem System { get; set; }
/// <summary>
/// The unique identifier of the session.
/// </summary>
[JsonProperty("session_id", NullValueHandling = NullValueHandling.Ignore)]
public string SessionId { get; set; }
}
}

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

3 changes: 2 additions & 1 deletion Scripts/Services/Assistant/V2/Model/MessageContextSkill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
namespace IBM.Watson.Assistant.V2.Model
{
/// <summary>
/// Contains information specific to a particular skill used by the Assistant.
/// Contains information specific to a particular skill used by the Assistant. The property name must be the same as
/// the name of the skill (for example, `main skill`).
/// </summary>
public class MessageContextSkill
{
Expand Down
37 changes: 37 additions & 0 deletions Scripts/Services/Assistant/V2/Model/MessageContextSkillSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* (C) Copyright IBM Corp. 2018, 2020.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

using IBM.Cloud.SDK.Model;
using Newtonsoft.Json;

namespace IBM.Watson.Assistant.V2.Model
{
/// <summary>
/// System context data used by the skill.
/// </summary>
public class MessageContextSkillSystem: DynamicModel<object>
{
/// <summary>
/// An encoded string representing the current conversation state. By saving this value and then sending it in
/// the context of a subsequent message request, you can restore the conversation to the same state. This can be
/// useful if you need to return to an earlier point in the conversation. If you are using stateful sessions,
/// you can also use a stored state value to restore a paused conversation whose session has expired.
/// </summary>
[JsonProperty("state", NullValueHandling = NullValueHandling.Ignore)]
public string State { get; set; }
}
}

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

8 changes: 4 additions & 4 deletions Scripts/Services/Assistant/V2/Model/MessageContextSkills.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2018, 2019 IBM Corp. All Rights Reserved.
* (C) Copyright IBM Corp. 2018, 2020.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,10 +20,10 @@
namespace IBM.Watson.Assistant.V2.Model
{
/// <summary>
/// Information specific to particular skills used by the Assistant.
/// Information specific to particular skills used by the assistant.
///
/// **Note:** Currently, only a single property named `main skill` is supported. This object contains variables that
/// apply to the dialog skill used by the assistant.
/// **Note:** Currently, only a single child property is supported, containing variables that apply to the dialog
/// skill used by the assistant.
/// </summary>
public class MessageContextSkills: DynamicModel<MessageContextSkill>
{
Expand Down
Loading