File size: 4,215 Bytes
dcf9dad
737a383
 
 
 
 
dcf9dad
 
 
737a383
 
dcf9dad
 
737a383
dcf9dad
737a383
 
 
 
 
 
 
 
 
dcf9dad
 
 
 
 
 
b412ca5
737a383
 
 
dcf9dad
737a383
 
 
 
 
 
dcf9dad
737a383
 
 
 
 
 
 
d4adf5c
737a383
 
dcf9dad
737a383
dcf9dad
737a383
d4adf5c
737a383
dcf9dad
 
737a383
d4adf5c
737a383
dcf9dad
737a383
dcf9dad
737a383
d4adf5c
737a383
dcf9dad
 
737a383
 
 
dcf9dad
737a383
dcf9dad
737a383
d4adf5c
737a383
dcf9dad
 
737a383
 
 
dcf9dad
737a383
dcf9dad
737a383
d4adf5c
737a383
 
dcf9dad
 
737a383
dcf9dad
737a383
 
dcf9dad
 
737a383
d4adf5c
737a383
 
d4adf5c
dcf9dad
 
d4adf5c
737a383
 
 
dcf9dad
 
737a383
 
 
 
 
 
 
dcf9dad
737a383
 
 
dcf9dad
d4adf5c
b412ca5
d4adf5c
b412ca5
737a383
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# models.py
# ------------------------------------------------------------------
# Central registry of all AI models AnyCoder can route to.
# ------------------------------------------------------------------
from __future__ import annotations

from dataclasses import dataclass
from typing import List, Optional


@dataclass(slots=True, frozen=True)
class ModelInfo:
    """
    Metadata for a single model entry.

    Attributes
    ----------
    name            : Human‑readable label shown in the UI.
    id              : Fully‑qualified model path, e.g. "openai/gpt‑4".
    description     : Short capability blurb.
    default_provider: Which provider to send inference requests to if the
                      caller does **not** override it.  Supported values:
                      "auto" | "groq" | "openai" | "gemini" | "fireworks".
                      The special value "auto" lets HF Inference decide.
    """
    name: str
    id: str
    description: str
    default_provider: str = "auto"


# ------------------------------------------------------------------
# Editable list of models exposed to both back‑end & front‑end
# ------------------------------------------------------------------
AVAILABLE_MODELS: List[ModelInfo] = [
    # High‑capacity HF models
    ModelInfo(
        name="Qwen/Qwen3‑32B",
        id="Qwen/Qwen3-32B",
        description="Qwen3‑32B model for high‑capacity code and text generation",
    ),
    ModelInfo(
        name="Qwen3‑235B‑A22B",
        id="Qwen/Qwen3-235B-A22B",
        description="Qwen3‑235B‑A22B model for code generation and general tasks",
    ),
    # Moonshot (Groq hardware by default)
    ModelInfo(
        name="Moonshot Kimi‑K2",
        id="moonshotai/Kimi-K2-Instruct",
        description="Moonshot AI Kimi‑K2‑Instruct (code, chat)",
        default_provider="groq",
    ),
    # DeepSeek
    ModelInfo(
        name="DeepSeek V3",
        id="deepseek-ai/DeepSeek-V3-0324",
        description="DeepSeek V3 model for code generation",
    ),
    ModelInfo(
        name="DeepSeek R1",
        id="deepseek-ai/DeepSeek-R1-0528",
        description="DeepSeek R1 model for code generation",
    ),
    # Multimodal Chinese / English models
    ModelInfo(
        name="ERNIE‑4.5‑VL",
        id="baidu/ERNIE-4.5-VL-424B-A47B-Base-PT",
        description="ERNIE‑4.5‑VL multimodal model (image + text)",
    ),
    ModelInfo(
        name="GLM‑4.1V‑9B‑Thinking",
        id="THUDM/GLM-4.1V-9B-Thinking",
        description="GLM‑4.1V‑9B multimodal reasoning model",
    ),
    # Lightweight general‑purpose models
    ModelInfo(
        name="SmolLM3‑3B",
        id="HuggingFaceTB/SmolLM3-3B",
        description="SmolLM3‑3B fast, low‑latency model",
    ),
    ModelInfo(
        name="MiniMax M1",
        id="MiniMaxAI/MiniMax-M1-80k",
        description="MiniMax M1 80k‑context general model",
    ),
    # External providers via HF Inference Providers
    ModelInfo(
        name="OpenAI GPT‑4",
        id="openai/gpt-4",
        description="OpenAI GPT‑4 accessed through HF Inference Providers",
        default_provider="openai",
    ),
    ModelInfo(
        name="Gemini Pro",
        id="gemini/pro",
        description="Google Gemini Pro via HF Inference Providers",
        default_provider="gemini",
    ),
    ModelInfo(
        name="Fireworks V1",
        id="fireworks-ai/fireworks-v1",
        description="Fireworks AI flagship model",
        default_provider="fireworks",
    ),
]


# ------------------------------------------------------------------
# Helper look‑ups
# ------------------------------------------------------------------
def find_model(identifier: str) -> Optional[ModelInfo]:
    """
    Retrieve a `ModelInfo` either by `.id` or by case‑insensitive `.name`.

    Parameters
    ----------
    identifier : str
        - `"openai/gpt-4"` – exact id
        - `"OpenAI GPT-4"`  – human label

    Returns
    -------
    Optional[ModelInfo]
    """
    key = identifier.lower()
    for m in AVAILABLE_MODELS:
        if m.id == identifier or m.name.lower() == key:
            return m
    return None