Skip to content

Commit 5bee7c1

Browse files
authored
Merge pull request #459 from watson-developer-cloud/rc-2.10.0
Unity SDK 2.10.0
2 parents 8232cac + 0be004e commit 5bee7c1

File tree

16 files changed

+579
-444
lines changed

16 files changed

+579
-444
lines changed

Doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ PROJECT_NAME = "IBM Watson SDK for Unity"
3838
# could be handy for archiving the generated documentation or if some version
3939
# control system is used.
4040

41-
PROJECT_NUMBER = 2.9.0
41+
PROJECT_NUMBER = 2.10.0
4242

4343
# Using the PROJECT_BRIEF tag one can provide an optional one line description
4444
# for a project that appears at the top of each page and should give viewer a

Examples/ServiceExamples/Scripts/ExampleAssistantV2.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@
1515
*
1616
*/
1717

18-
using System;
1918
using System.Collections;
2019
using System.Collections.Generic;
21-
using FullSerializer;
2220
using IBM.Watson.DeveloperCloud.Connection;
2321
using IBM.Watson.DeveloperCloud.Logging;
2422
using IBM.Watson.DeveloperCloud.Utilities;
@@ -58,8 +56,6 @@ public class ExampleAssistantV2 : MonoBehaviour
5856

5957
private Assistant _service;
6058

61-
private fsSerializer _serializer = new fsSerializer();
62-
6359
private bool _createSessionTested = false;
6460
private bool _messageTested = false;
6561
private bool _deleteSessionTested = false;

Examples/ServiceExamples/Scripts/ExampleVisualRecognition.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,7 @@ void Start()
8888
private IEnumerator CreateService()
8989
{
9090
Credentials credentials = null;
91-
if (!string.IsNullOrEmpty(_apikey))
92-
{
93-
// Authenticate using apikey
94-
credentials = new Credentials(_apikey, _serviceUrl);
95-
}
96-
else if (!string.IsNullOrEmpty(_iamApikey))
91+
if (!string.IsNullOrEmpty(_iamApikey))
9792
{
9893
// Authenticate using iamApikey
9994
TokenOptions tokenOptions = new TokenOptions()
@@ -110,7 +105,7 @@ private IEnumerator CreateService()
110105
}
111106
else
112107
{
113-
throw new WatsonException("Please provide either CF apikey or IAM apikey to authenticate the service.");
108+
throw new WatsonException("Please provide IAM apikey to authenticate the service.");
114109
}
115110

116111
// Create credential and instantiate service

README.md

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ The credentials for each service contain either a `username`, `password` and end
6767
To get started with the Watson Services in Unity, click on each service below to read through each of their `README.md`'s and their codes.
6868
* [Assistant V1](/Scripts/Services/Assistant/v1)
6969
* [Assistant V2](/Scripts/Services/Assistant/v2)
70-
* [Conversation](/Scripts/Services/Conversation/v1)
70+
* [Conversation](/Scripts/Services/Conversation/v1) (deprecated - Use Assistant V1 or Assistant V2)
7171
* [Discovery](/Scripts/Services/Discovery/v1)
72-
* [Language Translator V2](/Scripts/Services/LanguageTranslator/v2) (deprecated)
72+
* [Language Translator V2](/Scripts/Services/LanguageTranslator/v2) (deprecated - Use LanguageTranslator V3)
7373
* [Language Translator V3](/Scripts/Services/LanguageTranslator/v3)
7474
* [Natural Language Classifier](/Scripts/Services/NaturalLanguageClassifier/v2)
7575
* [Natural Language Understanding](/Scripts/Services/NaturalLanguageUnderstanding/v1)
@@ -84,7 +84,6 @@ Watson services are migrating to token-based Identity and Access Management (IAM
8484

8585
- With some service instances, you authenticate to the API by using **[IAM](#iam)**.
8686
- In other instances, you authenticate by providing the **[username and password](#username-and-password)** for the service instance.
87-
- Visual Recognition uses a form of [API key](#api-key) only with instances created before May 23, 2018. Newer instances of Visual Recognition use [IAM](#iam).
8887

8988
### Getting credentials
9089
To find out which authentication to use, view the service credentials. You find the service credentials for authentication the same way for all Watson services:
@@ -179,20 +178,6 @@ void Start()
179178
}
180179
```
181180

182-
### API key
183-
**Important**: This type of authentication works only with Visual Recognition instances created before May 23, 2018. Newer instances of Visual Recognition use [IAM](#iam).
184-
```cs
185-
using IBM.Watson.DeveloperCloud.Services.VisualRecognition.v3;
186-
using IBM.Watson.DeveloperCloud.Utilities;
187-
188-
void Start()
189-
{
190-
Credentials credentials = new Credentials(<apikey>, <url>);
191-
VisualRecognition _visualRecognition = new VisualRecognition(credentials);
192-
}
193-
```
194-
195-
196181
## Callbacks
197182
Success and failure callbacks are required. You can specify the return type in the callback.
198183
```cs

Scripts/Services/Assistant/v1/README.md

Lines changed: 63 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,9 @@ You complete these steps to implement your application:
1111

1212
### Message
1313
Send a message to the Assistant instance
14-
```cs
15-
// Send a simple message using a string
16-
private void Message()
17-
{
18-
if (!_assistant.Message(OnMessage, OnFail, <workspace-id>, <input-string>))
19-
Log.Debug("ExampleAssistant.Message()", "Failed to message!");
20-
}
2114

22-
private void OnMessage(object resp, Dictionary<string, object> customData)
23-
{
24-
Log.Debug("ExampleAssistant.OnMessage()", "Assistant: Message Response: {0}", customData["json"].ToString());
25-
}
26-
```
15+
- Send a message using a MessageRequest object
2716
```cs
28-
// Send a message using a MessageRequest object
2917
private void Message()
3018
{
3119
MessageRequest messageRequest = new MessageRequest()
@@ -45,8 +33,10 @@ private void OnMessage(object resp, Dictionary<string, object> customData)
4533
Log.Debug("ExampleAssistant.OnMessage()", "Assistant: Message Response: {0}", customData["json"].ToString());
4634
}
4735
```
36+
37+
38+
- Send a message perserving conversation context
4839
```cs
49-
// Send a message perserving conversation context
5040
Dictionary<string, object> _context; // context to persist
5141
5242
// Initiate a conversation
@@ -91,4 +81,63 @@ private void OnMessage1(object resp, Dictionary<string, object> customData)
9181
}
9282
```
9383

84+
85+
- Send a message perserving conversation context - Extract code from [ExampleAssistant.cs](https://github.com/watson-developer-cloud/unity-sdk/blob/develop/Examples/ServiceExamples/Scripts/ExampleAssistant.cs)
86+
```cs
87+
88+
private void Message()
89+
{
90+
MessageRequest messageRequest = new MessageRequest()
91+
{
92+
input = new Dictionary<string, object>()
93+
{
94+
{ "text", <input-string> }
95+
}
96+
};
97+
98+
if (!_assistant.Message(OnMessage, OnFail, <workspace-id>, messageRequest))
99+
Log.Debug("ExampleAssistant.Message()", "Failed to message!");
100+
}
101+
102+
private void OnMessage(object response, Dictionary<string, object> customData)
103+
{
104+
Log.Debug("ExampleAssistant.OnMessage()", "Response: {0}", customData["json"].ToString());
105+
106+
// Convert resp to fsdata
107+
fsData fsdata = null;
108+
fsResult r = _serializer.TrySerialize(response.GetType(), response, out fsdata);
109+
if (!r.Succeeded)
110+
throw new WatsonException(r.FormattedMessages);
111+
112+
// Convert fsdata to MessageResponse
113+
MessageResponse messageResponse = new MessageResponse();
114+
object obj = messageResponse;
115+
r = _serializer.TryDeserialize(fsdata, obj.GetType(), ref obj);
116+
if (!r.Succeeded)
117+
throw new WatsonException(r.FormattedMessages);
118+
119+
// Set context for next round of messaging
120+
object _tempContext = null;
121+
(response as Dictionary<string, object>).TryGetValue("context", out _tempContext);
122+
123+
if (_tempContext != null)
124+
_context = _tempContext as Dictionary<string, object>;
125+
else
126+
Log.Debug("ExampleAssistant.OnMessage()", "Failed to get context");
127+
128+
// Get intent
129+
object tempIntentsObj = null;
130+
(response as Dictionary<string, object>).TryGetValue("intents", out tempIntentsObj);
131+
object tempIntentObj = (tempIntentsObj as List<object>)[0];
132+
object tempIntent = null;
133+
(tempIntentObj as Dictionary<string, object>).TryGetValue("intent", out tempIntent);
134+
string intent = tempIntent.ToString();
135+
136+
Log.Debug("ExampleAssistant.OnMessage()", "intent: {0}", intent);
137+
138+
_messageTested = true;
139+
}
140+
141+
```
142+
94143
[assistant]: https://console.bluemix.net/docs/services/assistant/index.html

Scripts/Services/Conversation/v1/Conversation.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ public Credentials Credentials
9292
/// Conversation constructor
9393
/// </summary>
9494
/// <param name="credentials">The service credentials</param>
95+
[Obsolete("Conversation V1 is deprecated and will be removed in the next major release of the SDK. Use Assistant V1 or Assistant V2.")]
9596
public Conversation(Credentials credentials)
9697
{
9798
if (credentials.HasCredentials() || credentials.HasWatsonAuthenticationToken() || credentials.HasIamTokenData())

Scripts/Services/Conversation/v1/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Conversation
22

3+
**Conversation V1 is deprecated and will be removed in the next major release of the SDK. Use Assistant V1 or Assistant V2.**
4+
35
With the IBM Watson™ [Conversation][conversation] service, you can create an application that understands natural-language input and uses machine learning to respond to customers in a way that simulates a conversation between humans.
46

57
## Usage

Scripts/Services/Discovery/v1/DataModels.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,20 @@ public class Environment
7171
/// </summary>
7272
public bool read_only { get; set; }
7373
/// <summary>
74-
/// Size of the environment. = ['XS', 'S', 'MS', 'M', 'ML', 'L', 'XL', 'XXL', 'XXXL'].
74+
/// Size of the environment. = ['LT', 'XS', 'S', 'MS', 'M', 'ML', 'L', 'XL', 'XXL', 'XXXL'].
7575
/// </summary>
7676
public SizeEnum? size { get; set; }
7777
/// <summary>
78+
/// The new size requested for this environment. Only returned when the environment *status* is `resizing`.
79+
///
80+
/// *Note:* Querying and indexing can still be performed during an environment upsize.
81+
/// </summary>
82+
public string requested_size { get; set; }
83+
/// <summary>
84+
/// Information about Continuous Relevancy Training for this environment.
85+
/// </summary>
86+
public SearchStatus search_status { get; set; }
87+
/// <summary>
7888
/// Disk and memory usage.
7989
/// </summary>
8090
public IndexCapacity index_capacity { get; set; }
@@ -112,6 +122,11 @@ public class CreateEnvironmentRequest
112122
/// </value>
113123
public enum SizeEnum
114124
{
125+
/// <summary>
126+
/// Enum LT for LT
127+
/// </summary>
128+
[EnumMember(Value = "LT")]
129+
LT,
115130

116131
/// <summary>
117132
/// Enum XS for XS

0 commit comments

Comments
 (0)