Spaces:
Running
Running
remove non HF models
Browse files- backend_api.py +18 -72
- backend_models.py +4 -246
- frontend/src/components/LandingPage.tsx +4 -4
backend_api.py
CHANGED
|
@@ -24,7 +24,6 @@ import httpx
|
|
| 24 |
from backend_models import (
|
| 25 |
get_inference_client,
|
| 26 |
get_real_model_id,
|
| 27 |
-
create_gemini3_messages,
|
| 28 |
is_native_sdk_model,
|
| 29 |
is_mistral_model
|
| 30 |
)
|
|
@@ -100,22 +99,11 @@ def get_cached_client(model_id: str, provider: str = "auto"):
|
|
| 100 |
# Define models and languages here to avoid importing Gradio UI
|
| 101 |
AVAILABLE_MODELS = [
|
| 102 |
{"name": "GLM-4.6", "id": "zai-org/GLM-4.6", "description": "GLM-4.6 model via HuggingFace with Cerebras provider (Default)", "supports_images": False},
|
| 103 |
-
{"name": "Devstral Medium 2512", "id": "devstral-medium-2512", "description": "Mistral Devstral 2512 - Expert code generation model via OpenRouter", "supports_images": False},
|
| 104 |
{"name": "GLM-4.6V 👁️", "id": "zai-org/GLM-4.6V:zai-org", "description": "GLM-4.6V vision model - supports image uploads for visual understanding", "supports_images": True},
|
| 105 |
-
{"name": "DeepSeek V3
|
| 106 |
-
{"name": "DeepSeek R1", "id": "deepseek-ai/DeepSeek-R1
|
| 107 |
-
{"name": "Gemini 3.0 Flash Preview", "id": "gemini-3-flash-preview", "description": "Google Gemini 3.0 Flash Preview with Thinking Mode (High)", "supports_images": False},
|
| 108 |
-
{"name": "Gemini 3.0 Pro", "id": "gemini-3.0-pro", "description": "Google Gemini 3.0 Pro via Poe with advanced reasoning", "supports_images": False},
|
| 109 |
-
{"name": "Grok 4.1 Fast", "id": "x-ai/grok-4.1-fast", "description": "Grok 4.1 Fast model via OpenRouter (20 req/min on free tier)", "supports_images": False},
|
| 110 |
{"name": "MiniMax M2", "id": "MiniMaxAI/MiniMax-M2", "description": "MiniMax M2 model via HuggingFace InferenceClient with Novita provider", "supports_images": False},
|
| 111 |
-
{"name": "GPT-5.1", "id": "gpt-5.1", "description": "OpenAI GPT-5.1 model via Poe for advanced code generation and general tasks", "supports_images": False},
|
| 112 |
-
{"name": "GPT-5.1 Instant", "id": "gpt-5.1-instant", "description": "OpenAI GPT-5.1 Instant model via Poe for fast responses", "supports_images": False},
|
| 113 |
-
{"name": "GPT-5.1 Codex", "id": "gpt-5.1-codex", "description": "OpenAI GPT-5.1 Codex model via Poe optimized for code generation", "supports_images": False},
|
| 114 |
-
{"name": "Claude-Opus-4.5", "id": "claude-opus-4.5", "description": "Anthropic Claude Opus 4.5 via Poe (OpenAI-compatible)", "supports_images": False},
|
| 115 |
-
{"name": "Claude-Sonnet-4.5", "id": "claude-sonnet-4.5", "description": "Anthropic Claude Sonnet 4.5 via Poe (OpenAI-compatible)", "supports_images": False},
|
| 116 |
-
{"name": "Claude-Haiku-4.5", "id": "claude-haiku-4.5", "description": "Anthropic Claude Haiku 4.5 via Poe (OpenAI-compatible)", "supports_images": False},
|
| 117 |
{"name": "Kimi K2 Thinking", "id": "moonshotai/Kimi-K2-Thinking", "description": "Moonshot Kimi K2 Thinking model via HuggingFace with Together AI provider", "supports_images": False},
|
| 118 |
-
{"name": "GLM-4.6", "id": "zai-org/GLM-4.6", "description": "GLM-4.6 model via HuggingFace with Cerebras provider", "supports_images": False},
|
| 119 |
]
|
| 120 |
|
| 121 |
# Cache model lookup for faster access (built after AVAILABLE_MODELS is defined)
|
|
@@ -843,71 +831,29 @@ async def generate_code(
|
|
| 843 |
|
| 844 |
# Stream the response
|
| 845 |
try:
|
| 846 |
-
#
|
| 847 |
-
|
| 848 |
-
|
| 849 |
-
|
| 850 |
-
|
| 851 |
-
|
| 852 |
-
|
| 853 |
-
|
| 854 |
-
max_tokens=10000
|
| 855 |
-
)
|
| 856 |
-
|
| 857 |
-
# Handle Native SDK models (Gemini 3)
|
| 858 |
-
elif is_native_sdk_model(selected_model_id):
|
| 859 |
-
print(f"[Generate] Using Native SDK (Gemini) for {selected_model_id}")
|
| 860 |
-
|
| 861 |
-
if selected_model_id == "gemini-3-flash-preview":
|
| 862 |
-
contents, config = create_gemini3_messages(messages)
|
| 863 |
-
stream = client.models.generate_content_stream(
|
| 864 |
-
model=selected_model_id,
|
| 865 |
-
contents=contents,
|
| 866 |
-
config=config
|
| 867 |
-
)
|
| 868 |
-
else:
|
| 869 |
-
raise ValueError(f"Unknown native SDK model: {selected_model_id}")
|
| 870 |
-
|
| 871 |
-
# All other models use OpenAI-compatible API
|
| 872 |
-
else:
|
| 873 |
-
stream = client.chat.completions.create(
|
| 874 |
-
model=actual_model_id,
|
| 875 |
-
messages=messages,
|
| 876 |
-
temperature=0.7,
|
| 877 |
-
max_tokens=10000,
|
| 878 |
-
stream=True
|
| 879 |
-
)
|
| 880 |
|
| 881 |
chunk_count = 0
|
| 882 |
-
is_mistral = is_mistral_model(selected_model_id)
|
| 883 |
-
is_native = is_native_sdk_model(selected_model_id)
|
| 884 |
|
| 885 |
-
# Only process stream if it exists
|
| 886 |
if stream:
|
| 887 |
-
# Optimized chunk processing
|
| 888 |
for chunk in stream:
|
| 889 |
chunk_content = None
|
| 890 |
|
| 891 |
-
|
| 892 |
-
|
| 893 |
-
|
| 894 |
-
chunk_content = chunk.
|
| 895 |
-
|
| 896 |
-
|
| 897 |
-
elif is_mistral:
|
| 898 |
-
# Mistral format: chunk.data.choices[0].delta.content
|
| 899 |
-
try:
|
| 900 |
-
if chunk.data and chunk.data.choices and chunk.data.choices[0].delta.content:
|
| 901 |
-
chunk_content = chunk.data.choices[0].delta.content
|
| 902 |
-
except (AttributeError, IndexError):
|
| 903 |
-
continue
|
| 904 |
-
else:
|
| 905 |
-
# OpenAI format: chunk.choices[0].delta.content
|
| 906 |
-
try:
|
| 907 |
-
if chunk.choices and chunk.choices[0].delta.content:
|
| 908 |
-
chunk_content = chunk.choices[0].delta.content
|
| 909 |
-
except (AttributeError, IndexError):
|
| 910 |
-
continue
|
| 911 |
|
| 912 |
if chunk_content:
|
| 913 |
generated_code += chunk_content
|
|
|
|
| 24 |
from backend_models import (
|
| 25 |
get_inference_client,
|
| 26 |
get_real_model_id,
|
|
|
|
| 27 |
is_native_sdk_model,
|
| 28 |
is_mistral_model
|
| 29 |
)
|
|
|
|
| 99 |
# Define models and languages here to avoid importing Gradio UI
|
| 100 |
AVAILABLE_MODELS = [
|
| 101 |
{"name": "GLM-4.6", "id": "zai-org/GLM-4.6", "description": "GLM-4.6 model via HuggingFace with Cerebras provider (Default)", "supports_images": False},
|
|
|
|
| 102 |
{"name": "GLM-4.6V 👁️", "id": "zai-org/GLM-4.6V:zai-org", "description": "GLM-4.6V vision model - supports image uploads for visual understanding", "supports_images": True},
|
| 103 |
+
{"name": "DeepSeek V3", "id": "deepseek-ai/DeepSeek-V3", "description": "DeepSeek V3 - Fast model for code generation via HuggingFace Router with Novita provider", "supports_images": False},
|
| 104 |
+
{"name": "DeepSeek R1", "id": "deepseek-ai/DeepSeek-R1", "description": "DeepSeek R1 model for code generation via HuggingFace", "supports_images": False},
|
|
|
|
|
|
|
|
|
|
| 105 |
{"name": "MiniMax M2", "id": "MiniMaxAI/MiniMax-M2", "description": "MiniMax M2 model via HuggingFace InferenceClient with Novita provider", "supports_images": False},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
{"name": "Kimi K2 Thinking", "id": "moonshotai/Kimi-K2-Thinking", "description": "Moonshot Kimi K2 Thinking model via HuggingFace with Together AI provider", "supports_images": False},
|
|
|
|
| 107 |
]
|
| 108 |
|
| 109 |
# Cache model lookup for faster access (built after AVAILABLE_MODELS is defined)
|
|
|
|
| 831 |
|
| 832 |
# Stream the response
|
| 833 |
try:
|
| 834 |
+
# All models now use OpenAI-compatible API via HF Router or Inference API
|
| 835 |
+
stream = client.chat.completions.create(
|
| 836 |
+
model=actual_model_id,
|
| 837 |
+
messages=messages,
|
| 838 |
+
temperature=0.7,
|
| 839 |
+
max_tokens=10000,
|
| 840 |
+
stream=True
|
| 841 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 842 |
|
| 843 |
chunk_count = 0
|
|
|
|
|
|
|
| 844 |
|
| 845 |
+
# Only process stream if it exists
|
| 846 |
if stream:
|
| 847 |
+
# Optimized chunk processing
|
| 848 |
for chunk in stream:
|
| 849 |
chunk_content = None
|
| 850 |
|
| 851 |
+
# OpenAI format: chunk.choices[0].delta.content
|
| 852 |
+
try:
|
| 853 |
+
if chunk.choices and chunk.choices[0].delta.content:
|
| 854 |
+
chunk_content = chunk.choices[0].delta.content
|
| 855 |
+
except (AttributeError, IndexError):
|
| 856 |
+
continue
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 857 |
|
| 858 |
if chunk_content:
|
| 859 |
generated_code += chunk_content
|
backend_models.py
CHANGED
|
@@ -6,15 +6,6 @@ import os
|
|
| 6 |
from typing import Optional
|
| 7 |
|
| 8 |
from openai import OpenAI
|
| 9 |
-
from mistralai import Mistral
|
| 10 |
-
|
| 11 |
-
# Import genai for Gemini (legacy - no longer used with Poe API)
|
| 12 |
-
try:
|
| 13 |
-
from google import genai
|
| 14 |
-
from google.genai import types
|
| 15 |
-
GEMINI_AVAILABLE = True
|
| 16 |
-
except ImportError:
|
| 17 |
-
GEMINI_AVAILABLE = False
|
| 18 |
|
| 19 |
def get_inference_client(model_id: str, provider: str = "auto"):
|
| 20 |
"""
|
|
@@ -22,119 +13,7 @@ def get_inference_client(model_id: str, provider: str = "auto"):
|
|
| 22 |
|
| 23 |
Returns OpenAI-compatible client for all models or raises error if not configured.
|
| 24 |
"""
|
| 25 |
-
if model_id == "
|
| 26 |
-
# Use Poe (OpenAI-compatible) client for Gemini 3.0 Pro
|
| 27 |
-
return OpenAI(
|
| 28 |
-
api_key=os.getenv("POE_API_KEY"),
|
| 29 |
-
base_url="https://api.poe.com/v1"
|
| 30 |
-
)
|
| 31 |
-
|
| 32 |
-
elif model_id == "qwen3-30b-a3b-instruct-2507":
|
| 33 |
-
# Use DashScope OpenAI client
|
| 34 |
-
return OpenAI(
|
| 35 |
-
api_key=os.getenv("DASHSCOPE_API_KEY"),
|
| 36 |
-
base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
|
| 37 |
-
)
|
| 38 |
-
|
| 39 |
-
elif model_id == "qwen3-30b-a3b-thinking-2507":
|
| 40 |
-
# Use DashScope OpenAI client for Thinking model
|
| 41 |
-
return OpenAI(
|
| 42 |
-
api_key=os.getenv("DASHSCOPE_API_KEY"),
|
| 43 |
-
base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
|
| 44 |
-
)
|
| 45 |
-
|
| 46 |
-
elif model_id == "qwen3-coder-30b-a3b-instruct":
|
| 47 |
-
# Use DashScope OpenAI client for Coder model
|
| 48 |
-
return OpenAI(
|
| 49 |
-
api_key=os.getenv("DASHSCOPE_API_KEY"),
|
| 50 |
-
base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
|
| 51 |
-
)
|
| 52 |
-
|
| 53 |
-
elif model_id == "gpt-5.1":
|
| 54 |
-
# Use Poe (OpenAI-compatible) client for GPT-5.1 model
|
| 55 |
-
return OpenAI(
|
| 56 |
-
api_key=os.getenv("POE_API_KEY"),
|
| 57 |
-
base_url="https://api.poe.com/v1"
|
| 58 |
-
)
|
| 59 |
-
|
| 60 |
-
elif model_id == "gpt-5.1-instant":
|
| 61 |
-
# Use Poe (OpenAI-compatible) client for GPT-5.1 Instant model
|
| 62 |
-
return OpenAI(
|
| 63 |
-
api_key=os.getenv("POE_API_KEY"),
|
| 64 |
-
base_url="https://api.poe.com/v1"
|
| 65 |
-
)
|
| 66 |
-
|
| 67 |
-
elif model_id == "gpt-5.1-codex":
|
| 68 |
-
# Use Poe (OpenAI-compatible) client for GPT-5.1 Codex model
|
| 69 |
-
return OpenAI(
|
| 70 |
-
api_key=os.getenv("POE_API_KEY"),
|
| 71 |
-
base_url="https://api.poe.com/v1"
|
| 72 |
-
)
|
| 73 |
-
|
| 74 |
-
elif model_id == "gpt-5.1-codex-mini":
|
| 75 |
-
# Use Poe (OpenAI-compatible) client for GPT-5.1 Codex Mini model
|
| 76 |
-
return OpenAI(
|
| 77 |
-
api_key=os.getenv("POE_API_KEY"),
|
| 78 |
-
base_url="https://api.poe.com/v1"
|
| 79 |
-
)
|
| 80 |
-
|
| 81 |
-
elif model_id == "grok-4":
|
| 82 |
-
# Use Poe (OpenAI-compatible) client for Grok-4 model
|
| 83 |
-
return OpenAI(
|
| 84 |
-
api_key=os.getenv("POE_API_KEY"),
|
| 85 |
-
base_url="https://api.poe.com/v1"
|
| 86 |
-
)
|
| 87 |
-
|
| 88 |
-
elif model_id == "Grok-Code-Fast-1":
|
| 89 |
-
# Use Poe (OpenAI-compatible) client for Grok-Code-Fast-1 model
|
| 90 |
-
return OpenAI(
|
| 91 |
-
api_key=os.getenv("POE_API_KEY"),
|
| 92 |
-
base_url="https://api.poe.com/v1"
|
| 93 |
-
)
|
| 94 |
-
|
| 95 |
-
elif model_id == "claude-opus-4.1":
|
| 96 |
-
# Use Poe (OpenAI-compatible) client for Claude-Opus-4.1
|
| 97 |
-
return OpenAI(
|
| 98 |
-
api_key=os.getenv("POE_API_KEY"),
|
| 99 |
-
base_url="https://api.poe.com/v1"
|
| 100 |
-
)
|
| 101 |
-
|
| 102 |
-
elif model_id == "claude-opus-4.5":
|
| 103 |
-
# Use Poe (OpenAI-compatible) client for Claude-Opus-4.5
|
| 104 |
-
return OpenAI(
|
| 105 |
-
api_key=os.getenv("POE_API_KEY"),
|
| 106 |
-
base_url="https://api.poe.com/v1"
|
| 107 |
-
)
|
| 108 |
-
|
| 109 |
-
elif model_id == "claude-sonnet-4.5":
|
| 110 |
-
# Use Poe (OpenAI-compatible) client for Claude-Sonnet-4.5
|
| 111 |
-
return OpenAI(
|
| 112 |
-
api_key=os.getenv("POE_API_KEY"),
|
| 113 |
-
base_url="https://api.poe.com/v1"
|
| 114 |
-
)
|
| 115 |
-
|
| 116 |
-
elif model_id == "claude-haiku-4.5":
|
| 117 |
-
# Use Poe (OpenAI-compatible) client for Claude-Haiku-4.5
|
| 118 |
-
return OpenAI(
|
| 119 |
-
api_key=os.getenv("POE_API_KEY"),
|
| 120 |
-
base_url="https://api.poe.com/v1"
|
| 121 |
-
)
|
| 122 |
-
|
| 123 |
-
elif model_id == "x-ai/grok-4.1-fast":
|
| 124 |
-
# Use OpenRouter client for Grok 4.1 Fast model
|
| 125 |
-
return OpenAI(
|
| 126 |
-
api_key=os.getenv("OPENROUTER_API_KEY"),
|
| 127 |
-
base_url="https://openrouter.ai/api/v1",
|
| 128 |
-
)
|
| 129 |
-
|
| 130 |
-
elif model_id.startswith("openrouter/"):
|
| 131 |
-
# OpenRouter models
|
| 132 |
-
return OpenAI(
|
| 133 |
-
api_key=os.getenv("OPENROUTER_API_KEY"),
|
| 134 |
-
base_url="https://openrouter.ai/api/v1",
|
| 135 |
-
)
|
| 136 |
-
|
| 137 |
-
elif model_id == "MiniMaxAI/MiniMax-M2":
|
| 138 |
# Use HuggingFace Router with Novita provider for MiniMax M2 model
|
| 139 |
return OpenAI(
|
| 140 |
base_url="https://router.huggingface.co/v1",
|
|
@@ -142,56 +21,6 @@ def get_inference_client(model_id: str, provider: str = "auto"):
|
|
| 142 |
default_headers={"X-HF-Bill-To": "huggingface"}
|
| 143 |
)
|
| 144 |
|
| 145 |
-
elif model_id == "step-3":
|
| 146 |
-
# Use StepFun API client for Step-3 model
|
| 147 |
-
return OpenAI(
|
| 148 |
-
api_key=os.getenv("STEP_API_KEY"),
|
| 149 |
-
base_url="https://api.stepfun.com/v1"
|
| 150 |
-
)
|
| 151 |
-
|
| 152 |
-
elif model_id == "devstral-medium-2512":
|
| 153 |
-
# Use OpenRouter for Devstral
|
| 154 |
-
return OpenAI(
|
| 155 |
-
base_url="https://openrouter.ai/api/v1",
|
| 156 |
-
api_key=os.getenv("OPENROUTER_API_KEY"),
|
| 157 |
-
default_headers={
|
| 158 |
-
"HTTP-Referer": "https://anycoder.app",
|
| 159 |
-
"X-Title": "AnyCoder",
|
| 160 |
-
}
|
| 161 |
-
)
|
| 162 |
-
|
| 163 |
-
elif model_id == "codestral-2508" or model_id == "mistral-medium-2508":
|
| 164 |
-
# Use Mistral client for Mistral models
|
| 165 |
-
return Mistral(api_key=os.getenv("MISTRAL_API_KEY"))
|
| 166 |
-
|
| 167 |
-
elif model_id == "gemini-2.5-flash":
|
| 168 |
-
# Use Google Gemini (OpenAI-compatible) client
|
| 169 |
-
return OpenAI(
|
| 170 |
-
api_key=os.getenv("GEMINI_API_KEY"),
|
| 171 |
-
base_url="https://generativelanguage.googleapis.com/v1beta/openai/",
|
| 172 |
-
)
|
| 173 |
-
|
| 174 |
-
elif model_id == "gemini-2.5-pro":
|
| 175 |
-
# Use Google Gemini Pro (OpenAI-compatible) client
|
| 176 |
-
return OpenAI(
|
| 177 |
-
api_key=os.getenv("GEMINI_API_KEY"),
|
| 178 |
-
base_url="https://generativelanguage.googleapis.com/v1beta/openai/",
|
| 179 |
-
)
|
| 180 |
-
|
| 181 |
-
elif model_id == "gemini-flash-lite-latest":
|
| 182 |
-
# Use Google Gemini Flash Lite Latest (OpenAI-compatible) client
|
| 183 |
-
return OpenAI(
|
| 184 |
-
api_key=os.getenv("GEMINI_API_KEY"),
|
| 185 |
-
base_url="https://generativelanguage.googleapis.com/v1beta/openai/",
|
| 186 |
-
)
|
| 187 |
-
|
| 188 |
-
elif model_id == "kimi-k2-turbo-preview":
|
| 189 |
-
# Use Moonshot AI (OpenAI-compatible) client for Kimi K2 Turbo (Preview)
|
| 190 |
-
return OpenAI(
|
| 191 |
-
api_key=os.getenv("MOONSHOT_API_KEY"),
|
| 192 |
-
base_url="https://api.moonshot.ai/v1",
|
| 193 |
-
)
|
| 194 |
-
|
| 195 |
elif model_id == "moonshotai/Kimi-K2-Thinking":
|
| 196 |
# Use HuggingFace Router with Novita provider
|
| 197 |
return OpenAI(
|
|
@@ -232,27 +61,6 @@ def get_inference_client(model_id: str, provider: str = "auto"):
|
|
| 232 |
default_headers={"X-HF-Bill-To": "huggingface"}
|
| 233 |
)
|
| 234 |
|
| 235 |
-
elif model_id == "stealth-model-1":
|
| 236 |
-
# Use stealth model with generic configuration
|
| 237 |
-
api_key = os.getenv("STEALTH_MODEL_1_API_KEY")
|
| 238 |
-
if not api_key:
|
| 239 |
-
raise ValueError("STEALTH_MODEL_1_API_KEY environment variable is required")
|
| 240 |
-
|
| 241 |
-
base_url = os.getenv("STEALTH_MODEL_1_BASE_URL")
|
| 242 |
-
if not base_url:
|
| 243 |
-
raise ValueError("STEALTH_MODEL_1_BASE_URL environment variable is required")
|
| 244 |
-
|
| 245 |
-
return OpenAI(
|
| 246 |
-
api_key=api_key,
|
| 247 |
-
base_url=base_url,
|
| 248 |
-
)
|
| 249 |
-
|
| 250 |
-
elif model_id == "gemini-3-flash-preview":
|
| 251 |
-
# Use native Google GenAI client for Gemini 3.0 Flash Preview
|
| 252 |
-
if not GEMINI_AVAILABLE:
|
| 253 |
-
raise ImportError("google-genai package required for Gemini 3")
|
| 254 |
-
return genai.Client(api_key=os.getenv("GEMINI_API_KEY"))
|
| 255 |
-
|
| 256 |
else:
|
| 257 |
# Unknown model - try HuggingFace Inference API
|
| 258 |
return OpenAI(
|
|
@@ -263,17 +71,7 @@ def get_inference_client(model_id: str, provider: str = "auto"):
|
|
| 263 |
|
| 264 |
def get_real_model_id(model_id: str) -> str:
|
| 265 |
"""Get the real model ID with provider suffixes if needed"""
|
| 266 |
-
if model_id == "
|
| 267 |
-
return "mistralai/devstral-2512:free"
|
| 268 |
-
|
| 269 |
-
elif model_id == "stealth-model-1":
|
| 270 |
-
# Get the real model ID from environment variable
|
| 271 |
-
real_model_id = os.getenv("STEALTH_MODEL_1_ID")
|
| 272 |
-
if not real_model_id:
|
| 273 |
-
raise ValueError("STEALTH_MODEL_1_ID environment variable is required")
|
| 274 |
-
return real_model_id
|
| 275 |
-
|
| 276 |
-
elif model_id == "zai-org/GLM-4.6":
|
| 277 |
# GLM-4.6 requires Cerebras provider suffix in model string for API calls
|
| 278 |
return "zai-org/GLM-4.6:cerebras"
|
| 279 |
|
|
@@ -300,52 +98,12 @@ def get_real_model_id(model_id: str) -> str:
|
|
| 300 |
return model_id
|
| 301 |
|
| 302 |
|
| 303 |
-
def create_gemini3_messages(messages: list) -> tuple:
|
| 304 |
-
"""
|
| 305 |
-
Convert OpenAI-style messages to Gemini 3 format.
|
| 306 |
-
Returns (contents, tools, config)
|
| 307 |
-
"""
|
| 308 |
-
if not GEMINI_AVAILABLE:
|
| 309 |
-
raise ImportError("google-genai package required for Gemini 3")
|
| 310 |
-
|
| 311 |
-
contents = []
|
| 312 |
-
system_prompt = None
|
| 313 |
-
|
| 314 |
-
for msg in messages:
|
| 315 |
-
if msg['role'] == 'system':
|
| 316 |
-
system_prompt = msg['content']
|
| 317 |
-
elif msg['role'] in ['user', 'assistant']:
|
| 318 |
-
contents.append(
|
| 319 |
-
types.Content(
|
| 320 |
-
role="user" if msg['role'] == 'user' else "model",
|
| 321 |
-
parts=[types.Part.from_text(text=msg['content'])]
|
| 322 |
-
)
|
| 323 |
-
)
|
| 324 |
-
|
| 325 |
-
# Add system prompt as first user message if exists
|
| 326 |
-
if system_prompt:
|
| 327 |
-
contents.insert(0, types.Content(
|
| 328 |
-
role="user",
|
| 329 |
-
parts=[types.Part.from_text(text=f"System instructions: {system_prompt}")]
|
| 330 |
-
))
|
| 331 |
-
|
| 332 |
-
# Configure tools and thinking
|
| 333 |
-
tools = [types.Tool(googleSearch=types.GoogleSearch())]
|
| 334 |
-
config = types.GenerateContentConfig(
|
| 335 |
-
thinking_config=types.ThinkingConfig(thinking_level="HIGH"),
|
| 336 |
-
tools=tools,
|
| 337 |
-
max_output_tokens=16384
|
| 338 |
-
)
|
| 339 |
-
|
| 340 |
-
return contents, config
|
| 341 |
-
|
| 342 |
-
|
| 343 |
def is_native_sdk_model(model_id: str) -> bool:
|
| 344 |
"""Check if model uses native SDK (not OpenAI-compatible)"""
|
| 345 |
-
return
|
| 346 |
|
| 347 |
|
| 348 |
def is_mistral_model(model_id: str) -> bool:
|
| 349 |
"""Check if model uses Mistral SDK"""
|
| 350 |
-
return
|
| 351 |
|
|
|
|
| 6 |
from typing import Optional
|
| 7 |
|
| 8 |
from openai import OpenAI
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
def get_inference_client(model_id: str, provider: str = "auto"):
|
| 11 |
"""
|
|
|
|
| 13 |
|
| 14 |
Returns OpenAI-compatible client for all models or raises error if not configured.
|
| 15 |
"""
|
| 16 |
+
if model_id == "MiniMaxAI/MiniMax-M2":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
# Use HuggingFace Router with Novita provider for MiniMax M2 model
|
| 18 |
return OpenAI(
|
| 19 |
base_url="https://router.huggingface.co/v1",
|
|
|
|
| 21 |
default_headers={"X-HF-Bill-To": "huggingface"}
|
| 22 |
)
|
| 23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
elif model_id == "moonshotai/Kimi-K2-Thinking":
|
| 25 |
# Use HuggingFace Router with Novita provider
|
| 26 |
return OpenAI(
|
|
|
|
| 61 |
default_headers={"X-HF-Bill-To": "huggingface"}
|
| 62 |
)
|
| 63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
else:
|
| 65 |
# Unknown model - try HuggingFace Inference API
|
| 66 |
return OpenAI(
|
|
|
|
| 71 |
|
| 72 |
def get_real_model_id(model_id: str) -> str:
|
| 73 |
"""Get the real model ID with provider suffixes if needed"""
|
| 74 |
+
if model_id == "zai-org/GLM-4.6":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
# GLM-4.6 requires Cerebras provider suffix in model string for API calls
|
| 76 |
return "zai-org/GLM-4.6:cerebras"
|
| 77 |
|
|
|
|
| 98 |
return model_id
|
| 99 |
|
| 100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
def is_native_sdk_model(model_id: str) -> bool:
|
| 102 |
"""Check if model uses native SDK (not OpenAI-compatible)"""
|
| 103 |
+
return False
|
| 104 |
|
| 105 |
|
| 106 |
def is_mistral_model(model_id: str) -> bool:
|
| 107 |
"""Check if model uses Mistral SDK"""
|
| 108 |
+
return False
|
| 109 |
|
frontend/src/components/LandingPage.tsx
CHANGED
|
@@ -513,8 +513,8 @@ ${isGradio ? '\n\nIMPORTANT: Only output app.py with the redesigned UI (themes,
|
|
| 513 |
if (onStart) {
|
| 514 |
// Pass duplicated space ID so auto-deploy updates it
|
| 515 |
console.log('[Redesign] Calling onStart with duplicated repo ID:', duplicatedRepoId);
|
| 516 |
-
console.log('[Redesign] Using
|
| 517 |
-
onStart(redesignPrompt, result.language || 'html', '
|
| 518 |
}
|
| 519 |
}, 100);
|
| 520 |
|
|
@@ -558,8 +558,8 @@ Note: After generating the redesign, I will create a Pull Request on the origina
|
|
| 558 |
|
| 559 |
if (onStart) {
|
| 560 |
console.log('[Redesign] Will create PR - not passing repo ID');
|
| 561 |
-
console.log('[Redesign] Using
|
| 562 |
-
onStart(redesignPrompt, result.language || 'html', '
|
| 563 |
}
|
| 564 |
|
| 565 |
console.log('[Redesign] Will create PR after code generation completes');
|
|
|
|
| 513 |
if (onStart) {
|
| 514 |
// Pass duplicated space ID so auto-deploy updates it
|
| 515 |
console.log('[Redesign] Calling onStart with duplicated repo ID:', duplicatedRepoId);
|
| 516 |
+
console.log('[Redesign] Using GLM-4.6 for redesign');
|
| 517 |
+
onStart(redesignPrompt, result.language || 'html', 'zai-org/GLM-4.6', undefined, duplicatedRepoId);
|
| 518 |
}
|
| 519 |
}, 100);
|
| 520 |
|
|
|
|
| 558 |
|
| 559 |
if (onStart) {
|
| 560 |
console.log('[Redesign] Will create PR - not passing repo ID');
|
| 561 |
+
console.log('[Redesign] Using GLM-4.6 for redesign');
|
| 562 |
+
onStart(redesignPrompt, result.language || 'html', 'zai-org/GLM-4.6', undefined, repoId, true); // Pass true for shouldCreatePR
|
| 563 |
}
|
| 564 |
|
| 565 |
console.log('[Redesign] Will create PR after code generation completes');
|