Skip to content

Watson SDK for Unity 2.6.0 #434

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 14 commits into from
Aug 7, 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: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,5 @@ Docs/publishing-release.md.meta
*.md.meta
*.txt.meta
*.ps1.meta
**/.swagger-codegen-ignore
**/.swagger-codegen
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: objective-c
osx_image: xcode61
rvm:
- 2.1.2
- 2.2
cache:
directories:
- ./Unity
Expand Down
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.4.2
PROJECT_NUMBER = 2.6.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
43 changes: 31 additions & 12 deletions Examples/ServiceExamples/Scripts/ExampleAssistant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public class ExampleAssistant : MonoBehaviour
private bool _createEntityTested = false;
private bool _getEntityTested = false;
private bool _updateEntityTested = false;
private bool _listMentionsTested = false;
private bool _listValuesTested = false;
private bool _createValueTested = false;
private bool _getValueTested = false;
Expand Down Expand Up @@ -189,8 +190,8 @@ private IEnumerator Examples()
// Update Workspace
UpdateWorkspace updateWorkspace = new UpdateWorkspace()
{
Name = _createdWorkspaceName + "-updated",
Description = _createdWorkspaceDescription + "-updated",
Name = _createdWorkspaceName + "Updated",
Description = _createdWorkspaceDescription + "Updated",
Language = _createdWorkspaceLanguage
};
_service.UpdateWorkspace(OnUpdateWorkspace, OnFail, _createdWorkspaceId, updateWorkspace);
Expand Down Expand Up @@ -259,8 +260,8 @@ private IEnumerator Examples()
while (!_getIntentTested)
yield return null;
// Update Intents
string updatedIntent = _createdIntent + "-updated";
string updatedIntentDescription = _createdIntentDescription + "-updated";
string updatedIntent = _createdIntent + "Updated";
string updatedIntentDescription = _createdIntentDescription + "Updated";
UpdateIntent updateIntent = new UpdateIntent()
{
Intent = updatedIntent,
Expand All @@ -287,7 +288,7 @@ private IEnumerator Examples()
while (!_getExampleTested)
yield return null;
// Update Examples
string updatedExample = _createdExample + "-updated";
string updatedExample = _createdExample + "Updated";
UpdateExample updateExample = new UpdateExample()
{
Text = updatedExample
Expand All @@ -314,8 +315,8 @@ private IEnumerator Examples()
while (!_getEntityTested)
yield return null;
// Update Entities
string updatedEntity = _createdEntity + "-updated";
string updatedEntityDescription = _createdEntityDescription + "-updated";
string updatedEntity = _createdEntity + "Updated";
string updatedEntityDescription = _createdEntityDescription + "Updated";
UpdateEntity updateEntity = new UpdateEntity()
{
Entity = updatedEntity,
Expand All @@ -325,6 +326,11 @@ private IEnumerator Examples()
while (!_updateEntityTested)
yield return null;

// List Mentinos
_service.ListMentions(OnListMentions, OnFail, _createdWorkspaceId, updatedEntity);
while (!_listMentionsTested)
yield return null;

// List Values
_service.ListValues(OnListValues, OnFail, _createdWorkspaceId, updatedEntity);
while (!_listValuesTested)
Expand All @@ -342,7 +348,7 @@ private IEnumerator Examples()
while (!_getValueTested)
yield return null;
// Update Values
string updatedValue = _createdValue + "-updated";
string updatedValue = _createdValue + "Updated";
UpdateValue updateValue = new UpdateValue()
{
Value = updatedValue
Expand All @@ -368,7 +374,7 @@ private IEnumerator Examples()
while (!_getSynonymTested)
yield return null;
// Update Synonyms
string updatedSynonym = _createdSynonym + "-updated";
string updatedSynonym = _createdSynonym + "Updated";
UpdateSynonym updateSynonym = new UpdateSynonym()
{
Synonym = updatedSynonym
Expand All @@ -395,8 +401,8 @@ private IEnumerator Examples()
while (!_getDialogNodeTested)
yield return null;
// Update Dialog Nodes
string updatedDialogNodeName = _dialogNodeName + "_updated";
string updatedDialogNodeDescription = _dialogNodeDesc + "_updated";
string updatedDialogNodeName = _dialogNodeName + "Updated";
string updatedDialogNodeDescription = _dialogNodeDesc + "Updated";
UpdateDialogNode updateDialogNode = new UpdateDialogNode()
{
DialogNode = updatedDialogNodeName,
Expand Down Expand Up @@ -433,7 +439,7 @@ private IEnumerator Examples()
while (!_getCounterexampleTested)
yield return null;
// Update Counterexamples
string updatedCounterExampleText = _createdCounterExampleText + "-updated";
string updatedCounterExampleText = _createdCounterExampleText + "Updated";
UpdateCounterexample updateCounterExample = new UpdateCounterexample()
{
Text = updatedCounterExampleText
Expand Down Expand Up @@ -480,6 +486,12 @@ private IEnumerator Examples()
yield break;
}

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

private void OnDeleteWorkspace(object response, Dictionary<string, object> customData)
{
Log.Debug("ExampleAssistant.OnDeleteWorkspace()", "Response: {0}", customData["json"].ToString());
Expand Down Expand Up @@ -769,6 +781,13 @@ private void OnCreateWorkspace(Workspace response, Dictionary<string, object> cu
private void OnListWorkspaces(WorkspaceCollection response, Dictionary<string, object> customData)
{
Log.Debug("ExampleAssistant.OnListWorkspaces()", "Response: {0}", customData["json"].ToString());

foreach(Workspace workspace in response.Workspaces)
{
if(workspace.Name.Contains("unity"))
_service.DeleteWorkspace(OnDeleteWorkspace, OnFail, workspace.WorkspaceId);
}

_listWorkspacesTested = true;
}

Expand Down
27 changes: 12 additions & 15 deletions Examples/ServiceExamples/ServiceExamples.unity
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ OcclusionCullingSettings:
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 9
serializedVersion: 8
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
Expand All @@ -38,8 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.37311926, g: 0.38073996, b: 0.35872692, a: 1}
m_UseRadianceAmbientProbe: 0
m_IndirectSpecularColor: {r: 0.37311953, g: 0.38074014, b: 0.3587274, a: 1}
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
Expand All @@ -55,10 +54,11 @@ LightmapSettings:
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 1
m_LightmapEditorSettings:
serializedVersion: 10
serializedVersion: 9
m_Resolution: 2
m_BakeResolution: 40
m_AtlasSize: 1024
m_TextureWidth: 1024
m_TextureHeight: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 0
Expand Down Expand Up @@ -88,7 +88,6 @@ LightmapSettings:
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ShowResolutionOverlay: 1
m_LightingDataAsset: {fileID: 0}
m_UseShadowmask: 0
--- !u!196 &4
Expand All @@ -110,8 +109,6 @@ NavMeshSettings:
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &85803340
GameObject:
Expand Down Expand Up @@ -276,11 +273,11 @@ Camera:
m_TargetEye: 3
m_HDR: 0
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
m_StereoMirrorMode: 0
--- !u!4 &725710372
Transform:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -309,7 +306,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!114 &832860417
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -816,7 +813,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!114 &2118312580
MonoBehaviour:
m_ObjectHideFlags: 0
Expand All @@ -829,10 +826,10 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
_serviceUrl:
_workspaceId:
_versionDate:
_username:
_password:
_workspaceId: edff566a-66b3-477b-85ad-67c4b6837745
_versionDate: 2018-07-10
_username: 3a13aa4a-6cd1-437c-b0c3-7b1245d701ad
_password: 5OZLsFZN4Y0m
_iamApikey:
_iamUrl:
--- !u!4 &2118312581
Expand Down
110 changes: 110 additions & 0 deletions Scripts/Services/Assistant/v1/Assistant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2708,6 +2708,116 @@ private void OnUpdateEntityResponse(RESTConnector.Request req, RESTConnector.Res
((UpdateEntityRequestObj)req).FailCallback(resp.Error, customData);
}
}

/// <summary>
/// List entity mentions.
///
/// List mentions for a contextual entity. An entity mention is an occurrence of a contextual entity in the
/// context of an intent user input example.
///
/// This operation is limited to 200 requests per 30 minutes. For more information, see **Rate limiting**.
/// </summary>
/// <param name="successCallback">The function that is called when the operation is successful.</param>
/// <param name="failCallback">The function that is called when the operation fails.</param>
/// <param name="workspaceId">Unique identifier of the workspace.</param>
/// <param name="entity">The name of the entity.</param>
/// <param name="export">Whether to include all element content in the returned data. If **export**=`false`, the
/// returned data includes only information about the element itself. If **export**=`true`, all content,
/// including subelements, is included. (optional, default to false)</param>
/// <param name="includeAudit">Whether to include the audit properties (`created` and `updated` timestamps) in
/// the response. (optional, default to false)</param>
/// <returns><see cref="EntityMentionCollection" />EntityMentionCollection</returns>
/// <param name="customData">A Dictionary<string, object> of data that will be passed to the callback. The raw
/// json output from the REST call will be passed in this object as the value of the 'json'
/// key.</string></param>
public bool ListMentions(SuccessCallback<EntityMentionCollection> successCallback, FailCallback failCallback, string workspaceId, string entity, bool? export = null, bool? includeAudit = null, Dictionary<string, object> customData = null)
{
if (successCallback == null)
throw new ArgumentNullException("successCallback");
if (failCallback == null)
throw new ArgumentNullException("failCallback");

ListMentionsRequestObj req = new ListMentionsRequestObj();
req.SuccessCallback = successCallback;
req.FailCallback = failCallback;
req.CustomData = customData == null ? new Dictionary<string, object>() : customData;
if (req.CustomData.ContainsKey(Constants.String.CUSTOM_REQUEST_HEADERS))
{
foreach (KeyValuePair<string, string> kvp in req.CustomData[Constants.String.CUSTOM_REQUEST_HEADERS] as Dictionary<string, string>)
{
req.Headers.Add(kvp.Key, kvp.Value);
}
}
req.Parameters["version"] = VersionDate;
if (export != null)
req.Parameters["export"] = export;
if (includeAudit != null)
req.Parameters["include_audit"] = includeAudit;
req.OnResponse = OnListMentionsResponse;

RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/workspaces/{0}/entities/{1}/mentions", workspaceId, entity));
if (connector == null)
return false;

return connector.Send(req);
}

private class ListMentionsRequestObj : RESTConnector.Request
{
/// <summary>
/// The success callback.
/// </summary>
public SuccessCallback<EntityMentionCollection> SuccessCallback { get; set; }
/// <summary>
/// The fail callback.
/// </summary>
public FailCallback FailCallback { get; set; }
/// <summary>
/// Custom data.
/// </summary>
public Dictionary<string, object> CustomData { get; set; }
}

private void OnListMentionsResponse(RESTConnector.Request req, RESTConnector.Response resp)
{
EntityMentionCollection result = new EntityMentionCollection();
fsData data = null;
Dictionary<string, object> customData = ((ListMentionsRequestObj)req).CustomData;

if (resp.Success)
{
try
{
fsResult r = fsJsonParser.Parse(Encoding.UTF8.GetString(resp.Data), out data);
if (!r.Succeeded)
throw new WatsonException(r.FormattedMessages);

object obj = result;
r = _serializer.TryDeserialize(data, obj.GetType(), ref obj);
if (!r.Succeeded)
throw new WatsonException(r.FormattedMessages);

customData.Add("json", data);
}
catch (Exception e)
{
Log.Error("Assistant.OnListMentionsResponse()", "Exception: {0}", e.ToString());
resp.Success = false;
}
}

if (resp.Success)
{
if (((ListMentionsRequestObj)req).SuccessCallback != null)
((ListMentionsRequestObj)req).SuccessCallback(result, customData);
}
else
{
if (((ListMentionsRequestObj)req).FailCallback != null)
((ListMentionsRequestObj)req).FailCallback(resp.Error, customData);
}
}

/// <summary>
/// Add entity value. Create a new value for an entity. This operation is limited to 1000 requests per 30 minutes. For more information, see [**Rate limiting**](https://www.ibm.com/watson/developercloud/assistant/api/v1/#rate-limiting).
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions Scripts/Services/Assistant/v1/IAssistant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public interface IAssistant
bool ListEntities(SuccessCallback<EntityCollection> successCallback, FailCallback failCallback, string workspaceId, bool? export = null, long? pageLimit = null, bool? includeCount = null, string sort = null, string cursor = null, bool? includeAudit = null, Dictionary<string, object> customData = null);

bool UpdateEntity(SuccessCallback<Entity> successCallback, FailCallback failCallback, string workspaceId, string entity, UpdateEntity properties, Dictionary<string, object> customData = null);
bool ListMentions(SuccessCallback<EntityMentionCollection> successCallback, FailCallback failCallback, string workspaceId, string entity, bool? export = null, bool? includeAudit = null, Dictionary<string, object> customData = null);
bool CreateValue(SuccessCallback<Value> successCallback, FailCallback failCallback, string workspaceId, string entity, CreateValue properties, Dictionary<string, object> customData = null);

bool DeleteValue(SuccessCallback<object> successCallback, FailCallback failCallback, string workspaceId, string entity, string value, Dictionary<string, object> customData = null);
Expand Down
5 changes: 5 additions & 0 deletions Scripts/Services/Assistant/v1/Model/CreateDialogNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ public enum EventNameEnum
/// <value>The location in the dialog context where output is stored.</value>
[fsProperty("variable")]
public string Variable { get; set; }
/// <summary>
/// A label that can be displayed externally to describe the purpose of the node to users.
/// </summary>
[fsProperty("user_label")]
public string UserLabel { get; set; }
}

}
Loading