from typing import List, Optional from pydantic import BaseModel class ChatMessage(BaseModel): role: str content: str class ChatCompletionRequest(BaseModel): model: str = "yxchia/llama3-8b-cpt-sea-lionv2-instruct:Q4_K_M" messages: List[ChatMessage] max_tokens: Optional[int] = 512 temperature: Optional[float] = 0.2 stream: Optional[bool] = False response_format: Optional[dict] = None def model_dump(self, *args, **kwargs): # This overrides the dict method to rename response_format to format when serializing data = super().model_dump(*args, **kwargs) if "response_format" in data: data["format"] = data.pop("response_format") return data