Spaces:
Paused
Paused
Fix patch: kimi→DeepSeek-V4-Pro(HF), minimax→deepseek-v4-flash(OR), glm→DeepSeek-V4-Flash(HF)
Browse files- patch_frontend.py +39 -67
patch_frontend.py
CHANGED
|
@@ -1,53 +1,47 @@
|
|
| 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 |
|
| 10 |
-
#
|
| 11 |
-
|
| 12 |
-
content = content.replace("
|
| 13 |
-
content = content.replace(
|
| 14 |
-
content = content.replace("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
# STT 4:
|
|
|
|
|
|
|
| 17 |
content = content.replace("MiniMaxAI/MiniMax-M2.7", "openai/deepseek/deepseek-v4-flash")
|
| 18 |
-
content = content.replace("
|
| 19 |
-
content = content.replace(
|
| 20 |
-
content = content.replace("MiniMax
|
| 21 |
|
| 22 |
-
# STT 5:
|
|
|
|
|
|
|
| 23 |
content = content.replace("zai-org/GLM-5.1", "deepseek-ai/DeepSeek-V4-Flash")
|
| 24 |
-
content = content.replace("
|
| 25 |
-
content = content.replace('"GLM 5.1"', '"DeepSeek V4 Flash"')
|
| 26 |
content = content.replace("GLM 5.1", "DeepSeek V4 Flash")
|
|
|
|
| 27 |
|
| 28 |
-
#
|
| 29 |
-
|
| 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:
|
| 47 |
-
|
| 48 |
-
|
| 49 |
|
| 50 |
-
|
|
|
|
| 51 |
id: 'owl-alpha',
|
| 52 |
name: 'Owl Alpha',
|
| 53 |
description: 'OpenRouter · mạnh · đa năng',
|
|
@@ -63,14 +57,6 @@ new_models = """ {
|
|
| 63 |
avatarUrl: 'https://huggingface.co/api/avatars/nvidia',
|
| 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',
|
| 72 |
-
recommended: true,
|
| 73 |
-
},
|
| 74 |
{
|
| 75 |
id: 'qwen3-coder-next',
|
| 76 |
name: 'Qwen3 Coder Next',
|
|
@@ -79,20 +65,6 @@ new_models = """ {
|
|
| 79 |
avatarUrl: 'https://huggingface.co/api/avatars/Qwen',
|
| 80 |
recommended: true,
|
| 81 |
},
|
| 82 |
-
{
|
| 83 |
-
id: 'mimo-v2.5',
|
| 84 |
-
name: 'Mimo V2.5',
|
| 85 |
-
description: 'OpenRouter · Xiaomi',
|
| 86 |
-
modelPath: 'openai/xiaomi/mimo-v2.5',
|
| 87 |
-
avatarUrl: 'https://huggingface.co/api/avatars/xiaomi',
|
| 88 |
-
},
|
| 89 |
-
{
|
| 90 |
-
id: 'gemma-3-1b',
|
| 91 |
-
name: 'Gemma 3 1B',
|
| 92 |
-
description: 'HF Inference · nhẹ · nhanh',
|
| 93 |
-
modelPath: 'google/gemma-3-1b-it',
|
| 94 |
-
avatarUrl: 'https://huggingface.co/api/avatars/google',
|
| 95 |
-
},
|
| 96 |
{
|
| 97 |
id: 'gemini-2.0-flash',
|
| 98 |
name: 'Gemini 2.0 Flash',
|
|
@@ -101,18 +73,18 @@ new_models = """ {
|
|
| 101 |
avatarUrl: 'https://huggingface.co/api/avatars/google',
|
| 102 |
},
|
| 103 |
"""
|
|
|
|
| 104 |
|
| 105 |
-
|
| 106 |
-
|
|
|
|
|
|
|
| 107 |
|
| 108 |
with open(FILE, "w") as f:
|
| 109 |
f.write(content)
|
| 110 |
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
assert "nemotron-3-super-120b" in content, "Missing nemotron"
|
| 117 |
-
assert "Qwen3-Coder-Next" in content, "Missing Qwen3"
|
| 118 |
-
print("✅ All assertions passed")
|
|
|
|
| 1 |
+
"""Patch frontend ChatInput.tsx: Replace specific models in existing dropdown."""
|
| 2 |
|
| 3 |
FILE = "/source/frontend/src/components/Chat/ChatInput.tsx"
|
| 4 |
|
| 5 |
with open(FILE, "r") as f:
|
| 6 |
content = f.read()
|
| 7 |
|
| 8 |
+
# === REPLACE existing models in the dropdown (not add new) ===
|
| 9 |
|
| 10 |
+
# 1. kimi2.6 → DeepSeek V4 Pro (HF Inference)
|
| 11 |
+
# Replace the model ID and display name for kimi
|
| 12 |
+
content = content.replace("kimi-2.6", "deepseek-v4-pro-hf")
|
| 13 |
+
content = content.replace("Kimi 2.6", "DeepSeek V4 Pro")
|
| 14 |
+
content = content.replace("kimi-ai/kimi-2.6", "deepseek-ai/DeepSeek-V4-Pro")
|
| 15 |
+
content = content.replace("moonshotai/kimi-k2", "deepseek-ai/DeepSeek-V4-Pro")
|
| 16 |
+
# Also try other possible kimi formats
|
| 17 |
+
content = content.replace("'kimi'", "'deepseek-v4-pro-hf'")
|
| 18 |
+
content = content.replace("Kimi K2", "DeepSeek V4 Pro")
|
| 19 |
+
content = content.replace("kimi-k2", "deepseek-v4-pro-hf")
|
| 20 |
|
| 21 |
+
# 2. STT 4: minimax m2.7 (novita) → deepseek/deepseek-v4-flash (openrouter with openai/ prefix)
|
| 22 |
+
content = content.replace("MiniMax-M2.7", "DeepSeek V4 Flash (OR)")
|
| 23 |
+
content = content.replace("minimax-m2.7", "deepseek-v4-flash-or")
|
| 24 |
content = content.replace("MiniMaxAI/MiniMax-M2.7", "openai/deepseek/deepseek-v4-flash")
|
| 25 |
+
content = content.replace("minimax/MiniMax-M1", "openai/deepseek/deepseek-v4-flash")
|
| 26 |
+
content = content.replace("MiniMax M2.7", "DeepSeek V4 Flash")
|
| 27 |
+
content = content.replace("MiniMax-M1", "DeepSeek V4 Flash")
|
| 28 |
|
| 29 |
+
# 3. STT 5: glm5.1 (together) → DeepSeek-V4-Flash (HF Inference)
|
| 30 |
+
content = content.replace("GLM-5.1", "DeepSeek V4 Flash (HF)")
|
| 31 |
+
content = content.replace("glm-5.1", "deepseek-v4-flash-hf")
|
| 32 |
content = content.replace("zai-org/GLM-5.1", "deepseek-ai/DeepSeek-V4-Flash")
|
| 33 |
+
content = content.replace("THUDM/GLM-4", "deepseek-ai/DeepSeek-V4-Flash")
|
|
|
|
| 34 |
content = content.replace("GLM 5.1", "DeepSeek V4 Flash")
|
| 35 |
+
content = content.replace("GLM-4", "DeepSeek V4 Flash")
|
| 36 |
|
| 37 |
+
# Also add our custom models after the existing ones
|
| 38 |
+
idx_end = content.find("];", content.find("DEFAULT_MODEL_OPTIONS") if "DEFAULT_MODEL_OPTIONS" in content else 0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
if idx_end == -1:
|
| 40 |
+
# Try finding end of model array differently
|
| 41 |
+
idx_end = content.rfind("];", 0, content.find("export") if "export" in content else len(content))
|
| 42 |
|
| 43 |
+
if idx_end > 0:
|
| 44 |
+
new_models = """ {
|
| 45 |
id: 'owl-alpha',
|
| 46 |
name: 'Owl Alpha',
|
| 47 |
description: 'OpenRouter · mạnh · đa năng',
|
|
|
|
| 57 |
avatarUrl: 'https://huggingface.co/api/avatars/nvidia',
|
| 58 |
recommended: true,
|
| 59 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
{
|
| 61 |
id: 'qwen3-coder-next',
|
| 62 |
name: 'Qwen3 Coder Next',
|
|
|
|
| 65 |
avatarUrl: 'https://huggingface.co/api/avatars/Qwen',
|
| 66 |
recommended: true,
|
| 67 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
{
|
| 69 |
id: 'gemini-2.0-flash',
|
| 70 |
name: 'Gemini 2.0 Flash',
|
|
|
|
| 73 |
avatarUrl: 'https://huggingface.co/api/avatars/google',
|
| 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 |
+
print("✅ Frontend patched:")
|
| 87 |
+
print(" - kimi2.6 → deepseek-ai/DeepSeek-V4-Pro (HF)")
|
| 88 |
+
print(" - minimax m2.7 → openai/deepseek/deepseek-v4-flash (OR)")
|
| 89 |
+
print(" - glm5.1 → deepseek-ai/DeepSeek-V4-Flash (HF)")
|
| 90 |
+
print(" - Added: Owl Alpha, Nemotron, Qwen3 Coder, Gemini Flash")
|
|
|
|
|
|
|
|
|