gpt4 book ai didi

python - AttributeError: 'ChatBot' 对象没有属性 'get_responce'

转载 作者:行者123 更新时间:2023-12-01 00:35:56 24 4
gpt4 key购买 nike

我正在尝试制作聊天机器人,但它有一些意外的错误。请帮我解决这个问题。

from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
import os

bot = ChatBot('bot',storage_adapter='chatterbot.storage.SQLStorageAdapter',
trainer='chatterbot.trainers.ListTrainer')

for files in os.listdir('C:/Users/HP/Downloads/Packages/chatterbot-corpus-master/chatterbot-corpus-master/chatterbot_corpus/data/english/') :

data = open(r'C:/Users/HP/Downloads/Packages/chatterbot-corpus-master/chatterbot-corpus-master/chatterbot_corpus/data/english/'+files,).readlines()

trainer = ListTrainer(bot)
trainer.train(data)
print("Training completed")

while True :

message = input('You: ')

if message.strip() != 'Bye':

replay = bot.get_responce(message)

print('ChatBot :',replay)

if message.strip()=='bye':

print('bye')

break

CMD 的输出

E:\Tempo\Victoria>python victoria_train.py


[nltk_data] Downloading package averaged_perceptron_tagger to


[nltk_data] C:\Users\HP\AppData\Roaming\nltk_data...


[nltk_data] Package averaged_perceptron_tagger is already up-to-


[nltk_data] date!


[nltk_data] Downloading package stopwords to


[nltk_data] C:\Users\HP\AppData\Roaming\nltk_data...


[nltk_data] Package stopwords is already up-to-date!


List Trainer: [####################] 100%
Training completed


List Trainer: [####################] 100%
Training completed


List Trainer: [####################] 100%
Training completed


List Trainer: [####################] 100%
Training completed


You: hi

Traceback (most recent call last): File "victoria_train.py", line 21, in replay = bot.get_responce(message) AttributeError: 'ChatBot' object has no attribute 'get_responce'

最佳答案

您正在使用一个不存在的函数(响应中的拼写错误)。而是使用: 获取响应Click here用于聊天机器人文档。

关于python - AttributeError: 'ChatBot' 对象没有属性 'get_responce',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57760992/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com