mirror of
https://github.com/furyhawk/ai_agent.git
synced 2026-07-21 10:15:44 +00:00
- Implemented `conversation-store` for managing conversations and messages. - Created `file-preview-store` to handle file preview state. - Added `sidebar-store` for sidebar visibility management. - Developed `theme-store` for theme persistence and management. - Introduced `kb-selection-store` for managing active knowledge base selections with persistence. chore: define API and chat types - Added types for API responses, authentication, chat messages, conversations, and projects. - Defined interfaces for various entities including users, sessions, and message ratings. build: configure TypeScript and testing setup - Set up `tsconfig.json` for TypeScript configuration. - Created `vitest.config.ts` for testing configuration with Vitest. - Added `vitest.setup.ts` for global test setup including mocks for Next.js router and media queries. - Configured Vercel deployment settings in `vercel.json`.
38 lines
1.4 KiB
Python
38 lines
1.4 KiB
Python
"""ChatFile database model - stores metadata for files uploaded in chat."""
|
|
|
|
import uuid
|
|
|
|
from sqlalchemy import ForeignKey, Integer, String, Text
|
|
from sqlalchemy.dialects.postgresql import UUID as PG_UUID
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from app.db.base import Base, TimestampMixin
|
|
|
|
|
|
class ChatFile(Base, TimestampMixin):
|
|
"""Tracks files uploaded by users in chat conversations."""
|
|
|
|
__tablename__ = "chat_files"
|
|
|
|
id: Mapped[uuid.UUID] = mapped_column(
|
|
PG_UUID(as_uuid=True), primary_key=True, default=uuid.uuid4
|
|
)
|
|
user_id: Mapped[uuid.UUID] = mapped_column(
|
|
PG_UUID(as_uuid=True),
|
|
ForeignKey("users.id", ondelete="CASCADE"),
|
|
nullable=False,
|
|
index=True,
|
|
)
|
|
message_id: Mapped[uuid.UUID | None] = mapped_column(
|
|
PG_UUID(as_uuid=True), ForeignKey("messages.id", ondelete="CASCADE"), nullable=True
|
|
)
|
|
filename: Mapped[str] = mapped_column(String(255), nullable=False)
|
|
mime_type: Mapped[str] = mapped_column(String(100), nullable=False)
|
|
size: Mapped[int] = mapped_column(Integer, nullable=False)
|
|
storage_path: Mapped[str] = mapped_column(String(500), nullable=False)
|
|
file_type: Mapped[str] = mapped_column(String(20), nullable=False)
|
|
parsed_content: Mapped[str | None] = mapped_column(Text, nullable=True)
|
|
|
|
def __repr__(self) -> str:
|
|
return f"<ChatFile(id={self.id}, filename={self.filename}, type={self.file_type})>"
|