30 lines
1.2 KiB
Python
30 lines
1.2 KiB
Python
from django.db import models
|
|
from inventory.models import Dealer
|
|
|
|
|
|
class ChatLog(models.Model):
|
|
"""
|
|
Handles storage and representation of chat logs between users and chatbot.
|
|
|
|
This class is designed to store chat logs, which include user messages, chatbot
|
|
responses, their associated dealer, and timestamps of when the chat entries are
|
|
created. It supports linking chat logs to a specific dealer using a foreign key
|
|
relationship. The class provides an easy and structured way to manage and retrieve
|
|
historical chat data.
|
|
|
|
:ivar dealer: The dealer associated with this chat log.
|
|
:type dealer: Dealer
|
|
:ivar user_message: The message sent by the user.
|
|
:type user_message: str
|
|
:ivar chatbot_response: The response generated by the chatbot.
|
|
:type chatbot_response: str
|
|
:ivar timestamp: The date and time when the chat log entry was created.
|
|
:type timestamp: datetime
|
|
"""
|
|
dealer = models.ForeignKey(Dealer, on_delete=models.CASCADE, related_name='chatlogs')
|
|
user_message = models.TextField()
|
|
chatbot_response = models.TextField()
|
|
timestamp = models.DateTimeField(auto_now_add=True)
|
|
|
|
def __str__(self):
|
|
return self.user_message |