2017-08-28 115 views
1

在Django管理,训练一直使用空聊天机器人会话表

python manage.py train

上述代码填充具有基于训练数据的发言,并响应表中执行之后的聊天机器人转换表是空的yml文件。这可以。

但是,在测试过程中,发布到chatbot和响应的语句应该转到空的会话表中,不应该添加到训练语句和响应数据表中。

回答

1

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

如果你看看聊天机器人的source code,如果对话是存在于数据库,则通话将追加到现有对话,否则它会创建一个新的标识

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的聊天机器人管理页面

enter image description here

让我知道你是否需要任何进一步的帮助。

+0

太棒了!感谢您的澄清。唯一需要的其他帮助是w.r.t.到我的另一个[post](https://stackoverflow.com/questions/45910997/bestmatchadapter-confuse-two-different-questions-with-same-response)。请让我知道你的意见。再次感谢。 –

+1

当然我会尽快做 –

+0

谢谢。不过,我觉得有重复正在进行,我希望未来的聊天机器人发布会纠正这一问题。会话表应该只包含发布的用户声明和响应。声明和响应表应该只有使用“python manage train”填充的培训数据,而不包含用户输入的其他内容。 –