lvkaokao
update codes.
5a7ab71
raw
history blame
855 Bytes
from typing import Optional, List, Dict, Any
import time
import shortuuid
from pydantic import BaseModel, Field
class ChatCompletionRequest(BaseModel):
# TODO: support streaming, stop with a list of text etc.
model: str
messages: List[Dict[str, str]]
temperature: Optional[float] = 0.7
n: int = 1
max_tokens: Optional[int] = None
stop: Optional[str] = None
class ChatMessage(BaseModel):
role: str
content: str
class ChatCompletionResponseChoice(BaseModel):
index: int
message: ChatMessage
finish_reason: str
class ChatCompletionResponse(BaseModel):
id: str = Field(default_factory=shortuuid.random)
object: str = "chat.completion"
created: int = Field(default_factory=lambda: int(time.time()))
choices: List[ChatCompletionResponseChoice]
usage: Optional[Dict[str, int]] = None