feat: add Lingma OpenAI-compatible gateway service
This commit is contained in:
45
app/openai_schema.py
Normal file
45
app/openai_schema.py
Normal file
@@ -0,0 +1,45 @@
|
||||
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]
|
||||
Reference in New Issue
Block a user