Fix: patch_frontend also renames existing models in dropdown (Kimi→DeepSeek, MiniMax→Flash, GLM→Flash)
Browse files- patch_frontend.py +44 -18
patch_frontend.py
CHANGED
|
@@ -1,17 +1,46 @@
|
|
| 1 |
-
"""Patch frontend ChatInput.tsx:
|
| 2 |
|
| 3 |
FILE = "/source/frontend/src/components/Chat/ChatInput.tsx"
|
| 4 |
|
| 5 |
with open(FILE, "r") as f:
|
| 6 |
content = f.read()
|
| 7 |
|
| 8 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
idx_deepseek = content.find("'deepseek-v4-pro'")
|
| 10 |
if idx_deepseek == -1:
|
| 11 |
idx_deepseek = content.find("deepseek-ai/DeepSeek-V4")
|
| 12 |
if idx_deepseek == -1:
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
| 15 |
|
| 16 |
idx_end = content.find("];", idx_deepseek)
|
| 17 |
if idx_end == -1:
|
|
@@ -35,8 +64,8 @@ new_models = """ {
|
|
| 35 |
recommended: true,
|
| 36 |
},
|
| 37 |
{
|
| 38 |
-
id: 'deepseek-v4-pro',
|
| 39 |
-
name: 'DeepSeek V4 Pro',
|
| 40 |
description: 'OpenRouter · code quality · rẻ',
|
| 41 |
modelPath: 'openai/deepseek/deepseek-v4-pro',
|
| 42 |
avatarUrl: 'https://huggingface.co/api/avatars/deepseek-ai',
|
|
@@ -74,19 +103,16 @@ new_models = """ {
|
|
| 74 |
"""
|
| 75 |
|
| 76 |
content = content[:idx_end] + new_models + content[idx_end:]
|
| 77 |
-
|
| 78 |
-
# Rename Claude → Owl Alpha in UI
|
| 79 |
-
content = content.replace("'Claude Opus 4'", "'Owl Alpha'")
|
| 80 |
-
content = content.replace('"Claude Opus 4"', '"Owl Alpha"')
|
| 81 |
-
content = content.replace("Claude Opus", "Owl Alpha")
|
| 82 |
|
| 83 |
with open(FILE, "w") as f:
|
| 84 |
f.write(content)
|
| 85 |
|
| 86 |
-
|
| 87 |
-
assert "
|
| 88 |
-
assert "deepseek-v4-
|
| 89 |
-
assert "
|
| 90 |
-
assert "
|
| 91 |
-
assert "
|
| 92 |
-
|
|
|
|
|
|
| 1 |
+
"""Patch frontend ChatInput.tsx: rename existing models + add new ones."""
|
| 2 |
|
| 3 |
FILE = "/source/frontend/src/components/Chat/ChatInput.tsx"
|
| 4 |
|
| 5 |
with open(FILE, "r") as f:
|
| 6 |
content = f.read()
|
| 7 |
|
| 8 |
+
# === STEP 1: Rename existing models in DEFAULT_MODEL_OPTIONS ===
|
| 9 |
+
|
| 10 |
+
# STT 1: Kimi K2.6 → DeepSeek V4 Pro (HF Inference)
|
| 11 |
+
content = content.replace("moonshotai/Kimi-K2.6", "deepseek-ai/DeepSeek-V4-Pro")
|
| 12 |
+
content = content.replace("'Kimi K2.6'", "'DeepSeek V4 Pro'")
|
| 13 |
+
content = content.replace('"Kimi K2.6"', '"DeepSeek V4 Pro"')
|
| 14 |
+
content = content.replace("Kimi K2.6", "DeepSeek V4 Pro")
|
| 15 |
+
|
| 16 |
+
# STT 4: MiniMax M2.7 → deepseek/deepseek-v4-flash (OpenRouter)
|
| 17 |
+
content = content.replace("MiniMaxAI/MiniMax-M2.7", "openai/deepseek/deepseek-v4-flash")
|
| 18 |
+
content = content.replace("'MiniMax M2.7'", "'DeepSeek V4 Flash (OR)'")
|
| 19 |
+
content = content.replace('"MiniMax M2.7"', '"DeepSeek V4 Flash (OR)"')
|
| 20 |
+
content = content.replace("MiniMax M2.7", "DeepSeek V4 Flash (OR)")
|
| 21 |
+
|
| 22 |
+
# STT 5: GLM 5.1 → DeepSeek-V4-Flash (HF Inference)
|
| 23 |
+
content = content.replace("zai-org/GLM-5.1", "deepseek-ai/DeepSeek-V4-Flash")
|
| 24 |
+
content = content.replace("'GLM 5.1'", "'DeepSeek V4 Flash'")
|
| 25 |
+
content = content.replace('"GLM 5.1"', '"DeepSeek V4 Flash"')
|
| 26 |
+
content = content.replace("GLM 5.1", "DeepSeek V4 Flash")
|
| 27 |
+
|
| 28 |
+
# Rename Claude → Owl Alpha
|
| 29 |
+
content = content.replace("'Claude Opus 4'", "'Owl Alpha'")
|
| 30 |
+
content = content.replace('"Claude Opus 4"', '"Owl Alpha"')
|
| 31 |
+
content = content.replace("Claude Opus", "Owl Alpha")
|
| 32 |
+
|
| 33 |
+
print("✅ Renamed existing models in dropdown")
|
| 34 |
+
|
| 35 |
+
# === STEP 2: Add new models at end of array ===
|
| 36 |
idx_deepseek = content.find("'deepseek-v4-pro'")
|
| 37 |
if idx_deepseek == -1:
|
| 38 |
idx_deepseek = content.find("deepseek-ai/DeepSeek-V4")
|
| 39 |
if idx_deepseek == -1:
|
| 40 |
+
idx_deepseek = content.find("DeepSeek-V4-Pro")
|
| 41 |
+
if idx_deepseek == -1:
|
| 42 |
+
print("⚠️ Cannot find DeepSeek entry, trying last model entry")
|
| 43 |
+
idx_deepseek = content.rfind("recommended:")
|
| 44 |
|
| 45 |
idx_end = content.find("];", idx_deepseek)
|
| 46 |
if idx_end == -1:
|
|
|
|
| 64 |
recommended: true,
|
| 65 |
},
|
| 66 |
{
|
| 67 |
+
id: 'deepseek-v4-pro-or',
|
| 68 |
+
name: 'DeepSeek V4 Pro (OR)',
|
| 69 |
description: 'OpenRouter · code quality · rẻ',
|
| 70 |
modelPath: 'openai/deepseek/deepseek-v4-pro',
|
| 71 |
avatarUrl: 'https://huggingface.co/api/avatars/deepseek-ai',
|
|
|
|
| 103 |
"""
|
| 104 |
|
| 105 |
content = content[:idx_end] + new_models + content[idx_end:]
|
| 106 |
+
print("✅ Added new models to dropdown")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
|
| 108 |
with open(FILE, "w") as f:
|
| 109 |
f.write(content)
|
| 110 |
|
| 111 |
+
# Verify
|
| 112 |
+
assert "deepseek-ai/DeepSeek-V4-Pro" in content, "Missing DeepSeek V4 Pro"
|
| 113 |
+
assert "openai/deepseek/deepseek-v4-flash" in content, "Missing deepseek-v4-flash OR"
|
| 114 |
+
assert "deepseek-ai/DeepSeek-V4-Flash" in content, "Missing DeepSeek V4 Flash HF"
|
| 115 |
+
assert "owl-alpha" in content, "Missing owl-alpha"
|
| 116 |
+
assert "nemotron-3-super-120b" in content, "Missing nemotron"
|
| 117 |
+
assert "Qwen3-Coder-Next" in content, "Missing Qwen3"
|
| 118 |
+
print("✅ All assertions passed")
|