<p>如您所见,Watson开发人员云中有很多<a href="https://github.com/watson-developer-cloud/python-sdk/blob/master/examples/conversation_v1.py" rel="nofollow noreferrer">examples</a>供IBM开发人员使用。看一个使用<a href="https://github.com/watson-developer-cloud/python-sdk/blob/master/examples/conversation_v1.py" rel="nofollow noreferrer">Watson Conversation</a>的示例。在</p>
<p>当您想对多个请求(消息)使用同一个对话时,您需要包含来自上一个响应的上下文对象。在</p>
<p>但是请记住,您需要在您的工作区内创建对话流。在</p>
<p>例如:</p>
<pre><code>import json
from watson_developer_cloud import ConversationV1
#########################
# message
#########################
conversation = ConversationV1(
username='YOUR SERVICE USERNAME',
password='YOUR SERVICE PASSWORD',
version='2017-04-21')
# replace with your own workspace_id
workspace_id = '0a0c06c1-8e31-4655-9067-58fcac5134fc'
# this example don't include
response = conversation.message(workspace_id=workspace_id, message_input={
'text': 'What\'s the weather like?'})
print(json.dumps(response, indent=2))
# This example include the context object from the previous response.
# response = conversation.message(workspace_id=workspace_id, message_input={
# 'text': 'turn the wipers on'},
# context=response['context']) //example
# print(json.dumps(response, indent=2))
</code></pre>
<ul>
<li>请参阅使用Python的官方<a href="https://www.ibm.com/watson/developercloud/conversation/api/v1/?python#" rel="nofollow noreferrer">API Reference</a>。在</li>
</ul>