bep40 commited on
Commit
ad34d68
·
verified ·
1 Parent(s): 402e315

Restore 0c286f8: patch_frontend.py

Browse files
Files changed (1) hide show
  1. patch_frontend.py +29 -38
patch_frontend.py CHANGED
@@ -1,79 +1,70 @@
1
- """Patch frontend: ONLY add new models to end of array. Do NOT remove or modify existing entries."""
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 DEFAULT_MODEL_OPTIONS array end by counting brackets
9
- arr_start = content.find("const DEFAULT_MODEL_OPTIONS")
10
- if arr_start == -1:
11
- print("❌ DEFAULT_MODEL_OPTIONS not found!")
 
 
12
  import sys; sys.exit(1)
13
 
14
- # Find opening [
15
- bracket_start = content.find("[", arr_start)
16
- # Find matching ]
17
- idx = bracket_start + 1
18
- depth = 1
19
- while idx < len(content) and depth > 0:
20
- if content[idx] == '[':
21
- depth += 1
22
- elif content[idx] == ']':
23
- depth -= 1
24
- idx += 1
25
- arr_end = idx - 1 # position of closing ]
26
 
27
- # Insert new models just before ]
28
  new_models = """ {
29
- id: 'deepseek-v3-or',
30
- name: 'DeepSeek V3',
31
- description: 'OpenRouter · Mặc định',
32
- modelPath: 'openai/deepseek/deepseek-chat-v3-0324',
33
- avatarUrl: getHfAvatarUrl('deepseek-ai/DeepSeek-V3'),
34
- recommended: true,
35
- },
36
- {
37
  id: 'grok-4.3',
38
  name: 'Grok 4.3',
39
- description: 'Tốt nhất giá rẻ · $2/$10 · 1M ctx',
40
  modelPath: 'openai/x-ai/grok-4.3',
41
- avatarUrl: getHfAvatarUrl('xai-org/grok'),
42
  recommended: true,
43
  },
44
  {
45
  id: 'deepseek-v4-pro-or',
46
  name: 'DeepSeek V4 Pro',
47
- description: 'Rẻ nhất · $0.5/$2.18',
48
  modelPath: 'openai/deepseek/deepseek-v4-pro',
49
- avatarUrl: getHfAvatarUrl('deepseek-ai/DeepSeek-V4'),
 
50
  },
51
  {
52
  id: 'qwen3.7-max',
53
  name: 'Qwen 3.7 Max',
54
- description: 'Cân bằng · $1/$4',
55
  modelPath: 'openai/qwen/qwen3.7-max',
56
- avatarUrl: getHfAvatarUrl('Qwen/Qwen3'),
57
  },
58
  {
59
  id: 'qwen3-235b-hf',
60
  name: 'Qwen3 235B (HF Free)',
61
- description: 'Miễn phí HF Inference',
62
  modelPath: 'Qwen/Qwen3-235B-A22B',
63
- avatarUrl: getHfAvatarUrl('Qwen/Qwen3-235B-A22B'),
64
  },
65
  {
66
  id: 'gemini-2.0-flash',
67
  name: 'Gemini 2.0 Flash',
68
- description: 'Rẻ nhanh · $0.15/$0.60',
69
  modelPath: 'openai/google/gemini-2.0-flash-001',
70
- avatarUrl: getHfAvatarUrl('google/gemini'),
71
  },
72
  """
73
 
74
- content = content[:arr_end] + new_models + content[arr_end:]
75
 
76
  with open(FILE, "w") as f:
77
  f.write(content)
78
 
79
- print("✅ Added 6 new models to dropdown (existing entries untouched)")
 
 
 
 
 
 
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:]
61
 
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")