如何与聊天机器人进行持续对话?
How to have an ongoing conversation with a Chatbot?
我已经在 python 上成功实现了我的聊天机器人,它调用 api.ai 进行 HTTP 响应,然后解析值,基本上得到我想要的部分。
问题是我想要一个持续的对话,例如,假设我打招呼,机器人打招呼并且 python 代码第一次有 运行 那么我必须 运行它又问你好吗
我真正想要的是与机器人进行对话,无论我可以使用 python 代码的一个 运行 发送和接收多少请求。
这是您的程序的可能结构 -
# Initialize your program, lots of code here, get token/id, setup other variables
def process_input(input_text):
# clean input text
# get response from web bot
response = requests.get('url')
# clean response and then print it/redirect it
return response
if __name__=='__main__':
while True:
user_input = raw_input()
print(process_input(user_input))
# also add some terminal conditions like if user types 'bye', break while loop and exit
我已经在 python 上成功实现了我的聊天机器人,它调用 api.ai 进行 HTTP 响应,然后解析值,基本上得到我想要的部分。 问题是我想要一个持续的对话,例如,假设我打招呼,机器人打招呼并且 python 代码第一次有 运行 那么我必须 运行它又问你好吗
我真正想要的是与机器人进行对话,无论我可以使用 python 代码的一个 运行 发送和接收多少请求。
这是您的程序的可能结构 -
# Initialize your program, lots of code here, get token/id, setup other variables
def process_input(input_text):
# clean input text
# get response from web bot
response = requests.get('url')
# clean response and then print it/redirect it
return response
if __name__=='__main__':
while True:
user_input = raw_input()
print(process_input(user_input))
# also add some terminal conditions like if user types 'bye', break while loop and exit