ml-intern / patch_frontend.py
bep40's picture
Fix dropdown names: row 4 Novita→HF Inference, row 6 name→nvidia/nemotron path
5203fb1 verified
Raw
History Blame Contribute Delete
4.43 kB
"""Patch frontend ChatInput.tsx: Fix model IDs and rename dropdown labels."""
FILE = "/source/frontend/src/components/Chat/ChatInput.tsx"
with open(FILE, "r") as f:
content = f.read()
# === Row 2: Claude Opus 4.6 → Owl Alpha ===
content = content.replace("'Claude Opus 4.6'", "'Owl Alpha'")
content = content.replace('"Claude Opus 4.6"', '"Owl Alpha"')
content = content.replace("'Claude Opus 4'", "'Owl Alpha'")
content = content.replace('"Claude Opus 4"', '"Owl Alpha"')
content = content.replace("'Claude Sonnet 4.5'", "'Owl Beta'")
content = content.replace('"Claude Sonnet 4.5"', '"Owl Beta"')
content = content.replace("claude.label ?? option.name", "option.name")
content = content.replace("claude.label || option.name", "option.name")
content = content.replace("description: 'Anthropic'", "description: '🦉 Top Reasoning'")
# === Row 1: Kimi K2.6 → DeepSeek V4 Pro (HF Inference) ===
content = content.replace("moonshotai/Kimi-K2.6", "deepseek-ai/DeepSeek-V4-Pro")
content = content.replace("'Kimi K2.6'", "'DeepSeek V4 Pro'")
content = content.replace('"Kimi K2.6"', '"DeepSeek V4 Pro"')
# === Row 4: MiniMax M2.7 → DeepSeek V4 Flash, Novita → HF Inference ===
content = content.replace("MiniMaxAI/MiniMax-M2.7", "deepseek-ai/DeepSeek-V4-Flash")
content = content.replace("'MiniMax M2.7'", "'DeepSeek V4 Flash'")
content = content.replace('"MiniMax M2.7"', '"DeepSeek V4 Flash"')
content = content.replace("description: 'Novita'", "description: 'HF Inference'", 1)
# === Row 5: GLM 5.1 → DeepSeek V4 Flash, Together → Openrouter ===
content = content.replace("zai-org/GLM-5.1", "openai/deepseek/deepseek-v4-flash")
content = content.replace("'GLM 5.1'", "'DeepSeek V4 Flash'")
content = content.replace('"GLM 5.1"', '"DeepSeek V4 Flash"')
content = content.replace("description: 'Together'", "description: 'Openrouter'")
# === Row 6: DeepSeek V4 Pro (DeepInfra) → nvidia/nemotron-3-super-120b-a12b:free ===
content = content.replace("deepseek-ai/DeepSeek-V4-Pro:deepinfra", "nvidia/nemotron-3-super-120b-a12b:free")
content = content.replace("description: 'DeepInfra'", "description: 'Openrouter Free'")
# Find the name for row 6 - it's the one with id 'deepseek-v4-pro'
# In source: id: 'deepseek-v4-pro', name: 'DeepSeek V4 Pro'
# We need to change name to show the nvidia model path
content = content.replace("id: 'deepseek-v4-pro',\n name: 'DeepSeek V4 Pro'", "id: 'nemotron-120b',\n name: 'nvidia/nemotron-3-super-120b-a12b:free'")
# === Row 1 description: second Novita (if any remains) ===
content = content.replace("description: 'Novita'", "description: 'HF Inference'")
# === Update generic descriptions ===
content = content.replace("'Best coding model'", "'⚡ Mạnh nhất · Code + Reasoning'")
content = content.replace("'Best all-around model'", "'⚡ Mạnh nhất · Code + Reasoning'")
# === Add custom models at end of array ===
idx_end = content.find("];", content.find("DEFAULT_MODEL_OPTIONS") if "DEFAULT_MODEL_OPTIONS" in content else 0)
if idx_end == -1:
idx_end = content.rfind("];", 0, content.find("export") if "export" in content else len(content))
if idx_end > 0:
new_models = """ {
id: 'gemma-3-1b',
name: 'Gemma 3 1B',
description: 'HF Inference',
modelPath: 'google/gemma-3-1b-it',
avatarUrl: 'https://huggingface.co/api/avatars/google',
recommended: true,
},
{
id: 'qwen3-coder-next',
name: 'Qwen3 Coder Next',
description: 'HF Inference',
modelPath: 'Qwen/Qwen3-Coder-Next',
avatarUrl: 'https://huggingface.co/api/avatars/Qwen',
recommended: true,
},
{
id: 'gemini-2.0-flash',
name: 'Gemini 2.0 Flash',
description: 'Openrouter',
modelPath: 'openai/google/gemini-2.0-flash-001',
avatarUrl: 'https://huggingface.co/api/avatars/google',
},
"""
content = content[:idx_end] + new_models + content[idx_end:]
with open(FILE, "w") as f:
f.write(content)
print("✅ Frontend patched:")
print(" Row 1: DeepSeek V4 Pro | HF Inference")
print(" Row 2: Owl Alpha | 🦉 Top Reasoning")
print(" Row 3: GPT-5.5 | OpenAI")
print(" Row 4: DeepSeek V4 Flash | HF Inference (was Novita)")
print(" Row 5: DeepSeek V4 Flash | Openrouter (was Together)")
print(" Row 6: nvidia/nemotron-3-super-120b-a12b:free | Openrouter Free")
print(" Row 7: Gemma 3 1B | HF Inference")
print(" Row 8: Qwen3 Coder Next | HF Inference")
print(" Row 9: Gemini 2.0 Flash | Openrouter")