Skip to content

Commit 45c39db

Browse files
authored
Merge branch 'development' into gh-129-ReturnedErrorsIsDeserialized
2 parents ad6cfe8 + cdc47c2 commit 45c39db

File tree

7 files changed

+240
-170
lines changed

7 files changed

+240
-170
lines changed

appveyor.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,16 @@ environment:
1313
CRED_SECRET:
1414
secure: eEcA/09B7XzeTSb3GlaeqcWfQ/TemXxAq9/0AFM5+z8=
1515
VCAP_SERVICES: C:\projects\dotnet-standard-sdk\config
16+
init:
17+
- ps: '[System.IO.File]::AppendAllText("C:\Windows\System32\drivers\etc\hosts", "`n93.184.221.200 api.nuget.org")'
1618
install:
1719
- cmd: >-
1820
rm -rf packages
1921
2022
mkdir packages
2123
24+
nuget restore
25+
2226
nuget install -Verbosity quiet -OutputDirectory packages -Version 4.6.519 OpenCover
2327
2428
nuget install -Verbosity quiet -OutputDirectory packages -Version 2.4.5.0 ReportGenerator
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/**
2+
* Copyright 2017 IBM Corp. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
using IBM.WatsonDeveloperCloud.Conversation.v1.Model;
19+
using Newtonsoft.Json;
20+
using System;
21+
22+
namespace IBM.WatsonDeveloperCloud.Conversation.v1.Example
23+
{
24+
public class ConversationContextExample
25+
{
26+
private ConversationService _conversation;
27+
private string _workspaceID;
28+
private string[] _questionArray = { "hello", "can you turn up the AC", "can you turn on the wipers", "can you turn off the wipers", "can you turn down the ac", "can you unlock the door" };
29+
private int _questionIndex = 0;
30+
private dynamic _questionContext = null;
31+
32+
public ConversationContextExample(string username, string password, string workspaceId)
33+
{
34+
_conversation = new ConversationService(username, password, ConversationService.CONVERSATION_VERSION_DATE_2017_05_26);
35+
_workspaceID = workspaceId;
36+
37+
CallConversation(_questionIndex);
38+
}
39+
40+
public void CallConversation(int questionIndex)
41+
{
42+
MessageRequest messageRequest = new MessageRequest()
43+
{
44+
Input = new InputData()
45+
{
46+
Text = _questionArray[questionIndex]
47+
}
48+
};
49+
50+
if(_questionContext != null)
51+
{
52+
messageRequest.Context = _questionContext;
53+
}
54+
55+
var result = _conversation.Message(_workspaceID, messageRequest);
56+
Console.WriteLine(string.Format("result: {0}", JsonConvert.SerializeObject(result, Formatting.Indented)));
57+
_questionIndex++;
58+
_questionContext = result.Context;
59+
60+
if (questionIndex < _questionArray.Length - 1)
61+
CallConversation(_questionIndex);
62+
}
63+
}
64+
}
65+

examples/IBM.WatsonDeveloperCloud.Conversation.v1.Example/Example.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ public static void Main(string[] args)
3232
var _password = vcapServices["conversation"][0]["credentials"]["password"];
3333
var _workspaceID = vcapServices["conversation"][0]["credentials"]["workspaceId"];
3434

35-
ConversationServiceExample _conversationExample = new ConversationServiceExample(_username.ToString(), _password.ToString(), _workspaceID.ToString());
35+
//ConversationServiceExample _conversationExample = new ConversationServiceExample(_username.ToString(), _password.ToString(), _workspaceID.ToString());
36+
ConversationContextExample _converationContextExample = new ConversationContextExample(_username.ToString(), _password.ToString(), _workspaceID.ToString());
3637
Console.ReadKey();
3738
}
3839
}

src/IBM.WatsonDeveloperCloud.Conversation.v1/Model/MessageRequest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class MessageRequest
3030
/// </summary>
3131
/// <value>An input object that includes the input text.</value>
3232
[JsonProperty("input", NullValueHandling = NullValueHandling.Ignore)]
33-
public InputData Input { get; set; }
33+
public dynamic Input { get; set; }
3434
/// <summary>
3535
/// Whether to return more than one intent. Set to `true` to return all matching intents.
3636
/// </summary>
@@ -42,7 +42,7 @@ public class MessageRequest
4242
/// </summary>
4343
/// <value>State information for the conversation. Continue a conversation by including the context object from the previous response.</value>
4444
[JsonProperty("context", NullValueHandling = NullValueHandling.Ignore)]
45-
public Context Context { get; set; }
45+
public dynamic Context { get; set; }
4646
/// <summary>
4747
/// Include the entities from the previous response when they do not need to change and to prevent Watson from trying to identify them.
4848
/// </summary>

src/IBM.WatsonDeveloperCloud.Conversation.v1/Model/MessageResponse.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class MessageResponse
3030
/// </summary>
3131
/// <value>The user input from the request.</value>
3232
[JsonProperty("input", NullValueHandling = NullValueHandling.Ignore)]
33-
public MessageInput Input { get; set; }
33+
public dynamic Input { get; set; }
3434
/// <summary>
3535
/// An array of intents recognized in the user input, sorted in descending order of confidence.
3636
/// </summary>
@@ -54,7 +54,7 @@ public class MessageResponse
5454
/// </summary>
5555
/// <value>State information for the conversation.</value>
5656
[JsonProperty("context", NullValueHandling = NullValueHandling.Ignore)]
57-
public RuntimeContext Context { get; set; }
57+
public dynamic Context { get; set; }
5858
/// <summary>
5959
/// Output from the dialog, including the response to the user, the nodes that were triggered, and log messages.
6060
/// </summary>

src/IBM.WatsonDeveloperCloud/Constants.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ public class Constants
2626
/// The version number for this SDK build. Added to the header in
2727
/// each request as `User-Agent`.
2828
/// </summary>
29-
public const string SDK_VERSION = "watson-apis-dotnet-standard-sdk/1.1.0";
29+
public const string SDK_VERSION = "watson-apis-dotnet-sdk/1.2.0";
3030
}
3131
}

0 commit comments

Comments
 (0)