Update models.py
Browse files
models.py
CHANGED
@@ -1,130 +0,0 @@
|
|
1 |
-
# models.py
|
2 |
-
# ------------------------------------------------------------------
|
3 |
-
# Central registry of all AI models AnyCoder can route to.
|
4 |
-
# ------------------------------------------------------------------
|
5 |
-
from __future__ import annotations
|
6 |
-
|
7 |
-
from dataclasses import dataclass
|
8 |
-
from typing import List, Optional
|
9 |
-
|
10 |
-
|
11 |
-
@dataclass(slots=True, frozen=True)
|
12 |
-
class ModelInfo:
|
13 |
-
"""
|
14 |
-
Metadata for a single model entry.
|
15 |
-
|
16 |
-
Attributes
|
17 |
-
----------
|
18 |
-
name : Human‑readable label shown in the UI.
|
19 |
-
id : Fully‑qualified model path, e.g. "openai/gpt‑4".
|
20 |
-
description : Short capability blurb.
|
21 |
-
default_provider: Which provider to send inference requests to if the
|
22 |
-
caller does **not** override it. Supported values:
|
23 |
-
"auto" | "groq" | "openai" | "gemini" | "fireworks".
|
24 |
-
The special value "auto" lets HF Inference decide.
|
25 |
-
"""
|
26 |
-
name: str
|
27 |
-
id: str
|
28 |
-
description: str
|
29 |
-
default_provider: str = "auto"
|
30 |
-
|
31 |
-
|
32 |
-
# ------------------------------------------------------------------
|
33 |
-
# Editable list of models exposed to both back‑end & front‑end
|
34 |
-
# ------------------------------------------------------------------
|
35 |
-
AVAILABLE_MODELS: List[ModelInfo] = [
|
36 |
-
# High‑capacity HF models
|
37 |
-
ModelInfo(
|
38 |
-
name="Qwen/Qwen3‑32B",
|
39 |
-
id="Qwen/Qwen3-32B",
|
40 |
-
description="Qwen3‑32B model for high‑capacity code and text generation",
|
41 |
-
),
|
42 |
-
ModelInfo(
|
43 |
-
name="Qwen3‑235B‑A22B",
|
44 |
-
id="Qwen/Qwen3-235B-A22B",
|
45 |
-
description="Qwen3‑235B‑A22B model for code generation and general tasks",
|
46 |
-
),
|
47 |
-
# Moonshot (Groq hardware by default)
|
48 |
-
ModelInfo(
|
49 |
-
name="Moonshot Kimi‑K2",
|
50 |
-
id="moonshotai/Kimi-K2-Instruct",
|
51 |
-
description="Moonshot AI Kimi‑K2‑Instruct (code, chat)",
|
52 |
-
default_provider="groq",
|
53 |
-
),
|
54 |
-
# DeepSeek
|
55 |
-
ModelInfo(
|
56 |
-
name="DeepSeek V3",
|
57 |
-
id="deepseek-ai/DeepSeek-V3-0324",
|
58 |
-
description="DeepSeek V3 model for code generation",
|
59 |
-
),
|
60 |
-
ModelInfo(
|
61 |
-
name="DeepSeek R1",
|
62 |
-
id="deepseek-ai/DeepSeek-R1-0528",
|
63 |
-
description="DeepSeek R1 model for code generation",
|
64 |
-
),
|
65 |
-
# Multimodal Chinese / English models
|
66 |
-
ModelInfo(
|
67 |
-
name="ERNIE‑4.5‑VL",
|
68 |
-
id="baidu/ERNIE-4.5-VL-424B-A47B-Base-PT",
|
69 |
-
description="ERNIE‑4.5‑VL multimodal model (image + text)",
|
70 |
-
),
|
71 |
-
ModelInfo(
|
72 |
-
name="GLM‑4.1V‑9B‑Thinking",
|
73 |
-
id="THUDM/GLM-4.1V-9B-Thinking",
|
74 |
-
description="GLM‑4.1V‑9B multimodal reasoning model",
|
75 |
-
),
|
76 |
-
# Lightweight general‑purpose models
|
77 |
-
ModelInfo(
|
78 |
-
name="SmolLM3‑3B",
|
79 |
-
id="HuggingFaceTB/SmolLM3-3B",
|
80 |
-
description="SmolLM3‑3B fast, low‑latency model",
|
81 |
-
),
|
82 |
-
ModelInfo(
|
83 |
-
name="MiniMax M1",
|
84 |
-
id="MiniMaxAI/MiniMax-M1-80k",
|
85 |
-
description="MiniMax M1 80k‑context general model",
|
86 |
-
),
|
87 |
-
# External providers via HF Inference Providers
|
88 |
-
ModelInfo(
|
89 |
-
name="OpenAI GPT‑4",
|
90 |
-
id="openai/gpt-4",
|
91 |
-
description="OpenAI GPT‑4 accessed through HF Inference Providers",
|
92 |
-
default_provider="openai",
|
93 |
-
),
|
94 |
-
ModelInfo(
|
95 |
-
name="Gemini Pro",
|
96 |
-
id="gemini/pro",
|
97 |
-
description="Google Gemini Pro via HF Inference Providers",
|
98 |
-
default_provider="gemini",
|
99 |
-
),
|
100 |
-
ModelInfo(
|
101 |
-
name="Fireworks V1",
|
102 |
-
id="fireworks-ai/fireworks-v1",
|
103 |
-
description="Fireworks AI flagship model",
|
104 |
-
default_provider="fireworks",
|
105 |
-
),
|
106 |
-
]
|
107 |
-
|
108 |
-
|
109 |
-
# ------------------------------------------------------------------
|
110 |
-
# Helper look‑ups
|
111 |
-
# ------------------------------------------------------------------
|
112 |
-
def find_model(identifier: str) -> Optional[ModelInfo]:
|
113 |
-
"""
|
114 |
-
Retrieve a `ModelInfo` either by `.id` or by case‑insensitive `.name`.
|
115 |
-
|
116 |
-
Parameters
|
117 |
-
----------
|
118 |
-
identifier : str
|
119 |
-
- `"openai/gpt-4"` – exact id
|
120 |
-
- `"OpenAI GPT-4"` – human label
|
121 |
-
|
122 |
-
Returns
|
123 |
-
-------
|
124 |
-
Optional[ModelInfo]
|
125 |
-
"""
|
126 |
-
key = identifier.lower()
|
127 |
-
for m in AVAILABLE_MODELS:
|
128 |
-
if m.id == identifier or m.name.lower() == key:
|
129 |
-
return m
|
130 |
-
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|