Files
lingma-openai-gateway/app/openai_schema.py
root 5526779e98
Some checks failed
CI / lint-and-compile (push) Has been cancelled
chore: initialize clean history without secrets
2026-04-17 09:56:08 +08:00

46 lines
933 B
Python

from __future__ import annotations
from typing import Literal
from pydantic import BaseModel, Field
class ChatMessage(BaseModel):
role: Literal["system", "user", "assistant", "tool"]
content: str
class ChatCompletionsRequest(BaseModel):
model: str
messages: list[ChatMessage]
stream: bool = False
temperature: float | None = None
top_p: float | None = None
class ModelData(BaseModel):
id: str
name: str | None = None
object: str = "model"
created: int = 0
owned_by: str = "lingma"
class ModelsResponse(BaseModel):
object: str = "list"
data: list[ModelData]
class ChatCompletionChoice(BaseModel):
index: int = 0
finish_reason: str | None = "stop"
message: dict = Field(default_factory=dict)
class ChatCompletionResponse(BaseModel):
id: str
object: str = "chat.completion"
created: int
model: str
choices: list[ChatCompletionChoice]