Restore 5556f90 + add Grok4.3/DeepSeekV4Pro/Qwen3.7Max/Qwen3-HF to dropdown
Browse files- patch_frontend.py +39 -25
patch_frontend.py
CHANGED
|
@@ -1,49 +1,60 @@
|
|
| 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 |
-
# We need to find that closing and insert before it
|
| 10 |
-
|
| 11 |
-
# Look for the pattern: last entry closes with },\n]; before findModelByPath
|
| 12 |
-
import re
|
| 13 |
-
|
| 14 |
-
# Find DEFAULT_MODEL_OPTIONS array end
|
| 15 |
-
# Pattern: find "];" that comes after "avatarUrl: getHfAvatarUrl('deepseek"
|
| 16 |
idx_deepseek = content.find("'deepseek-v4-pro'")
|
| 17 |
if idx_deepseek == -1:
|
| 18 |
-
print("⚠️ Cannot find deepseek-v4-pro entry, trying alternative...")
|
| 19 |
idx_deepseek = content.find("deepseek-ai/DeepSeek-V4")
|
| 20 |
-
|
| 21 |
if idx_deepseek == -1:
|
| 22 |
-
print("❌ Cannot find DeepSeek entry
|
| 23 |
import sys; sys.exit(1)
|
| 24 |
|
| 25 |
-
# Find the next "];" after this entry
|
| 26 |
idx_end = content.find("];", idx_deepseek)
|
| 27 |
if idx_end == -1:
|
| 28 |
print("❌ Cannot find end of array!")
|
| 29 |
import sys; sys.exit(1)
|
| 30 |
|
| 31 |
-
# Insert new models before "];"
|
| 32 |
new_models = """ {
|
| 33 |
-
id: '
|
| 34 |
-
name: '
|
| 35 |
-
description: '
|
| 36 |
-
modelPath: 'openai/
|
| 37 |
-
avatarUrl: 'https://huggingface.co/api/avatars/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
recommended: true,
|
| 39 |
},
|
| 40 |
{
|
| 41 |
-
id: 'qwen3-
|
| 42 |
-
name: '
|
| 43 |
-
description: '
|
| 44 |
-
modelPath: 'openai/qwen/qwen3-
|
| 45 |
avatarUrl: 'https://huggingface.co/api/avatars/Qwen',
|
| 46 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
"""
|
| 48 |
|
| 49 |
content = content[:idx_end] + new_models + content[idx_end:]
|
|
@@ -51,6 +62,9 @@ content = content[:idx_end] + new_models + content[idx_end:]
|
|
| 51 |
with open(FILE, "w") as f:
|
| 52 |
f.write(content)
|
| 53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
assert "gemini-2.0-flash" in content
|
| 55 |
-
|
| 56 |
-
print("✅ Frontend patched: Gemini 2.0 Flash + Qwen3 30B added to dropdown")
|
|
|
|
| 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: 'grok-4.3',
|
| 23 |
+
name: 'Grok 4.3',
|
| 24 |
+
description: 'Tốt nhất giá rẻ · $2/$10 · 1M context',
|
| 25 |
+
modelPath: 'openai/x-ai/grok-4.3',
|
| 26 |
+
avatarUrl: 'https://huggingface.co/api/avatars/xai-org',
|
| 27 |
+
recommended: true,
|
| 28 |
+
},
|
| 29 |
+
{
|
| 30 |
+
id: 'deepseek-v4-pro-or',
|
| 31 |
+
name: 'DeepSeek V4 Pro',
|
| 32 |
+
description: 'Rẻ nhất · $0.5/$2.18 · code quality cực tốt',
|
| 33 |
+
modelPath: 'openai/deepseek/deepseek-v4-pro',
|
| 34 |
+
avatarUrl: 'https://huggingface.co/api/avatars/deepseek-ai',
|
| 35 |
recommended: true,
|
| 36 |
},
|
| 37 |
{
|
| 38 |
+
id: 'qwen3.7-max',
|
| 39 |
+
name: 'Qwen 3.7 Max',
|
| 40 |
+
description: 'Cân bằng · $1/$4 · quality khá',
|
| 41 |
+
modelPath: 'openai/qwen/qwen3.7-max',
|
| 42 |
avatarUrl: 'https://huggingface.co/api/avatars/Qwen',
|
| 43 |
},
|
| 44 |
+
{
|
| 45 |
+
id: 'qwen3-235b-hf',
|
| 46 |
+
name: 'Qwen3 235B (HF Free)',
|
| 47 |
+
description: 'Miễn phí qua HF Inference',
|
| 48 |
+
modelPath: 'Qwen/Qwen3-235B-A22B',
|
| 49 |
+
avatarUrl: 'https://huggingface.co/api/avatars/Qwen',
|
| 50 |
+
},
|
| 51 |
+
{
|
| 52 |
+
id: 'gemini-2.0-flash',
|
| 53 |
+
name: 'Gemini 2.0 Flash',
|
| 54 |
+
description: 'Rẻ · $0.15/$0.60 · nhanh',
|
| 55 |
+
modelPath: 'openai/google/gemini-2.0-flash-001',
|
| 56 |
+
avatarUrl: 'https://huggingface.co/api/avatars/google',
|
| 57 |
+
},
|
| 58 |
"""
|
| 59 |
|
| 60 |
content = content[:idx_end] + new_models + content[idx_end:]
|
|
|
|
| 62 |
with open(FILE, "w") as f:
|
| 63 |
f.write(content)
|
| 64 |
|
| 65 |
+
assert "grok-4.3" in content
|
| 66 |
+
assert "deepseek-v4-pro" in content
|
| 67 |
+
assert "qwen3.7-max" in content
|
| 68 |
+
assert "Qwen3-235B-A22B" in content
|
| 69 |
assert "gemini-2.0-flash" in content
|
| 70 |
+
print("✅ Frontend patched: Grok 4.3, DeepSeek V4 Pro, Qwen 3.7 Max, Qwen3 HF, Gemini Flash added")
|
|
|