Spaces:
Runtime error
Runtime error
Download app/api/models/chat.py from sibikrish/invoice-system: direct link, hf CLI and curl.
- Browser
- Download file 952 Bytes
-
https://huggingface.co/spaces/sibikrish/invoice-system/resolve/main/app/api/models/chat.py
- Command line
-
hf download hf://spaces/sibikrish/invoice-system/app/api/models/chat.py
-
curl -L -o chat.py https://huggingface.co/spaces/sibikrish/invoice-system/resolve/main/app/api/models/chat.py
952 Bytes
| from pydantic import BaseModel, Field | |
| from typing import List, Optional | |
| from datetime import datetime | |
| class ChatMessage(BaseModel): | |
| role: str = Field(..., description="Role of the message sender (user/assistant)") | |
| content: str = Field(..., description="Content of the message") | |
| timestamp: datetime = Field(default_factory=datetime.utcnow) | |
| class ChatRequest(BaseModel): | |
| query: str = Field(..., description="User's query about invoice reimbursements") | |
| chat_history: Optional[List[ChatMessage]] = Field(default=None, description="Previous chat messages for context") | |
| class ChatResponse(BaseModel): | |
| response: str = Field(..., description="Assistant's response in markdown format") | |
| relevant_invoices: Optional[List[str]] = Field(default=None, description="List of relevant invoice IDs referenced in the response") | |
| chat_history: List[ChatMessage] = Field(..., description="Updated chat history including the new exchange") |