Skip to content

Commit 721f30c

Browse files
committed
chore(Assistant V2): Look into generic props
1 parent 7f8a0b3 commit 721f30c

File tree

3 files changed

+58
-17
lines changed

3 files changed

+58
-17
lines changed

Assistant/v2/Models/MessageOutput.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public class MessageOutput
5656
/// Arbitrary variables that can be read and written to by a particular skill within the Assistant.
5757
/// </summary>
5858
[fsProperty("user_defined")]
59-
public dynamic UserDefined { get; set; }
59+
public object UserDefined { get; set; }
6060
}
6161

6262
}

Core/WatsonError.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-

2-
3-
using System.Collections.Generic;
4-
/**
1+
/**
52
* Copyright 2019 IBM Corp. All Rights Reserved.
63
*
74
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,6 +14,9 @@
1714
* limitations under the License.
1815
*
1916
*/
17+
18+
using System.Collections.Generic;
19+
2020
namespace IBM.Watson
2121
{
2222
public class WatsonError

Examples/ExampleAssistantV2.cs

Lines changed: 53 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,16 @@ private IEnumerator Examples()
107107
}
108108

109109
Log.Debug("ExampleAssistantV2.RunTest()", "Are you open on Christmas?");
110+
110111
MessageRequest messageRequest1 = new MessageRequest()
111112
{
112113
Input = new MessageInput()
113114
{
114-
Text = "Are you open on Christmas?"
115+
Text = "Are you open on Christmas?",
116+
Options = new MessageInputOptions()
117+
{
118+
ReturnContext = true
119+
}
115120
}
116121
};
117122
_service.Message(OnMessage1, _assistantId, _sessionId, messageRequest1);
@@ -126,7 +131,11 @@ private IEnumerator Examples()
126131
{
127132
Input = new MessageInput()
128133
{
129-
Text = "What are your hours?"
134+
Text = "What are your hours?",
135+
Options = new MessageInputOptions()
136+
{
137+
ReturnContext = true
138+
}
130139
}
131140
};
132141
_service.Message(OnMessage2, _assistantId, _sessionId, messageRequest2);
@@ -141,7 +150,11 @@ private IEnumerator Examples()
141150
{
142151
Input = new MessageInput()
143152
{
144-
Text = "I'd like to make an appointment for 12pm."
153+
Text = "I'd like to make an appointment for 12pm.",
154+
Options = new MessageInputOptions()
155+
{
156+
ReturnContext = true
157+
}
145158
}
146159
};
147160
_service.Message(OnMessage3, _assistantId, _sessionId, messageRequest3);
@@ -152,11 +165,38 @@ private IEnumerator Examples()
152165
}
153166

154167
Log.Debug("ExampleAssistantV2.RunTest()", "On Friday please.");
168+
169+
Dictionary<string, string> userDefinedDictionary = new Dictionary<string, string>();
170+
userDefinedDictionary.Add("name", "Watson");
171+
172+
Dictionary<string, Dictionary<string, string>> skillDictionary = new Dictionary<string, Dictionary<string, string>>();
173+
skillDictionary.Add("user_defined", userDefinedDictionary);
174+
175+
Dictionary<string, Dictionary<string, Dictionary<string, string>>> skills = new Dictionary<string, Dictionary<string, Dictionary<string, string>>>();
176+
skills.Add("main skill", skillDictionary);
177+
178+
//SerializableDictionary<string, string> userDefinedDictionary = new SerializableDictionary<string, string>();
179+
//userDefinedDictionary.Add("name", "Watson");
180+
181+
//SerializableDictionary<string, SerializableDictionary<string, string>> skillDictionary = new SerializableDictionary<string, SerializableDictionary<string, string>>();
182+
//skillDictionary.Add("user_defined", userDefinedDictionary);
183+
184+
//MessageContextSkills skills = new MessageContextSkills();
185+
//skills.Add("main skill", skillDictionary);
186+
155187
MessageRequest messageRequest4 = new MessageRequest()
156188
{
157189
Input = new MessageInput()
158190
{
159-
Text = "On Friday please."
191+
Text = "On Friday please.",
192+
Options = new MessageInputOptions()
193+
{
194+
ReturnContext = true
195+
}
196+
},
197+
Context = new MessageContext()
198+
{
199+
Skills = skills
160200
}
161201
};
162202
_service.Message(OnMessage4, _assistantId, _sessionId, messageRequest4);
@@ -177,43 +217,44 @@ private IEnumerator Examples()
177217
Log.Debug("ExampleAssistantV2.Examples()", "Assistant examples complete.");
178218
}
179219

180-
private void OnDeleteSession(WatsonResponse<object> response, WatsonError error, Dictionary<string, object> customData)
220+
private void OnDeleteSession(WatsonResponse<object> response, WatsonError error, System.Collections.Generic.Dictionary<string, object> customData)
181221
{
182222
Log.Debug("ExampleAssistantV2.OnDeleteSession()", "Session deleted.");
183223
_createSessionTested = true;
184224
}
185225

186-
private void OnMessage0(WatsonResponse<MessageResponse> response, WatsonError error, Dictionary<string, object> customData)
226+
private void OnMessage0(WatsonResponse<MessageResponse> response, WatsonError error, System.Collections.Generic.Dictionary<string, object> customData)
187227
{
188228
Log.Debug("ExampleAssistantV2.OnMessage0()", "response: {0}", response.Result.Output.Generic[0].Text);
189229
_messageTested0 = true;
190230
}
191231

192-
private void OnMessage1(WatsonResponse<MessageResponse> response, WatsonError error, Dictionary<string, object> customData)
232+
private void OnMessage1(WatsonResponse<MessageResponse> response, WatsonError error, System.Collections.Generic.Dictionary<string, object> customData)
193233
{
194234
Log.Debug("ExampleAssistantV2.OnMessage1()", "response: {0}", response.Result.Output.Generic[0].Text);
195235

196236
_messageTested1 = true;
197237
}
198-
199-
private void OnMessage2(WatsonResponse<MessageResponse> response, WatsonError error, Dictionary<string, object> customData)
238+
239+
private void OnMessage2(WatsonResponse<MessageResponse> response, WatsonError error, System.Collections.Generic.Dictionary<string, object> customData)
200240
{
201241
Log.Debug("ExampleAssistantV2.OnMessage2()", "response: {0}", response.Result.Output.Generic[0].Text);
202242
_messageTested2 = true;
203243
}
204244

205-
private void OnMessage3(WatsonResponse<MessageResponse> response, WatsonError error, Dictionary<string, object> customData)
245+
private void OnMessage3(WatsonResponse<MessageResponse> response, WatsonError error, System.Collections.Generic.Dictionary<string, object> customData)
206246
{
207247
Log.Debug("ExampleAssistantV2.OnMessage3()", "response: {0}", response.Result.Output.Generic[0].Text);
208248
_messageTested3 = true;
209249
}
210-
private void OnMessage4(WatsonResponse<MessageResponse> response, WatsonError error, Dictionary<string, object> customData)
250+
private void OnMessage4(WatsonResponse<MessageResponse> response, WatsonError error, System.Collections.Generic.Dictionary<string, object> customData)
211251
{
212252
Log.Debug("ExampleAssistantV2.OnMessage4()", "response: {0}", response.Result.Output.Generic[0].Text);
253+
//Log.Debug("ExampleAssistantV2.OnMessage4()", "response: {0}", response.Result.Context.Skills["main skill"]["user_defined"]["name"]);
213254
_messageTested4 = true;
214255
}
215256

216-
private void OnCreateSession(WatsonResponse<SessionResponse> response, WatsonError error, Dictionary<string, object> customData)
257+
private void OnCreateSession(WatsonResponse<SessionResponse> response, WatsonError error, System.Collections.Generic.Dictionary<string, object> customData)
217258
{
218259
Log.Debug("ExampleAssistantV2.OnCreateSession()", "Session: {0}", response.Result.SessionId);
219260
_sessionId = response.Result.SessionId;

0 commit comments

Comments
 (0)