Skip to content

Commit

Permalink
fix(Assistant): node dialog respose should have agent props
Browse files Browse the repository at this point in the history
  • Loading branch information
mamoonraja committed Dec 21, 2020
1 parent 800f7de commit e0ead99
Show file tree
Hide file tree
Showing 22 changed files with 290 additions and 203 deletions.
2 changes: 1 addition & 1 deletion Examples/ExamplePersonalityInsightsV3.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2019 IBM Corp. All Rights Reserved.
* (C) Copyright IBM Corp. 2019, 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
2 changes: 1 addition & 1 deletion Examples/GenericSerialization.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2019 IBM Corp. All Rights Reserved.
* (C) Copyright IBM Corp. 2019, 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
174 changes: 87 additions & 87 deletions Scripts/Services/Assistant/V1/AssistantService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

/**
* IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-a45d89ef-20201209-153452
* IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-a45d89ef-20201221-120002
*/

using System.Collections.Generic;
Expand Down Expand Up @@ -228,6 +228,92 @@ private void OnMessageResponse(RESTConnector.Request req, RESTConnector.Response
((RequestObject<MessageResponse>)req).Callback(response, resp.Error);
}

/// <summary>
/// Identify intents and entities in multiple user utterances.
///
/// Send multiple user inputs to a workspace in a single request and receive information about the intents and
/// entities recognized in each input. This method is useful for testing and comparing the performance of
/// different workspaces.
///
/// This method is available only with Premium plans.
/// </summary>
/// <param name="callback">The callback function that is invoked when the operation completes.</param>
/// <param name="workspaceId">Unique identifier of the workspace.</param>
/// <param name="input">An array of input utterances to classify. (optional)</param>
/// <returns><see cref="BulkClassifyResponse" />BulkClassifyResponse</returns>
public bool BulkClassify(Callback<BulkClassifyResponse> callback, string workspaceId, List<BulkClassifyUtterance> input = null)
{
if (callback == null)
throw new ArgumentNullException("`callback` is required for `BulkClassify`");
if (string.IsNullOrEmpty(workspaceId))
throw new ArgumentNullException("`workspaceId` is required for `BulkClassify`");
if (string.IsNullOrEmpty(Version))
throw new ArgumentNullException("`Version` is required");

RequestObject<BulkClassifyResponse> req = new RequestObject<BulkClassifyResponse>
{
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", "V1", "BulkClassify"))
{
req.Headers.Add(kvp.Key, kvp.Value);
}

if (!string.IsNullOrEmpty(Version))
{
req.Parameters["version"] = Version;
}
req.Headers["Content-Type"] = "application/json";
req.Headers["Accept"] = "application/json";

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

req.OnResponse = OnBulkClassifyResponse;

Connector.URL = GetServiceUrl() + string.Format("/v1/workspaces/{0}/bulk_classify", workspaceId);
Authenticator.Authenticate(Connector);

return Connector.Send(req);
}

private void OnBulkClassifyResponse(RESTConnector.Request req, RESTConnector.Response resp)
{
DetailedResponse<BulkClassifyResponse> response = new DetailedResponse<BulkClassifyResponse>();
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<BulkClassifyResponse>(json);
response.Response = json;
}
catch (Exception e)
{
Log.Error("AssistantService.OnBulkClassifyResponse()", "Exception: {0}", e.ToString());
resp.Success = false;
}

if (((RequestObject<BulkClassifyResponse>)req).Callback != null)
((RequestObject<BulkClassifyResponse>)req).Callback(response, resp.Error);
}

/// <summary>
/// List workspaces.
///
Expand Down Expand Up @@ -4665,91 +4751,5 @@ private void OnDeleteUserDataResponse(RESTConnector.Request req, RESTConnector.R
if (((RequestObject<object>)req).Callback != null)
((RequestObject<object>)req).Callback(response, resp.Error);
}

/// <summary>
/// Identify intents and entities in multiple user utterances.
///
/// Send multiple user inputs to a workspace in a single request and receive information about the intents and
/// entities recognized in each input. This method is useful for testing and comparing the performance of
/// different workspaces.
///
/// This method is available only with Premium plans.
/// </summary>
/// <param name="callback">The callback function that is invoked when the operation completes.</param>
/// <param name="workspaceId">Unique identifier of the workspace.</param>
/// <param name="input">An array of input utterances to classify. (optional)</param>
/// <returns><see cref="BulkClassifyResponse" />BulkClassifyResponse</returns>
public bool BulkClassify(Callback<BulkClassifyResponse> callback, string workspaceId, List<BulkClassifyUtterance> input = null)
{
if (callback == null)
throw new ArgumentNullException("`callback` is required for `BulkClassify`");
if (string.IsNullOrEmpty(workspaceId))
throw new ArgumentNullException("`workspaceId` is required for `BulkClassify`");
if (string.IsNullOrEmpty(Version))
throw new ArgumentNullException("`Version` is required");

RequestObject<BulkClassifyResponse> req = new RequestObject<BulkClassifyResponse>
{
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", "V1", "BulkClassify"))
{
req.Headers.Add(kvp.Key, kvp.Value);
}

if (!string.IsNullOrEmpty(Version))
{
req.Parameters["version"] = Version;
}
req.Headers["Content-Type"] = "application/json";
req.Headers["Accept"] = "application/json";

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

req.OnResponse = OnBulkClassifyResponse;

Connector.URL = GetServiceUrl() + string.Format("/v1/workspaces/{0}/bulk_classify", workspaceId);
Authenticator.Authenticate(Connector);

return Connector.Send(req);
}

private void OnBulkClassifyResponse(RESTConnector.Request req, RESTConnector.Response resp)
{
DetailedResponse<BulkClassifyResponse> response = new DetailedResponse<BulkClassifyResponse>();
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<BulkClassifyResponse>(json);
response.Response = json;
}
catch (Exception e)
{
Log.Error("AssistantService.OnBulkClassifyResponse()", "Exception: {0}", e.ToString());
resp.Success = false;
}

if (((RequestObject<BulkClassifyResponse>)req).Callback != null)
((RequestObject<BulkClassifyResponse>)req).Callback(response, resp.Error);
}
}
}
33 changes: 33 additions & 0 deletions Scripts/Services/Assistant/V1/Model/AgentAvailabilityMessage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* (C) Copyright IBM Corp. 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.V1.Model
{
/// <summary>
/// AgentAvailabilityMessage.
/// </summary>
public class AgentAvailabilityMessage
{
/// <summary>
/// The text of the message.
/// </summary>
[JsonProperty("message", NullValueHandling = NullValueHandling.Ignore)]
public string Message { get; set; }
}
}

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

2 changes: 1 addition & 1 deletion Scripts/Services/Assistant/V1/Model/DialogNodeOutput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace IBM.Watson.Assistant.V1.Model
/// The output of the dialog node. For more information about how to specify dialog node output, see the
/// [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-dialog-overview#dialog-overview-responses).
/// </summary>
public class DialogNodeOutput: DynamicModel<object>
public class DialogNodeOutput : DynamicModel<object>
{
/// <summary>
/// An array of objects describing the output defined for the dialog node.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,13 @@ public class QueryTypeValue
/// next available agent.
/// </summary>
[JsonProperty("agent_available", NullValueHandling = NullValueHandling.Ignore)]
public string AgentAvailable { get; protected set; }
public AgentAvailabilityMessage AgentAvailable { get; protected set; }
/// <summary>
/// An optional message to be displayed to the user to indicate that no online agent is available to take over
/// the conversation.
/// </summary>
[JsonProperty("agent_unavailable", NullValueHandling = NullValueHandling.Ignore)]
public string AgentUnavailable { get; protected set; }
public AgentAvailabilityMessage AgentUnavailable { get; protected set; }
/// <summary>
/// Routing or other contextual information to be used by target service desk systems.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class ResponseTypeValue
/// next available agent.
/// </summary>
[JsonProperty("agent_available", NullValueHandling = NullValueHandling.Ignore)]
public new string AgentAvailable
public new AgentAvailabilityMessage AgentAvailable
{
get { return base.AgentAvailable; }
set { base.AgentAvailable = value; }
Expand All @@ -61,7 +61,7 @@ public class ResponseTypeValue
/// the conversation.
/// </summary>
[JsonProperty("agent_unavailable", NullValueHandling = NullValueHandling.Ignore)]
public new string AgentUnavailable
public new AgentAvailabilityMessage AgentUnavailable
{
get { return base.AgentUnavailable; }
set { base.AgentUnavailable = value; }
Expand Down
4 changes: 2 additions & 2 deletions Scripts/Services/Assistant/V1/Model/MessageInput.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright IBM Corp. 2018, 2020.
* (C) Copyright IBM Corp. 2019, 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 @@ -23,7 +23,7 @@ namespace IBM.Watson.Assistant.V1.Model
/// <summary>
/// An input object that includes the input text.
/// </summary>
public class MessageInput: DynamicModel<object>
public class MessageInput : DynamicModel<object>
{
/// <summary>
/// The text of the user input. This string cannot contain carriage return, newline, or tab characters.
Expand Down
4 changes: 2 additions & 2 deletions Scripts/Services/Assistant/V1/Model/OutputData.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. 2019, 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,7 +25,7 @@ namespace IBM.Watson.Assistant.V1.Model
/// An output object that includes the response to the user, the dialog nodes that were triggered, and messages from
/// the log.
/// </summary>
public class OutputData: DynamicModel<object>
public class OutputData : DynamicModel<object>
{
/// <summary>
/// An array of the nodes that were triggered to create the response, in the order in which they were visited.
Expand Down
7 changes: 3 additions & 4 deletions Scripts/Services/Assistant/V1/Model/RuntimeEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,10 @@ public class RuntimeEntity
[JsonProperty("groups", NullValueHandling = NullValueHandling.Ignore)]
public List<CaptureGroup> Groups { get; set; }
/// <summary>
/// An object containing detailed information about the entity recognized in the user input. This property is
/// included only if the new system entities are enabled for the workspace.
/// An object containing detailed information about the entity recognized in the user input.
///
/// For more information about how the new system entities are interpreted, see the
/// [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-beta-system-entities).
/// For more information about how system entities are interpreted, see the
/// [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-system-entities).
/// </summary>
[JsonProperty("interpretation", NullValueHandling = NullValueHandling.Ignore)]
public RuntimeEntityInterpretation Interpretation { get; set; }
Expand Down
4 changes: 2 additions & 2 deletions Scripts/Services/Assistant/V1/Model/RuntimeResponseGeneric.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,13 @@ public class PreferenceValue
/// next available agent.
/// </summary>
[JsonProperty("agent_available", NullValueHandling = NullValueHandling.Ignore)]
public string AgentAvailable { get; protected set; }
public AgentAvailabilityMessage AgentAvailable { get; protected set; }
/// <summary>
/// An optional message to be displayed to the user to indicate that no online agent is available to take over
/// the conversation.
/// </summary>
[JsonProperty("agent_unavailable", NullValueHandling = NullValueHandling.Ignore)]
public string AgentUnavailable { get; protected set; }
public AgentAvailabilityMessage AgentUnavailable { get; protected set; }
/// <summary>
/// Routing or other contextual information to be used by target service desk systems.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class ResponseTypeValue
/// next available agent.
/// </summary>
[JsonProperty("agent_available", NullValueHandling = NullValueHandling.Ignore)]
public new string AgentAvailable
public new AgentAvailabilityMessage AgentAvailable
{
get { return base.AgentAvailable; }
set { base.AgentAvailable = value; }
Expand All @@ -61,7 +61,7 @@ public class ResponseTypeValue
/// the conversation.
/// </summary>
[JsonProperty("agent_unavailable", NullValueHandling = NullValueHandling.Ignore)]
public new string AgentUnavailable
public new AgentAvailabilityMessage AgentUnavailable
{
get { return base.AgentUnavailable; }
set { base.AgentUnavailable = value; }
Expand Down
Loading

0 comments on commit e0ead99

Please sign in to comment.