This commit is contained in:
2026-03-04 20:05:33 +08:00
parent fdbe06a077
commit 6998d694bb
25 changed files with 572 additions and 37 deletions

37
prompt/schemas.py Normal file
View 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(),
}