2023-06-30 11:10:59 +03:00
|
|
|
from dataclasses import asdict, dataclass
|
2023-08-10 11:25:08 +03:00
|
|
|
from typing import Optional
|
|
|
|
from uuid import UUID
|
2023-06-22 18:50:06 +03:00
|
|
|
|
|
|
|
|
|
|
|
@dataclass
|
|
|
|
class Chat:
|
|
|
|
chat_id: str
|
|
|
|
user_id: str
|
|
|
|
creation_time: str
|
|
|
|
chat_name: str
|
|
|
|
|
|
|
|
def __init__(self, chat_dict: dict):
|
2023-08-10 11:25:08 +03:00
|
|
|
self.chat_id = chat_dict.get("chat_id", "")
|
|
|
|
self.user_id = chat_dict.get("user_id", "")
|
|
|
|
self.creation_time = chat_dict.get("creation_time", "")
|
|
|
|
self.chat_name = chat_dict.get("chat_name", "")
|
2023-06-22 18:50:06 +03:00
|
|
|
|
|
|
|
|
|
|
|
@dataclass
|
|
|
|
class ChatHistory:
|
|
|
|
chat_id: str
|
|
|
|
message_id: str
|
|
|
|
user_message: str
|
|
|
|
assistant: str
|
|
|
|
message_time: str
|
2023-08-10 11:25:08 +03:00
|
|
|
prompt_id: Optional[UUID]
|
|
|
|
brain_id: Optional[UUID]
|
2024-01-20 07:34:30 +03:00
|
|
|
metadata: Optional[dict] = None
|
2024-03-21 10:11:06 +03:00
|
|
|
thumbs: Optional[bool] = None
|
2023-06-22 18:50:06 +03:00
|
|
|
|
|
|
|
def __init__(self, chat_dict: dict):
|
2023-08-10 11:25:08 +03:00
|
|
|
self.chat_id = chat_dict.get("chat_id", "")
|
|
|
|
self.message_id = chat_dict.get("message_id", "")
|
|
|
|
self.user_message = chat_dict.get("user_message", "")
|
|
|
|
self.assistant = chat_dict.get("assistant", "")
|
|
|
|
self.message_time = chat_dict.get("message_time", "")
|
|
|
|
|
|
|
|
self.prompt_id = chat_dict.get("prompt_id")
|
|
|
|
self.brain_id = chat_dict.get("brain_id")
|
2024-01-20 07:34:30 +03:00
|
|
|
self.metadata = chat_dict.get("metadata")
|
2024-03-21 10:11:06 +03:00
|
|
|
self.thumbs = chat_dict.get("thumbs")
|
2023-06-30 11:10:59 +03:00
|
|
|
|
|
|
|
def to_dict(self):
|
|
|
|
return asdict(self)
|