python - Django Admin 中的空 Chatterbot 对话表

标签 python django chatterbot

在 Django 管理中,使用执行训练后,chatterbot 转换表为空

python管理.py训练

上面的代码使用基于 yml 文件的训练数据填充语句和响应表。这很好。

但是,在测试过程中,发布到聊天机器人的语句和响应应该进入空对话表,而不应该添加到经过训练的语句和响应数据表中。

最佳答案

当您启动对话界面时,机器人将开始将您的所有对话记录到数据库中。

如果你查看source code对于chatterbot,如果数据库中存在对话,则该对话将追加到现有对话中,否则它将创建一个新的标识符

    conversation.id = request.session.get('conversation_id', 0)
    existing_conversation = False
    try:
        Conversation.objects.get(id=conversation.id)
        existing_conversation = True

    except Conversation.DoesNotExist:
        conversation_id = self.chatterbot.storage.create_conversation()
        request.session['conversation_id'] = conversation_id
        conversation.id = conversation_id

    if existing_conversation:
        responses = Response.objects.filter(
            conversations__id=conversation.id
        )

        for response in responses:
            conversation.statements.append(response.statement.serialize())
            conversation.statements.append(response.response.serialize())

    return conversation

对话的 Django 聊天机器人 ADMIN 页面示例

enter image description here

如果您需要任何进一步的帮助,请告诉我。

关于python - Django Admin 中的空 Chatterbot 对话表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45911071/

相关文章:

python - Flask Python 中的 Http 和 Http

python - 高效查询字段范围内缺失的整数?

javascript - 如何在django中使用js切换 "like button"

python - 属性错误: “' ChatBot' object has no attribute 'trains' ”

python - 如何将 CHATBOT 未回答的问题存储在文本文件中

python - 比较字典中列表中的任意数量的日期

python - Django 休息框架 : set database dynamically from URL parameter

python - django-evolution 错误

python - 在 django 项目中组织模板

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