【问题标题】:chatterbot taking ages to return responsechatterbot 需要很长时间才能返回响应
【发布时间】:2020-09-13 21:54:35
【问题描述】:

我有一段从示例中提取的代码。它在 repl.it 上运行良好,就像几秒钟后的响应一样。但是,过了一段时间,它开始在 1-3 分钟后返回响应,甚至更多或永远不会。
这开始在重新启动时突然发生。我尝试重置数据库。那没有帮助。然后我尝试制作一个新的repl。这也无济于事

这是我的代码:

from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer
import logging


'''
This is an example showing how to train a chat bot using the
ChatterBot Corpus of conversation dialog.
'''

# Enable info level logging
logging.basicConfig(level=logging.INFO)

chatbot = ChatBot('Example Bot')

# Start by training our bot with the ChatterBot corpus data
chatbot.set_trainer(ChatterBotCorpusTrainer)

chatbot.train(
    'chatterbot.corpus.english'
)
while True:
    inp = input("=> ")
    print(chatbot.get_response(inp))

它开始工作正常,但卡在:

/opt/virtualenvs/python3/lib/python3.8/site-packages/chatterbot/storage/jsonfile.py:24: UnsuitableForProductionWarning:The JsonFileStorageAdapter is not recommended for production environments.
warnings.warn(
=> Hello
INFO:chatterbot.adapters:Recieved input statement: Hello
INFO:chatterbot.adapters:"Hello" is a known statement

这里是repl链接:https://repl.it/@blackskull12/chatterbottest#main.py


如果我替换:

chatbot.set_trainer(ChatterBotCorpusTrainer)

chatbot.train(
    'chatterbot.corpus.english'
)

到:

trainer = ChatterBotCorpusTrainer(chatbot)

trainer.train(
    'chatterbot.corpus.english'
)

此更改在我的电脑上运行良好。但是在repl上给出错误。 ChatBot has no atribute 'find'

我不知道从哪里继续。谁能帮助我,让我的机器人重获新生?

【问题讨论】:

  • 我希望这些信息量足够

标签: python artificial-intelligence bots chatterbot repl.it


【解决方案1】:

TDRL; 我不确定为什么它会“卡住”,但如果它在您的 PC 上运行良好,那么问题可能是 Repl.it 上的 chatterbox 版本是旧版本(尽管 repl 可能由于权限问题或性能检查/限制)。

“查找”错误

如下图github issue tracker:

最近在 1.0.0a1 版本中删除了 find 属性,但我不确定您为什么会从 0.8.7 版本中收到此消息。

您可以在 PC 上降级到以前的版本(以匹配 repl.it 中的版本)1:

pip3 install chatterbot==0.8.6

或重新安装 chatterbox 并将其升级到 1.0.0a1 以上以使用 chatbot.set_trainer(ChatterBotCorpusTrainer)) 方法。在您的 PC 上:

sudo pip3 uninstall chatterbot
sudo pip3 install chatterbot --no-cache-dir

对于 Repl.it:2 根据他们的文档,他们有一个 GUI package manager you can use to install a package:

点击“包装盒”符号:

搜索并单击包,然后单击加号以添加它

这应该显示为 正在安装 1.1 版 ....

要检查您在家庭桌面上使用的版本并重新使用以下命令(无论您的 Python 别名是什么):

python3 -m chatterbot --version

1:我不建议这样做,因为它正在您的 PC 上运行,因此升级似乎是更有可能的解决方案。

2:我不建议为此使用 Repl.it,因为小型 repl 需要处理很多 - 在我的系统中安装 9 个依赖项需要很长时间,并且 repl.it 有多个 CPU正如人们所期望的那样,限制到位。我也有一个付费帐户,因此给了我不同的权限。如果它不起作用,请联系他们的客户服务。

【讨论】:

  • 好的,所以我尝试在 repl 中以各种方式更新模块。它总是安装旧模块
  • @BlackThunder 我添加了 repl.it 包管理器的链接和显示版本 >1 的图片
  • 您是否尝试过自己安装?因为当我从那里安装时,它会安装版本0.6.3
  • @BlackThunder 然后联系 Repl.it,因为问题在他们这边(对我来说很好)和/或确保您使用 python3 而不是 python 2(他们仍然有 repls 而 1.0 没有据我记得,t 适用于 2,所以不会安装)
  • @BlackThunder 相同。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-07-21
  • 1970-01-01
  • 2017-03-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多