Python主机上的chatterbot

2024-09-17 07:26:47 发布

您现在位置:Python中文网/ 问答频道 /正文

我希望在服务器上运行我的chatterbot,同时允许与用户进行来回对话。我怎样才能做到这一点?你知道吗

我在考虑使用pm2来运行bot作为一种服务,但是如果一个用户忙于监听传入的请求,它怎么能“连接”到这个bot呢?你知道吗

我需要这个.py模块作为一个单独的服务器与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

Tags: 用户fromimport服务器youinputoutputadapter
1条回答
网友
1楼 · 发布于 2024-09-17 07:26:47

要做到这一点还有很多工作要做,下面是您需要遵循的快速步骤列表:

  1. 设计一个与聊天机器人交互的web应用程序
  2. 设置一个服务器并在其中安装聊天机器人和web
  3. train chatterbot保持服务器全天候运行
  4. 购买域名链接到你的网站。你知道吗
  5. 生成$;)

相关问题 更多 >