-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #292 from watson-developer-cloud/rc-2.9.0
v2.9.0
- Loading branch information
Showing
109 changed files
with
2,682 additions
and
323 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[bumpversion] | ||
commit = True | ||
current_version = 2.8.0 | ||
current_version = 2.9.0 | ||
|
||
[bumpversion:file:Doxyfile] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
examples/IBM.WatsonDeveloperCloud.Assistant.v2.Example/AssistantServiceExample.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
| ||
|
||
using IBM.WatsonDeveloperCloud.Assistant.v2.Model; | ||
using Newtonsoft.Json; | ||
using System; | ||
/** | ||
* Copyright 2018 IBM Corp. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
namespace IBM.WatsonDeveloperCloud.Assistant.v2.Example | ||
{ | ||
internal class AssistantServiceExample | ||
{ | ||
private AssistantService _assistant; | ||
private string _assistantId; | ||
private string[] _questionArray = { "", "good", "i want a pizza", "large", "three" }; | ||
private int _questionIndex = 0; | ||
private string _sessionId; | ||
|
||
public AssistantServiceExample(string url, string username, string password, string assistantId) | ||
{ | ||
_assistant = new AssistantService(username, password, "2018-09-20"); | ||
_assistant.SetEndpoint(url); | ||
|
||
_assistantId = assistantId; | ||
|
||
var session = _assistant.CreateSession(_assistantId); | ||
_sessionId = session.SessionId; | ||
|
||
CallAssistant(_questionIndex); | ||
} | ||
|
||
public void CallAssistant(int questionIndex) | ||
{ | ||
MessageRequest messageRequest = new MessageRequest() | ||
{ | ||
Input = new MessageInput() | ||
{ | ||
Text = _questionArray[questionIndex] | ||
} | ||
}; | ||
|
||
Console.WriteLine(_questionArray[questionIndex]); | ||
var result = _assistant.Message(_assistantId, _sessionId, messageRequest); | ||
Console.WriteLine(result.Output.Generic[0].Text); | ||
_questionIndex++; | ||
|
||
if (questionIndex < _questionArray.Length - 1) | ||
{ | ||
CallAssistant(_questionIndex); | ||
} | ||
else | ||
{ | ||
_assistant.DeleteSession(_assistantId, _sessionId); | ||
Console.WriteLine("Session deleted!"); | ||
} | ||
} | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
examples/IBM.WatsonDeveloperCloud.Assistant.v2.Example/Example.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/** | ||
* Copyright 2018 IBM Corp. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
using IBM.WatsonDeveloperCloud.Util; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Linq; | ||
using System; | ||
using System.IO; | ||
|
||
namespace IBM.WatsonDeveloperCloud.Assistant.v2.Example | ||
{ | ||
class Example | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
string credentials = string.Empty; | ||
|
||
#region Get Credentials | ||
string _endpoint = string.Empty; | ||
string _username = string.Empty; | ||
string _password = string.Empty; | ||
string _assistantId = string.Empty; | ||
|
||
if (string.IsNullOrEmpty(credentials)) | ||
{ | ||
var parentDirectory = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent.Parent.Parent.FullName; | ||
string credentialsFilepath = parentDirectory + Path.DirectorySeparatorChar + "sdk-credentials" + Path.DirectorySeparatorChar + "credentials.json"; | ||
if (File.Exists(credentialsFilepath)) | ||
{ | ||
try | ||
{ | ||
credentials = File.ReadAllText(credentialsFilepath); | ||
credentials = Utility.AddTopLevelObjectToJson(credentials, "VCAP_SERVICES"); | ||
} | ||
catch (Exception e) | ||
{ | ||
throw new Exception(string.Format("Failed to load credentials: {0}", e.Message)); | ||
} | ||
|
||
VcapCredentials vcapCredentials = JsonConvert.DeserializeObject<VcapCredentials>(credentials); | ||
var vcapServices = JObject.Parse(credentials); | ||
|
||
Credential credential = vcapCredentials.GetCredentialByname("assistantV2-sdk-staging")[0].Credentials; | ||
_endpoint = credential.Url; | ||
_username = credential.Username; | ||
_password = credential.Password; | ||
_assistantId = credential.AssistantId; | ||
} | ||
else | ||
{ | ||
Console.WriteLine("Credentials file does not exist. Please define credentials."); | ||
_username = ""; | ||
_password = ""; | ||
_endpoint = ""; | ||
_assistantId = ""; | ||
} | ||
} | ||
#endregion | ||
|
||
AssistantServiceExample _AssistantServiceExample = new AssistantServiceExample(_endpoint, _username, _password, _assistantId); | ||
|
||
Console.ReadKey(); | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...nDeveloperCloud.Assistant.v2.Example/IBM.WatsonDeveloperCloud.Assistant.v2.Example.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<VersionPrefix>2.8.0</VersionPrefix> | ||
<TargetFramework>netcoreapp1.0</TargetFramework> | ||
<AssemblyName>IBM.WatsonDeveloperCloud.Conversation.v1.Example</AssemblyName> | ||
<OutputType>Exe</OutputType> | ||
<PackageId>IBM.WatsonDeveloperCloud.Conversation.v1.Example</PackageId> | ||
<RuntimeFrameworkVersion>1.0.4</RuntimeFrameworkVersion> | ||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> | ||
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> | ||
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> | ||
<Version>2.8.0</Version> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> | ||
<DebugType>full</DebugType> | ||
<DebugSymbols>true</DebugSymbols> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> | ||
<DebugType>full</DebugType> | ||
<DebugSymbols>true</DebugSymbols> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\IBM.WatsonDeveloperCloud.Assistant.v2\IBM.WatsonDeveloperCloud.Assistant.v2.csproj" /> | ||
<ProjectReference Include="..\..\src\IBM.WatsonDeveloperCloud\IBM.WatsonDeveloperCloud.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.