Spaces:
Running
Running
Restore patch_frontend.py from commit 36e2e7f8
Browse files- patch_frontend.py +95 -0
patch_frontend.py
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Patch frontend ChatInput.tsx: Fix model IDs and rename dropdown labels."""
|
| 2 |
+
|
| 3 |
+
FILE = "/source/frontend/src/components/Chat/ChatInput.tsx"
|
| 4 |
+
|
| 5 |
+
with open(FILE, "r") as f:
|
| 6 |
+
content = f.read()
|
| 7 |
+
|
| 8 |
+
# === Row 2: Claude Opus 4.6 → Owl Alpha ===
|
| 9 |
+
content = content.replace("'Claude Opus 4.6'", "'Owl Alpha'")
|
| 10 |
+
content = content.replace('"Claude Opus 4.6"', '"Owl Alpha"')
|
| 11 |
+
content = content.replace("'Claude Opus 4'", "'Owl Alpha'")
|
| 12 |
+
content = content.replace('"Claude Opus 4"', '"Owl Alpha"')
|
| 13 |
+
content = content.replace("'Claude Sonnet 4.5'", "'Owl Beta'")
|
| 14 |
+
content = content.replace('"Claude Sonnet 4.5"', '"Owl Beta"')
|
| 15 |
+
content = content.replace("claude.label ?? option.name", "option.name")
|
| 16 |
+
content = content.replace("claude.label || option.name", "option.name")
|
| 17 |
+
content = content.replace("description: 'Anthropic'", "description: '🦉 Top Reasoning'")
|
| 18 |
+
|
| 19 |
+
# === Row 1: Kimi K2.6 → DeepSeek V4 Pro (HF Inference) ===
|
| 20 |
+
content = content.replace("moonshotai/Kimi-K2.6", "deepseek-ai/DeepSeek-V4-Pro")
|
| 21 |
+
content = content.replace("'Kimi K2.6'", "'DeepSeek V4 Pro'")
|
| 22 |
+
content = content.replace('"Kimi K2.6"', '"DeepSeek V4 Pro"')
|
| 23 |
+
|
| 24 |
+
# === Row 4: MiniMax M2.7 → DeepSeek V4 Flash, Novita → HF Inference ===
|
| 25 |
+
content = content.replace("MiniMaxAI/MiniMax-M2.7", "deepseek-ai/DeepSeek-V4-Flash")
|
| 26 |
+
content = content.replace("'MiniMax M2.7'", "'DeepSeek V4 Flash'")
|
| 27 |
+
content = content.replace('"MiniMax M2.7"', '"DeepSeek V4 Flash"')
|
| 28 |
+
content = content.replace("description: 'Novita'", "description: 'HF Inference'", 1)
|
| 29 |
+
|
| 30 |
+
# === Row 5: GLM 5.1 → DeepSeek V4 Flash, Together → Openrouter ===
|
| 31 |
+
content = content.replace("zai-org/GLM-5.1", "openai/deepseek/deepseek-v4-flash")
|
| 32 |
+
content = content.replace("'GLM 5.1'", "'DeepSeek V4 Flash'")
|
| 33 |
+
content = content.replace('"GLM 5.1"', '"DeepSeek V4 Flash"')
|
| 34 |
+
content = content.replace("description: 'Together'", "description: 'Openrouter'")
|
| 35 |
+
|
| 36 |
+
# === Row 6: DeepSeek V4 Pro (DeepInfra) → nvidia/nemotron-3-super-120b-a12b:free ===
|
| 37 |
+
content = content.replace("deepseek-ai/DeepSeek-V4-Pro:deepinfra", "nvidia/nemotron-3-super-120b-a12b:free")
|
| 38 |
+
content = content.replace("description: 'DeepInfra'", "description: 'Openrouter Free'")
|
| 39 |
+
# Find the name for row 6 - it's the one with id 'deepseek-v4-pro'
|
| 40 |
+
# In source: id: 'deepseek-v4-pro', name: 'DeepSeek V4 Pro'
|
| 41 |
+
# We need to change name to show the nvidia model path
|
| 42 |
+
content = content.replace("id: 'deepseek-v4-pro',\n name: 'DeepSeek V4 Pro'", "id: 'nemotron-120b',\n name: 'nvidia/nemotron-3-super-120b-a12b:free'")
|
| 43 |
+
|
| 44 |
+
# === Row 1 description: second Novita (if any remains) ===
|
| 45 |
+
content = content.replace("description: 'Novita'", "description: 'HF Inference'")
|
| 46 |
+
|
| 47 |
+
# === Update generic descriptions ===
|
| 48 |
+
content = content.replace("'Best coding model'", "'⚡ Mạnh nhất · Code + Reasoning'")
|
| 49 |
+
content = content.replace("'Best all-around model'", "'⚡ Mạnh nhất · Code + Reasoning'")
|
| 50 |
+
|
| 51 |
+
# === Add custom models at end of array ===
|
| 52 |
+
idx_end = content.find("];", content.find("DEFAULT_MODEL_OPTIONS") if "DEFAULT_MODEL_OPTIONS" in content else 0)
|
| 53 |
+
if idx_end == -1:
|
| 54 |
+
idx_end = content.rfind("];", 0, content.find("export") if "export" in content else len(content))
|
| 55 |
+
|
| 56 |
+
if idx_end > 0:
|
| 57 |
+
new_models = """ {
|
| 58 |
+
id: 'gemma-3-1b',
|
| 59 |
+
name: 'Gemma 3 1B',
|
| 60 |
+
description: 'HF Inference',
|
| 61 |
+
modelPath: 'google/gemma-3-1b-it',
|
| 62 |
+
avatarUrl: 'https://huggingface.co/api/avatars/google',
|
| 63 |
+
recommended: true,
|
| 64 |
+
},
|
| 65 |
+
{
|
| 66 |
+
id: 'qwen3-coder-next',
|
| 67 |
+
name: 'Qwen3 Coder Next',
|
| 68 |
+
description: 'HF Inference',
|
| 69 |
+
modelPath: 'Qwen/Qwen3-Coder-Next',
|
| 70 |
+
avatarUrl: 'https://huggingface.co/api/avatars/Qwen',
|
| 71 |
+
recommended: true,
|
| 72 |
+
},
|
| 73 |
+
{
|
| 74 |
+
id: 'gemini-2.0-flash',
|
| 75 |
+
name: 'Gemini 2.0 Flash',
|
| 76 |
+
description: 'Openrouter',
|
| 77 |
+
modelPath: 'openai/google/gemini-2.0-flash-001',
|
| 78 |
+
avatarUrl: 'https://huggingface.co/api/avatars/google',
|
| 79 |
+
},
|
| 80 |
+
"""
|
| 81 |
+
content = content[:idx_end] + new_models + content[idx_end:]
|
| 82 |
+
|
| 83 |
+
with open(FILE, "w") as f:
|
| 84 |
+
f.write(content)
|
| 85 |
+
|
| 86 |
+
print("✅ Frontend patched:")
|
| 87 |
+
print(" Row 1: DeepSeek V4 Pro | HF Inference")
|
| 88 |
+
print(" Row 2: Owl Alpha | 🦉 Top Reasoning")
|
| 89 |
+
print(" Row 3: GPT-5.5 | OpenAI")
|
| 90 |
+
print(" Row 4: DeepSeek V4 Flash | HF Inference (was Novita)")
|
| 91 |
+
print(" Row 5: DeepSeek V4 Flash | Openrouter (was Together)")
|
| 92 |
+
print(" Row 6: nvidia/nemotron-3-super-120b-a12b:free | Openrouter Free")
|
| 93 |
+
print(" Row 7: Gemma 3 1B | HF Inference")
|
| 94 |
+
print(" Row 8: Qwen3 Coder Next | HF Inference")
|
| 95 |
+
print(" Row 9: Gemini 2.0 Flash | Openrouter")
|