presenton/servers/fastapi/models/sql/chat_history_message.py
sudipnext 4c271170b5 feat: Add chat history management and asset generation features
- Introduced a new `ChatHistoryMessageModel` to persist chat messages in the database.
- Implemented a migration script to create the `chat_history_messages` table.
- Enhanced chat services to support storing and retrieving chat history.
- Added functionality for generating multiple media assets in a single API call.
- Updated the chat UI to display assistant activities and tool usage more effectively.
- Refactored API calls to use absolute URLs for better reliability.
2026-04-26 13:12:50 +05:45

31 lines
1,019 B
Python

from datetime import datetime
from typing import Optional
import uuid
from sqlalchemy import JSON, Column, DateTime, ForeignKey, Text
from sqlmodel import Field, SQLModel
from utils.datetime_utils import get_current_utc_datetime
class ChatHistoryMessageModel(SQLModel, table=True):
__tablename__ = "chat_history_messages"
id: uuid.UUID = Field(default_factory=uuid.uuid4, primary_key=True)
presentation_id: uuid.UUID = Field(
sa_column=Column(
ForeignKey("presentations.id", ondelete="CASCADE"),
index=True,
nullable=False,
)
)
conversation_id: uuid.UUID = Field(index=True)
position: int = Field(index=True, ge=1)
role: str
content: str = Field(sa_column=Column(Text, nullable=False))
created_at: datetime = Field(
sa_column=Column(
DateTime(timezone=True), nullable=False, default=get_current_utc_datetime
)
)
tool_calls: Optional[list[str]] = Field(sa_column=Column(JSON), default=None)