Files
2026-07-26 18:50:51 +08:00

105 lines
2.8 KiB
Python

from __future__ import annotations
from dataclasses import dataclass
from typing import Literal
Provider = Literal["k1412", "deepseek"]
@dataclass(frozen=True, slots=True)
class ModelSpec:
public_id: str
display_name: str
provider: Provider
provider_model: str
thinking_enabled: bool
thinking_label: str
thinking_adjustable: bool
reasoning_effort: str | None
max_output_tokens: int
max_iterations: int
context_char_budget: int
MODEL_SPECS: dict[str, ModelSpec] = {
"luna": ModelSpec(
public_id="luna",
display_name="Luna",
provider="k1412",
provider_model="ChatGPT-5.6:Luna",
thinking_enabled=True,
thinking_label="开启(不分档)",
thinking_adjustable=False,
reasoning_effort=None,
max_output_tokens=4_096,
max_iterations=8,
context_char_budget=120_000,
),
"terra": ModelSpec(
public_id="terra",
display_name="Terra",
provider="k1412",
provider_model="ChatGPT-5.6:Terra",
thinking_enabled=True,
thinking_label="开启(不分档)",
thinking_adjustable=False,
reasoning_effort=None,
max_output_tokens=4_096,
max_iterations=16,
context_char_budget=240_000,
),
"sol": ModelSpec(
public_id="sol",
display_name="Sol",
provider="k1412",
provider_model="ChatGPT-5.6:Sol",
thinking_enabled=True,
thinking_label="开启(不分档)",
thinking_adjustable=False,
reasoning_effort=None,
max_output_tokens=4_096,
max_iterations=24,
context_char_budget=400_000,
),
"deepseek-v4-pro": ModelSpec(
public_id="deepseek-v4-pro",
display_name="DeepSeek V4 Pro",
provider="deepseek",
provider_model="deepseek-v4-pro",
thinking_enabled=True,
thinking_label="极高",
thinking_adjustable=False,
reasoning_effort="max",
max_output_tokens=16_384,
max_iterations=32,
context_char_budget=800_000,
),
}
def get_model_spec(model_id: str) -> ModelSpec:
try:
return MODEL_SPECS[model_id]
except KeyError as exc:
raise ValueError(f"Unsupported model: {model_id}") from exc
def openai_model_list() -> dict:
return {
"object": "list",
"data": [
{
"id": spec.public_id,
"object": "model",
"owned_by": "k1412-agent",
"name": spec.display_name,
"k1412": {
"thinking_enabled": spec.thinking_enabled,
"thinking_label": spec.thinking_label,
"thinking_adjustable": spec.thinking_adjustable,
},
}
for spec in MODEL_SPECS.values()
],
}