Empty Chatterbot Conversation table in Django Admin

603 Views Asked by At

In Django admin, the chatterbot conversion table is empty after training has been performed using

python manage.py train

The above code populates the statement and response tables with the training data based on the yml file. This is fine.

However, during testing, the statements posted to the chatbot and the response ought to go to the empty conversation table and should not be added to the trained statement and response data table.

1

There are 1 best solutions below

6
On

When you start the conversation interface then bot will start recording all your conversations into DB.

If you look into source code of chatterbot, if conversations are exists in DB then the conversation will append into existing conversation, else it will create a new identifier

    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

A sample Django chatterbot ADMIN page of conversations

enter image description here

Let me know if you need any further help on this.