wiki/implementation/Chatbot/legacy/schemas.py

36 lines
1 KiB
Python

"""Schemas for chat package."""
from pydantic import BaseModel, Field
class PostChatMessageRequest(BaseModel):
"""Request schema for posting a chat message."""
thread: str = Field(
..., example="8237529", description="Unique identifier for the chat thread"
)
message: str = Field(
..., example="Hello, world!", description="The message content"
)
class ChatMessageItem(BaseModel):
"""Represents a single chat message item for an API response."""
role: str = Field(
..., examples=["human", "assistant"], description="Role of the message sender"
)
content: str = Field(
..., example="Hello, world!", description="The message content"
)
class PostChatMessageResponse(BaseModel):
"""Response schema when posting a chat message."""
thread: str = Field(
..., example="8237529", description="Unique identifier for the chat thread"
)
chat_history: list[ChatMessageItem] = Field(
..., description="List of messages in the chat thread"
)