Skip to content

Commit 9b68410

Browse files
committed
adding Conversation service
1 parent 6c1937a commit 9b68410

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import json
2+
from watson_developer_cloud import ConversationV1Experimental
3+
4+
5+
conversation = ConversationV1Experimental(
6+
username='YOUR SERVICE USERNAME',
7+
password='YOUR SERVICE PASSWORD',
8+
version='2016-05-09')
9+
10+
# replace with your own workspace_id
11+
workspace_id = '25dfa8a0-0263-471b-8980-317e68c30488'
12+
13+
response = conversation.message(workspace_id=workspace_id, message_input={'text': 'What\'s the weather like?'})
14+
print(json.dumps(response, indent=2))

watson_developer_cloud/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from .alchemy_vision_v1 import AlchemyVisionV1
2121
from .authorization_v1 import AuthorizationV1
2222
from .concept_insights_v2 import ConceptInsightsV2
23+
from .conversation_v1_experimental import ConversationV1Experimental
2324
from .document_conversion_v1 import DocumentConversionV1
2425
from .dialog_v1 import DialogV1
2526
from .language_translation_v2 import LanguageTranslationV2
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Copyright 2016 IBM All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
"""
15+
The Conversation v1 experimental service
16+
(http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/conversation.html)
17+
"""
18+
19+
from .watson_developer_cloud_service import WatsonDeveloperCloudService
20+
21+
22+
class ConversationV1Experimental(WatsonDeveloperCloudService):
23+
"""Client for the Conversation service"""
24+
25+
default_url = 'https://gateway.watsonplatform.net/conversation-experimental/api'
26+
latest_version = '2016-05-19'
27+
28+
def __init__(self, version, url=default_url, username=None, password=None, use_vcap_services=True):
29+
WatsonDeveloperCloudService.__init__(
30+
self, 'conversation', url, username, password, use_vcap_services)
31+
self.version = version
32+
33+
def message(self, workspace_id, message_input, context=None):
34+
"""
35+
Retrieves information about a specific classifier.
36+
:param workspace_id: The workspace to use
37+
:param message_input: The input, usually containing a text field
38+
:param context: The optional context object
39+
"""
40+
41+
params = {'version': self.version}
42+
data = {'input': message_input,
43+
'context': context}
44+
return self.request(method='POST', url='/v1/workspaces/{0}/message'.format(workspace_id), params=params,
45+
json=data, accept_json=True)

0 commit comments

Comments
 (0)