Spaces:
Sleeping
Sleeping
Download src/models/message.py from muhammadibtisam999/Phase3-hack2: direct link, hf CLI and curl.
- Browser
- Download file 838 Bytes
-
https://huggingface.co/spaces/muhammadibtisam999/Phase3-hack2/resolve/main/src/models/message.py
- Command line
-
hf download hf://spaces/muhammadibtisam999/Phase3-hack2/src/models/message.py
-
curl -L -o message.py https://huggingface.co/spaces/muhammadibtisam999/Phase3-hack2/resolve/main/src/models/message.py
838 Bytes
| # backend/src/models/message.py | |
| """Message model for AI chatbot feature.""" | |
| from sqlmodel import SQLModel, Field, Column | |
| from sqlalchemy import JSON | |
| from datetime import datetime | |
| from typing import Optional, List, Any | |
| class Message(SQLModel, table=True): | |
| """Represents a single message within a conversation.""" | |
| __tablename__ = "messages" | |
| id: Optional[int] = Field(default=None, primary_key=True) | |
| conversation_id: int = Field(foreign_key="conversations.id", index=True, nullable=False) | |
| user_id: str = Field(index=True, nullable=False) | |
| role: str = Field(max_length=20, nullable=False) # "user" or "assistant" | |
| content: str = Field(nullable=False) | |
| tool_calls: Optional[List[Any]] = Field(default=None, sa_column=Column(JSON)) | |
| created_at: datetime = Field(default_factory=datetime.utcnow, index=True) | |