Spaces:
Paused
Paused
Add frontend patch script to inject Gemini+Qwen3 into ChatInput.tsx
Browse files- patch_frontend.py +64 -0
patch_frontend.py
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Patch frontend ChatInput.tsx to add Gemini 2.0 Flash + Qwen3 30B to model 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 |
+
# Find the closing of DEFAULT_MODEL_OPTIONS array and add new models before it
|
| 9 |
+
# The array ends with "];" after the last model object
|
| 10 |
+
|
| 11 |
+
new_models = """ {
|
| 12 |
+
id: 'gemini-2.0-flash',
|
| 13 |
+
name: 'Gemini 2.0 Flash',
|
| 14 |
+
description: 'OpenRouter',
|
| 15 |
+
modelPath: 'openai/google/gemini-2.0-flash-001',
|
| 16 |
+
avatarUrl: 'https://huggingface.co/api/avatars/google',
|
| 17 |
+
recommended: true,
|
| 18 |
+
},
|
| 19 |
+
{
|
| 20 |
+
id: 'qwen3-30b',
|
| 21 |
+
name: 'Qwen3 30B',
|
| 22 |
+
description: 'OpenRouter',
|
| 23 |
+
modelPath: 'openai/qwen/qwen3-30b-a3b',
|
| 24 |
+
avatarUrl: 'https://huggingface.co/api/avatars/Qwen',
|
| 25 |
+
},
|
| 26 |
+
"""
|
| 27 |
+
|
| 28 |
+
# Insert before the closing "];" of DEFAULT_MODEL_OPTIONS
|
| 29 |
+
# Find the last "},\n];" pattern in the array
|
| 30 |
+
target = """ },
|
| 31 |
+
];
|
| 32 |
+
|
| 33 |
+
const findModelByPath"""
|
| 34 |
+
|
| 35 |
+
replacement = """ },
|
| 36 |
+
""" + new_models + """];
|
| 37 |
+
|
| 38 |
+
const findModelByPath"""
|
| 39 |
+
|
| 40 |
+
if target in content:
|
| 41 |
+
content = content.replace(target, replacement)
|
| 42 |
+
print("✅ Added Gemini 2.0 Flash + Qwen3 30B to frontend dropdown")
|
| 43 |
+
else:
|
| 44 |
+
# Try alternative pattern
|
| 45 |
+
target2 = "}\n];\n\nconst findModelByPath"
|
| 46 |
+
if target2 in content:
|
| 47 |
+
content = content.replace(target2, "}\n" + new_models + "];\n\nconst findModelByPath")
|
| 48 |
+
print("✅ Added models (alt pattern)")
|
| 49 |
+
else:
|
| 50 |
+
print("❌ Could not find insertion point!")
|
| 51 |
+
print("Looking for pattern near DEFAULT_MODEL_OPTIONS end...")
|
| 52 |
+
idx = content.find("DEFAULT_MODEL_OPTIONS")
|
| 53 |
+
end_idx = content.find("];", idx)
|
| 54 |
+
print(f" Array starts at {idx}, ends at {end_idx}")
|
| 55 |
+
print(f" Content near end: {repr(content[end_idx-50:end_idx+10])}")
|
| 56 |
+
import sys; sys.exit(1)
|
| 57 |
+
|
| 58 |
+
with open(FILE, "w") as f:
|
| 59 |
+
f.write(content)
|
| 60 |
+
|
| 61 |
+
# Verify
|
| 62 |
+
assert "gemini-2.0-flash" in content
|
| 63 |
+
assert "qwen3-30b" in content
|
| 64 |
+
print("✅ Frontend patch complete")
|