mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-16 01:55:15 +03:00
da8e7513e6
# Description Please include a summary of the changes and the related issue. Please also include relevant motivation and context. ## Checklist before requesting a review Please delete options that are not relevant. - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my code - [ ] I have commented hard-to-understand areas - [ ] I have ideally added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged ## Screenshots (if appropriate): --------- Co-authored-by: Stan Girard <girard.stanislas@gmail.com>
46 lines
1.3 KiB
Python
46 lines
1.3 KiB
Python
from dataclasses import asdict, dataclass
|
|
from typing import Optional
|
|
from uuid import UUID
|
|
|
|
|
|
@dataclass
|
|
class Chat:
|
|
chat_id: str
|
|
user_id: str
|
|
creation_time: str
|
|
chat_name: str
|
|
|
|
def __init__(self, chat_dict: dict):
|
|
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", "")
|
|
|
|
|
|
@dataclass
|
|
class ChatHistory:
|
|
chat_id: str
|
|
message_id: str
|
|
user_message: str
|
|
assistant: str
|
|
message_time: str
|
|
prompt_id: Optional[UUID]
|
|
brain_id: Optional[UUID]
|
|
metadata: Optional[dict] = None
|
|
thumbs: Optional[bool] = None
|
|
|
|
def __init__(self, chat_dict: dict):
|
|
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")
|
|
self.metadata = chat_dict.get("metadata")
|
|
self.thumbs = chat_dict.get("thumbs")
|
|
|
|
def to_dict(self):
|
|
return asdict(self)
|