[英]Python host chatterbot on server
I want to have my chatterbot run on the server, while at the same time allow conversations to go back and forth with a user. 我想让我的chatterbot在服务器上运行,同时允许与用户进行来回对话。 How can I achieve this?
我该如何实现?
I was thinking using pm2 to run the bot as a service, but how can a user 'connect' to this bot at all if it is busy listening to incoming requests? 我当时在考虑使用pm2将机器人作为服务运行,但是如果忙于侦听传入的请求,用户如何才能“连接”到该机器人呢?
Do I need this .py module to work as a separate server along with the bot? 我需要这个.py模块与机器人一起作为单独的服务器工作吗?
The following is the bot code, it's pretty much the boiler plate from the chatterbot setup guide: 以下是bot代码,几乎是chatterbot设置指南中的样板:
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
chatbot = ChatBot("Inssa Bot",
logic_adapters=[
"chatterbot.logic.MathematicalEvaluation",
"chatterbot.logic.TimeLogicAdapter"
],
input_adapter="chatterbot.input.VariableInputTypeAdapter",
output_adapter="chatterbot.output.OutputAdapter"
)
conversation = [
"Hello",
"Hi there!",
"How are you doing?",
"I'm doing great.",
"That is good to hear",
"Thank you.",
"You're welcome."
]
chatbot.set_trainer(ListTrainer)
chatbot.train(conversation)
while True:
try:
say = input('Speak: ')
bot_input = chatbot.get_response(say)
print(bot_input)
except(KeyboardInterrupt, EOFError, SystemExit):
print('aaaaa')
break
There is a lot of work to do to achieve so, here is a quick list of steps you need to follow: 为此,有许多工作要做,这里是您需要遵循的快速步骤列表:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.