Spaces:
Paused
Paused
Upload patch_frontend.py
Browse files- patch_frontend.py +12 -19
patch_frontend.py
CHANGED
|
@@ -1,14 +1,10 @@
|
|
| 1 |
-
"""Patch frontend ChatInput.tsx + model.ts: Remove Owl Alpha, fix Tencent HY3 path,
|
| 2 |
|
| 3 |
-
# === Step 1: Patch model.ts constants
|
| 4 |
MODEL_FILE = "/source/frontend/src/utils/model.ts"
|
| 5 |
with open(MODEL_FILE, "r") as f:
|
| 6 |
model_content = f.read()
|
| 7 |
|
| 8 |
-
# Remove Claude Opus β Owl Alpha replacement β just keep the original Claude path
|
| 9 |
-
# (no replacement needed for CLAUDE_OPUS_48_MODEL_PATH since we're removing it)
|
| 10 |
-
|
| 11 |
-
# Instead, directly set Tencent HY3 path
|
| 12 |
model_content = model_content.replace(
|
| 13 |
"export const KIMI_K27_CODE_MODEL_PATH = 'moonshotai/Kimi-K2.7-Code:novita';",
|
| 14 |
"export const KIMI_K27_CODE_MODEL_PATH = 'deepseek-ai/DeepSeek-V4-Pro';"
|
|
@@ -26,14 +22,11 @@ model_content = model_content.replace(
|
|
| 26 |
"export const DEEPSEEK_V4_PRO_MODEL_PATH = 'nvidia/nemotron-3-super-120b-a12b:free';"
|
| 27 |
)
|
| 28 |
|
| 29 |
-
# Remove isClaudePath β isOpenrouterPath change (revert to original)
|
| 30 |
-
# We keep the original isClaudePath function checking for 'anthropic'
|
| 31 |
-
|
| 32 |
with open(MODEL_FILE, "w") as f:
|
| 33 |
f.write(model_content)
|
| 34 |
-
print("β
model.ts constants updated
|
| 35 |
|
| 36 |
-
# === Step 2: Patch ChatInput.tsx
|
| 37 |
FILE = "/source/frontend/src/components/Chat/ChatInput.tsx"
|
| 38 |
with open(FILE, "r") as f:
|
| 39 |
content = f.read()
|
|
@@ -50,7 +43,7 @@ content = content.replace('"Kimi K2.7 Code"', '"DeepSeek V4 Pro"')
|
|
| 50 |
content = content.replace("'MiniMax M3'", "'DeepSeek V4 Flash'")
|
| 51 |
content = content.replace('"MiniMax M3"', '"DeepSeek V4 Flash"')
|
| 52 |
|
| 53 |
-
# Row 5: GLM 5.2 β DeepSeek V4 Flash
|
| 54 |
content = content.replace("'GLM 5.2'", "'DeepSeek V4 Flash'")
|
| 55 |
content = content.replace('"GLM 5.2"', '"DeepSeek V4 Flash"')
|
| 56 |
|
|
@@ -60,7 +53,7 @@ content = content.replace(
|
|
| 60 |
" {\n id: 'nemotron-120b',\n name: 'nvidia/nemotron-3-super-120b-a12b:free',\n modelPath: DEEPSEEK_V4_PRO_MODEL_PATH,\n avatarUrl: 'https://huggingface.co/api/avatars/nvidia',\n },"
|
| 61 |
)
|
| 62 |
|
| 63 |
-
# Remove old Tencent HY3 entry
|
| 64 |
old_tencent_block = """ {
|
| 65 |
id: 'tencent-hy3',
|
| 66 |
name: 'Tencent HY3',
|
|
@@ -69,7 +62,7 @@ old_tencent_block = """ {
|
|
| 69 |
},"""
|
| 70 |
content = content.replace(old_tencent_block, "")
|
| 71 |
|
| 72 |
-
# === Add
|
| 73 |
idx_end = content.find("];", content.find("DEFAULT_MODEL_OPTIONS") if "DEFAULT_MODEL_OPTIONS" in content else 0)
|
| 74 |
if idx_end == -1:
|
| 75 |
idx_end = content.rfind("];", 0, content.find("export") if "export" in content else len(content))
|
|
@@ -77,15 +70,15 @@ if idx_end == -1:
|
|
| 77 |
if idx_end > 0:
|
| 78 |
new_models = """ {
|
| 79 |
id: 'gemma-4-31b',
|
| 80 |
-
name: 'Gemma 4 31B',
|
| 81 |
-
modelPath: 'google/gemma-4-
|
| 82 |
avatarUrl: 'https://huggingface.co/api/avatars/google',
|
| 83 |
recommended: true,
|
| 84 |
},
|
| 85 |
{
|
| 86 |
id: 'tencent-hy3',
|
| 87 |
-
name: 'Tencent HY3',
|
| 88 |
-
modelPath: 'tencent/hy3',
|
| 89 |
avatarUrl: 'https://huggingface.co/api/avatars/tencent',
|
| 90 |
recommended: true,
|
| 91 |
},
|
|
@@ -122,4 +115,4 @@ print(" Row 3 (Kimi): DeepSeek V4 Pro")
|
|
| 122 |
print(" Row 4 (MiniMax): DeepSeek V4 Flash")
|
| 123 |
print(" Row 5 (GLM): DeepSeek V4 Flash (OR)")
|
| 124 |
print(" Row 6 (DeepSeek): nvidia/nemotron-3-super-120b-a12b:free")
|
| 125 |
-
print(" NEW: Gemma 4 31B, Tencent HY3 (DEFAULT), Gemma 3 1B, Qwen3 Coder Next, Gemini 2.0 Flash")
|
|
|
|
| 1 |
+
"""Patch frontend ChatInput.tsx + model.ts: Remove Owl Alpha, fix Tencent HY3 path, add Gemma 4:free."""
|
| 2 |
|
| 3 |
+
# === Step 1: Patch model.ts constants ===
|
| 4 |
MODEL_FILE = "/source/frontend/src/utils/model.ts"
|
| 5 |
with open(MODEL_FILE, "r") as f:
|
| 6 |
model_content = f.read()
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
model_content = model_content.replace(
|
| 9 |
"export const KIMI_K27_CODE_MODEL_PATH = 'moonshotai/Kimi-K2.7-Code:novita';",
|
| 10 |
"export const KIMI_K27_CODE_MODEL_PATH = 'deepseek-ai/DeepSeek-V4-Pro';"
|
|
|
|
| 22 |
"export const DEEPSEEK_V4_PRO_MODEL_PATH = 'nvidia/nemotron-3-super-120b-a12b:free';"
|
| 23 |
)
|
| 24 |
|
|
|
|
|
|
|
|
|
|
| 25 |
with open(MODEL_FILE, "w") as f:
|
| 26 |
f.write(model_content)
|
| 27 |
+
print("β
model.ts constants updated")
|
| 28 |
|
| 29 |
+
# === Step 2: Patch ChatInput.tsx ===
|
| 30 |
FILE = "/source/frontend/src/components/Chat/ChatInput.tsx"
|
| 31 |
with open(FILE, "r") as f:
|
| 32 |
content = f.read()
|
|
|
|
| 43 |
content = content.replace("'MiniMax M3'", "'DeepSeek V4 Flash'")
|
| 44 |
content = content.replace('"MiniMax M3"', '"DeepSeek V4 Flash"')
|
| 45 |
|
| 46 |
+
# Row 5: GLM 5.2 β DeepSeek V4 Flash
|
| 47 |
content = content.replace("'GLM 5.2'", "'DeepSeek V4 Flash'")
|
| 48 |
content = content.replace('"GLM 5.2"', '"DeepSeek V4 Flash"')
|
| 49 |
|
|
|
|
| 53 |
" {\n id: 'nemotron-120b',\n name: 'nvidia/nemotron-3-super-120b-a12b:free',\n modelPath: DEEPSEEK_V4_PRO_MODEL_PATH,\n avatarUrl: 'https://huggingface.co/api/avatars/nvidia',\n },"
|
| 54 |
)
|
| 55 |
|
| 56 |
+
# Remove old Tencent HY3 entry if present
|
| 57 |
old_tencent_block = """ {
|
| 58 |
id: 'tencent-hy3',
|
| 59 |
name: 'Tencent HY3',
|
|
|
|
| 62 |
},"""
|
| 63 |
content = content.replace(old_tencent_block, "")
|
| 64 |
|
| 65 |
+
# === Add models at end of DEFAULT_MODEL_OPTIONS array ===
|
| 66 |
idx_end = content.find("];", content.find("DEFAULT_MODEL_OPTIONS") if "DEFAULT_MODEL_OPTIONS" in content else 0)
|
| 67 |
if idx_end == -1:
|
| 68 |
idx_end = content.rfind("];", 0, content.find("export") if "export" in content else len(content))
|
|
|
|
| 70 |
if idx_end > 0:
|
| 71 |
new_models = """ {
|
| 72 |
id: 'gemma-4-31b',
|
| 73 |
+
name: 'Gemma 4 31B:free',
|
| 74 |
+
modelPath: 'google/gemma-4-31b-it:free',
|
| 75 |
avatarUrl: 'https://huggingface.co/api/avatars/google',
|
| 76 |
recommended: true,
|
| 77 |
},
|
| 78 |
{
|
| 79 |
id: 'tencent-hy3',
|
| 80 |
+
name: 'Tencent HY3:free',
|
| 81 |
+
modelPath: 'tencent/hy3:free',
|
| 82 |
avatarUrl: 'https://huggingface.co/api/avatars/tencent',
|
| 83 |
recommended: true,
|
| 84 |
},
|
|
|
|
| 115 |
print(" Row 4 (MiniMax): DeepSeek V4 Flash")
|
| 116 |
print(" Row 5 (GLM): DeepSeek V4 Flash (OR)")
|
| 117 |
print(" Row 6 (DeepSeek): nvidia/nemotron-3-super-120b-a12b:free")
|
| 118 |
+
print(" NEW: Gemma 4 31B:free, Tencent HY3:free (DEFAULT), Gemma 3 1B, Qwen3 Coder Next, Gemini 2.0 Flash")
|