Skip to content

Unity SDK 2.10.0 #459

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 16 commits into from
Oct 10, 2018
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
2 changes: 1 addition & 1 deletion Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = "IBM Watson SDK for Unity"
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 2.9.0
PROJECT_NUMBER = 2.10.0

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
4 changes: 0 additions & 4 deletions Examples/ServiceExamples/Scripts/ExampleAssistantV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@
*
*/

using System;
using System.Collections;
using System.Collections.Generic;
using FullSerializer;
using IBM.Watson.DeveloperCloud.Connection;
using IBM.Watson.DeveloperCloud.Logging;
using IBM.Watson.DeveloperCloud.Utilities;
Expand Down Expand Up @@ -58,8 +56,6 @@ public class ExampleAssistantV2 : MonoBehaviour

private Assistant _service;

private fsSerializer _serializer = new fsSerializer();

private bool _createSessionTested = false;
private bool _messageTested = false;
private bool _deleteSessionTested = false;
Expand Down
9 changes: 2 additions & 7 deletions Examples/ServiceExamples/Scripts/ExampleVisualRecognition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,7 @@ void Start()
private IEnumerator CreateService()
{
Credentials credentials = null;
if (!string.IsNullOrEmpty(_apikey))
{
// Authenticate using apikey
credentials = new Credentials(_apikey, _serviceUrl);
}
else if (!string.IsNullOrEmpty(_iamApikey))
if (!string.IsNullOrEmpty(_iamApikey))
{
// Authenticate using iamApikey
TokenOptions tokenOptions = new TokenOptions()
Expand All @@ -110,7 +105,7 @@ private IEnumerator CreateService()
}
else
{
throw new WatsonException("Please provide either CF apikey or IAM apikey to authenticate the service.");
throw new WatsonException("Please provide IAM apikey to authenticate the service.");
}

// Create credential and instantiate service
Expand Down
19 changes: 2 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ The credentials for each service contain either a `username`, `password` and end
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.
* [Assistant V1](/Scripts/Services/Assistant/v1)
* [Assistant V2](/Scripts/Services/Assistant/v2)
* [Conversation](/Scripts/Services/Conversation/v1)
* [Conversation](/Scripts/Services/Conversation/v1) (deprecated - Use Assistant V1 or Assistant V2)
* [Discovery](/Scripts/Services/Discovery/v1)
* [Language Translator V2](/Scripts/Services/LanguageTranslator/v2) (deprecated)
* [Language Translator V2](/Scripts/Services/LanguageTranslator/v2) (deprecated - Use LanguageTranslator V3)
* [Language Translator V3](/Scripts/Services/LanguageTranslator/v3)
* [Natural Language Classifier](/Scripts/Services/NaturalLanguageClassifier/v2)
* [Natural Language Understanding](/Scripts/Services/NaturalLanguageUnderstanding/v1)
Expand All @@ -84,7 +84,6 @@ Watson services are migrating to token-based Identity and Access Management (IAM

- With some service instances, you authenticate to the API by using **[IAM](#iam)**.
- In other instances, you authenticate by providing the **[username and password](#username-and-password)** for the service instance.
- 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).

### Getting credentials
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:
Expand Down Expand Up @@ -179,20 +178,6 @@ void Start()
}
```

### API key
**Important**: This type of authentication works only with Visual Recognition instances created before May 23, 2018. Newer instances of Visual Recognition use [IAM](#iam).
```cs
using IBM.Watson.DeveloperCloud.Services.VisualRecognition.v3;
using IBM.Watson.DeveloperCloud.Utilities;

void Start()
{
Credentials credentials = new Credentials(<apikey>, <url>);
VisualRecognition _visualRecognition = new VisualRecognition(credentials);
}
```


## Callbacks
Success and failure callbacks are required. You can specify the return type in the callback.
```cs
Expand Down
77 changes: 63 additions & 14 deletions Scripts/Services/Assistant/v1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,9 @@ You complete these steps to implement your application:

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

private void OnMessage(object resp, Dictionary<string, object> customData)
{
Log.Debug("ExampleAssistant.OnMessage()", "Assistant: Message Response: {0}", customData["json"].ToString());
}
```
- Send a message using a MessageRequest object
```cs
// Send a message using a MessageRequest object
private void Message()
{
MessageRequest messageRequest = new MessageRequest()
Expand All @@ -45,8 +33,10 @@ private void OnMessage(object resp, Dictionary<string, object> customData)
Log.Debug("ExampleAssistant.OnMessage()", "Assistant: Message Response: {0}", customData["json"].ToString());
}
```


- Send a message perserving conversation context
```cs
// Send a message perserving conversation context
Dictionary<string, object> _context; // context to persist

// Initiate a conversation
Expand Down Expand Up @@ -91,4 +81,63 @@ private void OnMessage1(object resp, Dictionary<string, object> customData)
}
```


- 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)
```cs

private void Message()
{
MessageRequest messageRequest = new MessageRequest()
{
input = new Dictionary<string, object>()
{
{ "text", <input-string> }
}
};

if (!_assistant.Message(OnMessage, OnFail, <workspace-id>, messageRequest))
Log.Debug("ExampleAssistant.Message()", "Failed to message!");
}

private void OnMessage(object response, Dictionary<string, object> customData)
{
Log.Debug("ExampleAssistant.OnMessage()", "Response: {0}", customData["json"].ToString());

// Convert resp to fsdata
fsData fsdata = null;
fsResult r = _serializer.TrySerialize(response.GetType(), response, out fsdata);
if (!r.Succeeded)
throw new WatsonException(r.FormattedMessages);

// Convert fsdata to MessageResponse
MessageResponse messageResponse = new MessageResponse();
object obj = messageResponse;
r = _serializer.TryDeserialize(fsdata, obj.GetType(), ref obj);
if (!r.Succeeded)
throw new WatsonException(r.FormattedMessages);

// Set context for next round of messaging
object _tempContext = null;
(response as Dictionary<string, object>).TryGetValue("context", out _tempContext);

if (_tempContext != null)
_context = _tempContext as Dictionary<string, object>;
else
Log.Debug("ExampleAssistant.OnMessage()", "Failed to get context");

// Get intent
object tempIntentsObj = null;
(response as Dictionary<string, object>).TryGetValue("intents", out tempIntentsObj);
object tempIntentObj = (tempIntentsObj as List<object>)[0];
object tempIntent = null;
(tempIntentObj as Dictionary<string, object>).TryGetValue("intent", out tempIntent);
string intent = tempIntent.ToString();

Log.Debug("ExampleAssistant.OnMessage()", "intent: {0}", intent);

_messageTested = true;
}

```

[assistant]: https://console.bluemix.net/docs/services/assistant/index.html
1 change: 1 addition & 0 deletions Scripts/Services/Conversation/v1/Conversation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public Credentials Credentials
/// Conversation constructor
/// </summary>
/// <param name="credentials">The service credentials</param>
[Obsolete("Conversation V1 is deprecated and will be removed in the next major release of the SDK. Use Assistant V1 or Assistant V2.")]
public Conversation(Credentials credentials)
{
if (credentials.HasCredentials() || credentials.HasWatsonAuthenticationToken() || credentials.HasIamTokenData())
Expand Down
2 changes: 2 additions & 0 deletions Scripts/Services/Conversation/v1/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Conversation

**Conversation V1 is deprecated and will be removed in the next major release of the SDK. Use Assistant V1 or Assistant V2.**

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.

## Usage
Expand Down
17 changes: 16 additions & 1 deletion Scripts/Services/Discovery/v1/DataModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,20 @@ public class Environment
/// </summary>
public bool read_only { get; set; }
/// <summary>
/// Size of the environment. = ['XS', 'S', 'MS', 'M', 'ML', 'L', 'XL', 'XXL', 'XXXL'].
/// Size of the environment. = ['LT', 'XS', 'S', 'MS', 'M', 'ML', 'L', 'XL', 'XXL', 'XXXL'].
/// </summary>
public SizeEnum? size { get; set; }
/// <summary>
/// The new size requested for this environment. Only returned when the environment *status* is `resizing`.
///
/// *Note:* Querying and indexing can still be performed during an environment upsize.
/// </summary>
public string requested_size { get; set; }
/// <summary>
/// Information about Continuous Relevancy Training for this environment.
/// </summary>
public SearchStatus search_status { get; set; }
/// <summary>
/// Disk and memory usage.
/// </summary>
public IndexCapacity index_capacity { get; set; }
Expand Down Expand Up @@ -112,6 +122,11 @@ public class CreateEnvironmentRequest
/// </value>
public enum SizeEnum
{
/// <summary>
/// Enum LT for LT
/// </summary>
[EnumMember(Value = "LT")]
LT,

/// <summary>
/// Enum XS for XS
Expand Down
Loading