add chat
This commit is contained in:
37
prompt/schemas.py
Normal file
37
prompt/schemas.py
Normal file
@@ -0,0 +1,37 @@
|
||||
from typing import Optional
|
||||
from uuid import UUID
|
||||
from ninja import Schema
|
||||
|
||||
|
||||
class MessageOut(Schema):
|
||||
id: int
|
||||
role: str
|
||||
content: str
|
||||
code_html: Optional[str] = None
|
||||
code_css: Optional[str] = None
|
||||
code_js: Optional[str] = None
|
||||
created: str
|
||||
|
||||
|
||||
class ConversationOut(Schema):
|
||||
id: UUID
|
||||
user_id: int
|
||||
username: str
|
||||
task_id: int
|
||||
task_title: str
|
||||
is_active: bool
|
||||
message_count: int
|
||||
created: str
|
||||
|
||||
@staticmethod
|
||||
def from_conv(conv):
|
||||
return {
|
||||
"id": conv.id,
|
||||
"user_id": conv.user_id,
|
||||
"username": conv.user.username,
|
||||
"task_id": conv.task_id,
|
||||
"task_title": conv.task.title,
|
||||
"is_active": conv.is_active,
|
||||
"message_count": conv.messages.count(),
|
||||
"created": conv.created.isoformat(),
|
||||
}
|
||||
Reference in New Issue
Block a user