简体   繁体   English

服务器上的Python主机chatterbot

[英]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: 为此,有许多工作要做,这里是您需要遵循的快速步骤列表:

  1. design a web app to interact with your chatbot 设计一个Web应用程序以与您的聊天机器人进行交互
  2. set up a server and install your chatbot and web in it 设置服务器并在其中安装您的聊天机器人和网络
  3. train chatterbot keep server running 24/7 训练chatterbot使服务器保持24/7运行
  4. buy domain link to your site. 购买到您网站的域名链接。
  5. make $ ;) 使$;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM