2025-03-14 18:53:14 -07:00
|
|
|
from typing import Any, Dict, List, Optional
|
2025-05-05 23:18:12 -07:00
|
|
|
|
|
|
|
|
from app.db import ChatType
|
2025-05-07 22:04:57 -07:00
|
|
|
from pydantic import BaseModel, ConfigDict
|
2025-05-05 23:18:12 -07:00
|
|
|
|
2025-03-14 18:53:14 -07:00
|
|
|
from .base import IDModel, TimestampModel
|
2025-05-05 23:18:12 -07:00
|
|
|
|
2025-03-14 18:53:14 -07:00
|
|
|
|
|
|
|
|
class ChatBase(BaseModel):
|
|
|
|
|
type: ChatType
|
|
|
|
|
title: str
|
|
|
|
|
initial_connectors: Optional[List[str]] = None
|
|
|
|
|
messages: List[Any]
|
|
|
|
|
search_space_id: int
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ClientAttachment(BaseModel):
|
|
|
|
|
name: str
|
|
|
|
|
contentType: str
|
|
|
|
|
url: str
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ToolInvocation(BaseModel):
|
|
|
|
|
toolCallId: str
|
|
|
|
|
toolName: str
|
|
|
|
|
args: dict
|
|
|
|
|
result: dict
|
|
|
|
|
|
|
|
|
|
|
2025-05-10 20:06:19 -07:00
|
|
|
# class ClientMessage(BaseModel):
|
|
|
|
|
# role: str
|
|
|
|
|
# content: str
|
|
|
|
|
# experimental_attachments: Optional[List[ClientAttachment]] = None
|
|
|
|
|
# toolInvocations: Optional[List[ToolInvocation]] = None
|
2025-03-14 18:53:14 -07:00
|
|
|
|
|
|
|
|
class AISDKChatRequest(BaseModel):
|
2025-05-10 20:06:19 -07:00
|
|
|
messages: List[Any]
|
2025-03-14 18:53:14 -07:00
|
|
|
data: Optional[Dict[str, Any]] = None
|
|
|
|
|
|
|
|
|
|
class ChatCreate(ChatBase):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
class ChatUpdate(ChatBase):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
class ChatRead(ChatBase, IDModel, TimestampModel):
|
2025-05-07 22:04:57 -07:00
|
|
|
model_config = ConfigDict(from_attributes=True)
|