akhaliq HF Staff commited on
Commit
adeffef
Β·
1 Parent(s): e6a4a9c

feat: set google/gemma-4-31B-it as the default model and add support for it in the backend and frontend

Browse files
backend_api.py CHANGED
@@ -100,7 +100,8 @@ def get_cached_client(model_id: str, provider: str = "auto"):
100
 
101
  # Define models and languages here to avoid importing Gradio UI
102
  AVAILABLE_MODELS = [
103
- {"name": "GLM-5.1 πŸš€", "id": "zai-org/GLM-5.1", "description": "GLM-5.1 - Latest powerful model via HuggingFace Router with Novita provider (Default)", "supports_images": False},
 
104
  {"name": "Qwen3.5-397B πŸ€–", "id": "Qwen/Qwen3.5-397B-A17B", "description": "Qwen3.5-397B-A17B - Latest powerful model via HuggingFace Router", "supports_images": True},
105
  {"name": "MiniMax-M2.5 πŸ€–", "id": "MiniMaxAI/MiniMax-M2.5", "description": "MiniMax-M2.5 - Latest powerful coder model via HuggingFace Router with fastest provider", "supports_images": False},
106
  {"name": "GLM-5 🧠", "id": "zai-org/GLM-5", "description": "GLM-5 - New powerful reasoning model via HuggingFace Router", "supports_images": False},
@@ -201,7 +202,7 @@ async def startup_event():
201
  class CodeGenerationRequest(BaseModel):
202
  query: str
203
  language: str = "html"
204
- model_id: str = "zai-org/GLM-5.1"
205
  provider: str = "auto"
206
  history: List[List[str]] = []
207
  agent_mode: bool = False
 
100
 
101
  # Define models and languages here to avoid importing Gradio UI
102
  AVAILABLE_MODELS = [
103
+ {"name": "Gemma-4-31B ✨", "id": "google/gemma-4-31B-it", "description": "Gemma-4-31B-it - Latest powerful model via HuggingFace Router with fastest provider (Default)", "supports_images": True},
104
+ {"name": "GLM-5.1 πŸš€", "id": "zai-org/GLM-5.1", "description": "GLM-5.1 - Powerful model via HuggingFace Router with Novita provider", "supports_images": False},
105
  {"name": "Qwen3.5-397B πŸ€–", "id": "Qwen/Qwen3.5-397B-A17B", "description": "Qwen3.5-397B-A17B - Latest powerful model via HuggingFace Router", "supports_images": True},
106
  {"name": "MiniMax-M2.5 πŸ€–", "id": "MiniMaxAI/MiniMax-M2.5", "description": "MiniMax-M2.5 - Latest powerful coder model via HuggingFace Router with fastest provider", "supports_images": False},
107
  {"name": "GLM-5 🧠", "id": "zai-org/GLM-5", "description": "GLM-5 - New powerful reasoning model via HuggingFace Router", "supports_images": False},
 
202
  class CodeGenerationRequest(BaseModel):
203
  query: str
204
  language: str = "html"
205
+ model_id: str = "google/gemma-4-31B-it"
206
  provider: str = "auto"
207
  history: List[List[str]] = []
208
  agent_mode: bool = False
backend_models.py CHANGED
@@ -69,6 +69,14 @@ def get_inference_client(model_id: str, provider: str = "auto"):
69
  default_headers={"X-HF-Bill-To": "huggingface"}
70
  )
71
 
 
 
 
 
 
 
 
 
72
  elif model_id.startswith("Qwen/Qwen3.5"):
73
  # Qwen 3.5 models via HuggingFace Router
74
  return OpenAI(
@@ -139,6 +147,9 @@ def get_real_model_id(model_id: str) -> str:
139
  # Qwen3-Coder-Next needs Novita provider
140
  return "Qwen/Qwen3-Coder-Next:novita"
141
 
 
 
 
142
  elif model_id == "Qwen/Qwen3.5-397B-A17B":
143
  # Qwen3.5-397B-A17B needs fastest provider
144
  return "Qwen/Qwen3.5-397B-A17B:fastest"
 
69
  default_headers={"X-HF-Bill-To": "huggingface"}
70
  )
71
 
72
+ elif model_id.startswith("google/gemma"):
73
+ # Gemma models via HuggingFace Router
74
+ return OpenAI(
75
+ base_url="https://router.huggingface.co/v1",
76
+ api_key=os.getenv("HF_TOKEN"),
77
+ default_headers={"X-HF-Bill-To": "huggingface"}
78
+ )
79
+
80
  elif model_id.startswith("Qwen/Qwen3.5"):
81
  # Qwen 3.5 models via HuggingFace Router
82
  return OpenAI(
 
147
  # Qwen3-Coder-Next needs Novita provider
148
  return "Qwen/Qwen3-Coder-Next:novita"
149
 
150
+ elif model_id == "google/gemma-4-31B-it":
151
+ return "google/gemma-4-31B-it:fastest"
152
+
153
  elif model_id == "Qwen/Qwen3.5-397B-A17B":
154
  # Qwen3.5-397B-A17B needs fastest provider
155
  return "Qwen/Qwen3.5-397B-A17B:fastest"
frontend/src/app/page.tsx CHANGED
@@ -17,7 +17,7 @@ export default function Home() {
17
 
18
  const [generatedCode, setGeneratedCode] = useState('');
19
  const [selectedLanguage, setSelectedLanguage] = useState<Language>('html');
20
- const [selectedModel, setSelectedModel] = useState('zai-org/GLM-5.1');
21
  const [models, setModels] = useState<Model[]>([]);
22
  const [isGenerating, setIsGenerating] = useState(false);
23
  const [isAuthenticated, setIsAuthenticated] = useState(false);
 
17
 
18
  const [generatedCode, setGeneratedCode] = useState('');
19
  const [selectedLanguage, setSelectedLanguage] = useState<Language>('html');
20
+ const [selectedModel, setSelectedModel] = useState('google/gemma-4-31B-it');
21
  const [models, setModels] = useState<Model[]>([]);
22
  const [isGenerating, setIsGenerating] = useState(false);
23
  const [isAuthenticated, setIsAuthenticated] = useState(false);
frontend/src/components/ControlPanel.tsx CHANGED
@@ -89,6 +89,7 @@ export default function ControlPanel({
89
  };
90
 
91
  const formatModelName = (name: string, id: string) => {
 
92
  if (id === 'zai-org/GLM-5.1') return 'GLM-5.1 πŸš€';
93
  if (id === 'Qwen/Qwen3.5-397B-A17B') return 'Qwen3.5-397B-A17B πŸ€–';
94
  return name;
@@ -201,7 +202,7 @@ export default function ControlPanel({
201
  >
202
  <div className="flex items-center justify-between gap-2">
203
  <span className="text-sm text-[#f5f5f7]">{formatModelName(model.name, model.id)}</span>
204
- {['zai-org/GLM-5.1', 'Qwen/Qwen3.5-397B-A17B', 'MiniMaxAI/MiniMax-M2.5'].includes(model.id) && (
205
  <span className="px-1.5 py-0.5 bg-gradient-to-r from-purple-500 to-pink-500 text-white text-[9px] font-bold rounded uppercase flex-shrink-0">
206
  NEW
207
  </span>
 
89
  };
90
 
91
  const formatModelName = (name: string, id: string) => {
92
+ if (id === 'google/gemma-4-31B-it') return 'Gemma-4-31B ✨';
93
  if (id === 'zai-org/GLM-5.1') return 'GLM-5.1 πŸš€';
94
  if (id === 'Qwen/Qwen3.5-397B-A17B') return 'Qwen3.5-397B-A17B πŸ€–';
95
  return name;
 
202
  >
203
  <div className="flex items-center justify-between gap-2">
204
  <span className="text-sm text-[#f5f5f7]">{formatModelName(model.name, model.id)}</span>
205
+ {['google/gemma-4-31B-it', 'zai-org/GLM-5.1', 'Qwen/Qwen3.5-397B-A17B', 'MiniMaxAI/MiniMax-M2.5'].includes(model.id) && (
206
  <span className="px-1.5 py-0.5 bg-gradient-to-r from-purple-500 to-pink-500 text-white text-[9px] font-bold rounded uppercase flex-shrink-0">
207
  NEW
208
  </span>
frontend/src/components/LandingPage.tsx CHANGED
@@ -31,7 +31,7 @@ export default function LandingPage({
31
  onImport,
32
  isAuthenticated,
33
  initialLanguage = 'html',
34
- initialModel = 'zai-org/GLM-5.1',
35
  onAuthChange,
36
  setPendingPR,
37
  pendingPRRef
@@ -282,6 +282,7 @@ export default function LandingPage({
282
  };
283
 
284
  const formatModelName = (name: string, id: string) => {
 
285
  if (id === 'zai-org/GLM-5.1') return 'GLM-5.1 πŸš€';
286
  if (id === 'Qwen/Qwen3.5-397B-A17B') return 'Qwen3.5-397B-A17B πŸ€–';
287
  return name;
@@ -520,8 +521,8 @@ ${isGradio ? '\n\nIMPORTANT: Only output app.py with the redesigned UI (themes,
520
  if (onStart) {
521
  // Pass duplicated space ID so auto-deploy updates it
522
  console.log('[Redesign] Calling onStart with duplicated repo ID:', duplicatedRepoId);
523
- console.log('[Redesign] Using zai-org/GLM-5.1 for redesign');
524
- onStart(redesignPrompt, result.language || 'html', 'zai-org/GLM-5.1', undefined, duplicatedRepoId);
525
  }
526
  }, 100);
527
 
@@ -565,8 +566,8 @@ Note: After generating the redesign, I will create a Pull Request on the origina
565
 
566
  if (onStart) {
567
  console.log('[Redesign] Will create PR - not passing repo ID');
568
- console.log('[Redesign] Using zai-org/GLM-5.1 for redesign');
569
- onStart(redesignPrompt, result.language || 'html', 'zai-org/GLM-5.1', undefined, repoId, true); // Pass true for shouldCreatePR
570
  }
571
 
572
  console.log('[Redesign] Will create PR after code generation completes');
 
31
  onImport,
32
  isAuthenticated,
33
  initialLanguage = 'html',
34
+ initialModel = 'google/gemma-4-31B-it',
35
  onAuthChange,
36
  setPendingPR,
37
  pendingPRRef
 
282
  };
283
 
284
  const formatModelName = (name: string, id: string) => {
285
+ if (id === 'google/gemma-4-31B-it') return 'Gemma-4-31B ✨';
286
  if (id === 'zai-org/GLM-5.1') return 'GLM-5.1 πŸš€';
287
  if (id === 'Qwen/Qwen3.5-397B-A17B') return 'Qwen3.5-397B-A17B πŸ€–';
288
  return name;
 
521
  if (onStart) {
522
  // Pass duplicated space ID so auto-deploy updates it
523
  console.log('[Redesign] Calling onStart with duplicated repo ID:', duplicatedRepoId);
524
+ console.log('[Redesign] Using google/gemma-4-31B-it for redesign');
525
+ onStart(redesignPrompt, result.language || 'html', 'google/gemma-4-31B-it', undefined, duplicatedRepoId);
526
  }
527
  }, 100);
528
 
 
566
 
567
  if (onStart) {
568
  console.log('[Redesign] Will create PR - not passing repo ID');
569
+ console.log('[Redesign] Using google/gemma-4-31B-it for redesign');
570
+ onStart(redesignPrompt, result.language || 'html', 'google/gemma-4-31B-it', undefined, repoId, true); // Pass true for shouldCreatePR
571
  }
572
 
573
  console.log('[Redesign] Will create PR after code generation completes');