|
| 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