Spaces:
Paused
Paused
Fix Owl Alpha: name display + openai/ prefix for OpenRouter routing
Browse files- patch_frontend.py +49 -41
patch_frontend.py
CHANGED
|
@@ -1,73 +1,81 @@
|
|
| 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 |
-
|
| 13 |
-
|
|
|
|
| 14 |
|
| 15 |
-
|
| 16 |
-
content = content.replace("MiniMaxAI/MiniMax-M2.7", "deepseek-ai/DeepSeek-V4-Flash")
|
| 17 |
-
content = content.replace("MiniMaxAI/MiniMax-M1", "deepseek-ai/DeepSeek-V4-Flash")
|
| 18 |
-
content = content.replace("minimax/MiniMax-M1", "deepseek-ai/DeepSeek-V4-Flash")
|
| 19 |
-
content = content.replace("MiniMax M2.7", "DeepSeek V4 Flash Inference")
|
| 20 |
-
content = content.replace("MiniMax M1", "DeepSeek V4 Flash Inference")
|
| 21 |
-
|
| 22 |
-
# === Fix STT 5: zai-org/GLM-5.1 → openai/deepseek/deepseek-v4-flash (OpenRouter) ===
|
| 23 |
-
content = content.replace("zai-org/GLM-5.1", "openai/deepseek/deepseek-v4-flash")
|
| 24 |
-
content = content.replace("THUDM/GLM-4", "openai/deepseek/deepseek-v4-flash")
|
| 25 |
-
content = content.replace("GLM 5.1", "DeepSeek V4 Flash Openrouter")
|
| 26 |
-
content = content.replace("GLM-4", "DeepSeek V4 Flash Openrouter")
|
| 27 |
-
|
| 28 |
-
# === Update descriptions for performance notes ===
|
| 29 |
-
# STT1 description
|
| 30 |
-
content = content.replace("'Best coding model'", "'⚡ Mạnh nhất · Code + Reasoning · Free HF Inference'")
|
| 31 |
-
content = content.replace("'Best all-around model'", "'⚡ Mạnh nhất · Code + Reasoning · Free HF Inference'")
|
| 32 |
-
|
| 33 |
-
# === Add custom models at end of array ===
|
| 34 |
-
idx_end = content.find("];", content.find("DEFAULT_MODEL_OPTIONS") if "DEFAULT_MODEL_OPTIONS" in content else 0)
|
| 35 |
if idx_end == -1:
|
| 36 |
-
|
|
|
|
| 37 |
|
| 38 |
-
|
| 39 |
-
new_models = """ {
|
| 40 |
id: 'owl-alpha',
|
| 41 |
name: 'Owl Alpha Openrouter',
|
| 42 |
-
description: '
|
| 43 |
-
modelPath: 'openrouter/owl-alpha',
|
| 44 |
avatarUrl: 'https://huggingface.co/api/avatars/openrouter',
|
| 45 |
recommended: true,
|
| 46 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
{
|
| 48 |
id: 'qwen3-coder-next',
|
| 49 |
name: 'Qwen3 Coder Next',
|
| 50 |
-
description: '
|
| 51 |
modelPath: 'Qwen/Qwen3-Coder-Next',
|
| 52 |
avatarUrl: 'https://huggingface.co/api/avatars/Qwen',
|
| 53 |
recommended: true,
|
| 54 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
{
|
| 56 |
id: 'gemini-2.0-flash',
|
| 57 |
name: 'Gemini 2.0 Flash',
|
| 58 |
-
description: '
|
| 59 |
modelPath: 'openai/google/gemini-2.0-flash-001',
|
| 60 |
avatarUrl: 'https://huggingface.co/api/avatars/google',
|
| 61 |
},
|
| 62 |
"""
|
| 63 |
-
|
|
|
|
| 64 |
|
| 65 |
with open(FILE, "w") as f:
|
| 66 |
f.write(content)
|
| 67 |
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Patch frontend ChatInput.tsx: Add all models to dropdown with descriptions."""
|
| 2 |
|
| 3 |
FILE = "/source/frontend/src/components/Chat/ChatInput.tsx"
|
| 4 |
|
| 5 |
with open(FILE, "r") as f:
|
| 6 |
content = f.read()
|
| 7 |
|
| 8 |
+
# Find end of DEFAULT_MODEL_OPTIONS array
|
| 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 |
+
print("❌ Cannot find DeepSeek entry!")
|
| 14 |
+
import sys; sys.exit(1)
|
| 15 |
|
| 16 |
+
idx_end = content.find("];", idx_deepseek)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
if idx_end == -1:
|
| 18 |
+
print("❌ Cannot find end of array!")
|
| 19 |
+
import sys; sys.exit(1)
|
| 20 |
|
| 21 |
+
new_models = """ {
|
|
|
|
| 22 |
id: 'owl-alpha',
|
| 23 |
name: 'Owl Alpha Openrouter',
|
| 24 |
+
description: 'OpenRouter · mạnh · đa năng',
|
| 25 |
+
modelPath: 'openai/openrouter/owl-alpha',
|
| 26 |
avatarUrl: 'https://huggingface.co/api/avatars/openrouter',
|
| 27 |
recommended: true,
|
| 28 |
},
|
| 29 |
+
{
|
| 30 |
+
id: 'deepseek-v4-pro',
|
| 31 |
+
name: 'DeepSeek V4 Pro',
|
| 32 |
+
description: 'Rẻ nhất · code quality cực tốt · HF Inference',
|
| 33 |
+
modelPath: 'deepseek-ai/DeepSeek-V4-Pro',
|
| 34 |
+
avatarUrl: 'https://huggingface.co/api/avatars/deepseek-ai',
|
| 35 |
+
recommended: true,
|
| 36 |
+
},
|
| 37 |
{
|
| 38 |
id: 'qwen3-coder-next',
|
| 39 |
name: 'Qwen3 Coder Next',
|
| 40 |
+
description: 'Code mạnh · HF Inference',
|
| 41 |
modelPath: 'Qwen/Qwen3-Coder-Next',
|
| 42 |
avatarUrl: 'https://huggingface.co/api/avatars/Qwen',
|
| 43 |
recommended: true,
|
| 44 |
},
|
| 45 |
+
{
|
| 46 |
+
id: 'minimax-m2.7',
|
| 47 |
+
name: 'MiniMax M2.7',
|
| 48 |
+
description: 'Đa năng · HF Inference',
|
| 49 |
+
modelPath: 'MiniMaxAI/MiniMax-M2.7',
|
| 50 |
+
avatarUrl: 'https://huggingface.co/api/avatars/MiniMaxAI',
|
| 51 |
+
},
|
| 52 |
+
{
|
| 53 |
+
id: 'glm-5.1',
|
| 54 |
+
name: 'GLM 5.1',
|
| 55 |
+
description: 'Mạnh · HF Inference',
|
| 56 |
+
modelPath: 'zai-org/GLM-5.1',
|
| 57 |
+
avatarUrl: 'https://huggingface.co/api/avatars/zai-org',
|
| 58 |
+
},
|
| 59 |
{
|
| 60 |
id: 'gemini-2.0-flash',
|
| 61 |
name: 'Gemini 2.0 Flash',
|
| 62 |
+
description: 'Rẻ · nhanh · OpenRouter',
|
| 63 |
modelPath: 'openai/google/gemini-2.0-flash-001',
|
| 64 |
avatarUrl: 'https://huggingface.co/api/avatars/google',
|
| 65 |
},
|
| 66 |
"""
|
| 67 |
+
|
| 68 |
+
content = content[:idx_end] + new_models + content[idx_end:]
|
| 69 |
|
| 70 |
with open(FILE, "w") as f:
|
| 71 |
f.write(content)
|
| 72 |
|
| 73 |
+
assert "owl-alpha" in content
|
| 74 |
+
assert "Owl Alpha Openrouter" in content
|
| 75 |
+
assert "openai/openrouter/owl-alpha" in content
|
| 76 |
+
assert "DeepSeek-V4-Pro" in content
|
| 77 |
+
assert "Qwen3-Coder-Next" in content
|
| 78 |
+
assert "MiniMax-M2.7" in content
|
| 79 |
+
assert "GLM-5.1" in content
|
| 80 |
+
assert "gemini-2.0-flash" in content
|
| 81 |
+
print("✅ Frontend patched: Owl Alpha Openrouter, DeepSeek V4 Pro, Qwen3 Coder Next, MiniMax M2.7, GLM 5.1, Gemini Flash")
|