Spaces:
No application file
No application file
| """ | |
| Chat API schemas for transportation application | |
| """ | |
| from pydantic import BaseModel, Field | |
| from typing import List, Dict, Any, Optional | |
| class ChatRequest(BaseModel): | |
| """Schema cho chat request""" | |
| message: str = Field(..., description="Tin nhắn từ người dùng", example="Dự đoán phương thức vận chuyển cho project ABC") | |
| class FunctionCall(BaseModel): | |
| """Schema cho function call""" | |
| function_name: str = Field(..., description="Tên function được gọi") | |
| arguments: Dict[str, Any] = Field(..., description="Tham số của function") | |
| result: Dict[str, Any] = Field(..., description="Kết quả của function") | |
| class ChatResponse(BaseModel): | |
| """Schema cho chat response""" | |
| response: str = Field(..., description="Phản hồi từ AI") | |
| function_calls: List[FunctionCall] = Field(default_factory=list, description="Các function calls đã thực hiện") | |
| status: str = Field(default="success", description="Trạng thái response") | |
| error_message: Optional[str] = Field(None, description="Thông báo lỗi nếu có") | |
| class StreamChunk(BaseModel): | |
| """Schema cho streaming chunk với định dạng gọn""" | |
| event: str = Field(..., description="Loại event: status, delta, final") | |
| stage: Optional[str] = Field(None, description="Stage cho status event: starting, processing, completed") | |
| message: Optional[str] = Field(None, description="Message cho status event") | |
| content: Optional[str] = Field(None, description="Nội dung cho delta và final event") |