feat: add openai-compatible model gateway
This commit is contained in:
83
backend/apps/modelhub/schemas.py
Normal file
83
backend/apps/modelhub/schemas.py
Normal file
@@ -0,0 +1,83 @@
|
||||
from datetime import datetime
|
||||
from typing import Any
|
||||
from uuid import UUID
|
||||
|
||||
from ninja import Schema
|
||||
|
||||
|
||||
class ModelProviderIn(Schema):
|
||||
name: str
|
||||
base_url: str
|
||||
api_key: str
|
||||
enabled: bool = True
|
||||
default_timeout_seconds: int = 60
|
||||
|
||||
|
||||
class ModelProviderUpdateIn(Schema):
|
||||
name: str | None = None
|
||||
base_url: str | None = None
|
||||
api_key: str | None = None
|
||||
enabled: bool | None = None
|
||||
default_timeout_seconds: int | None = None
|
||||
|
||||
|
||||
class ModelProviderOut(Schema):
|
||||
id: int
|
||||
name: str
|
||||
base_url: str
|
||||
enabled: bool
|
||||
default_timeout_seconds: int
|
||||
credential_set: bool
|
||||
credential_masked: str
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
|
||||
|
||||
class ModelDeploymentIn(Schema):
|
||||
provider_id: int
|
||||
display_name: str
|
||||
model_name: str
|
||||
default_temperature: float = 0.2
|
||||
max_output_tokens: int = 2048
|
||||
enabled: bool = True
|
||||
|
||||
|
||||
class ModelDeploymentUpdateIn(Schema):
|
||||
display_name: str | None = None
|
||||
model_name: str | None = None
|
||||
default_temperature: float | None = None
|
||||
max_output_tokens: int | None = None
|
||||
enabled: bool | None = None
|
||||
|
||||
|
||||
class ModelDeploymentOut(Schema):
|
||||
id: int
|
||||
provider_id: int
|
||||
provider_name: str
|
||||
display_name: str
|
||||
model_name: str
|
||||
capability: str
|
||||
default_temperature: float
|
||||
max_output_tokens: int
|
||||
enabled: bool
|
||||
|
||||
|
||||
class ModelTestIn(Schema):
|
||||
prompt: str = "请回复:模型连接正常"
|
||||
|
||||
|
||||
class ModelInvocationOut(Schema):
|
||||
public_id: UUID
|
||||
deployment_id: int | None
|
||||
status: str
|
||||
model_snapshot: dict[str, Any]
|
||||
output_text: str
|
||||
input_tokens: int | None
|
||||
output_tokens: int | None
|
||||
duration_ms: int
|
||||
retry_count: int
|
||||
error_code: str
|
||||
error_message: str
|
||||
created_at: datetime
|
||||
started_at: datetime | None
|
||||
finished_at: datetime | None
|
||||
Reference in New Issue
Block a user