bep40 commited on
Commit
9fca8b2
Β·
verified Β·
1 Parent(s): 07e9eb8

Upload patch_frontend.py

Browse files
Files changed (1) hide show
  1. patch_frontend.py +83 -59
patch_frontend.py CHANGED
@@ -1,10 +1,12 @@
1
  """Patch frontend ChatInput.tsx: Replace entire DEFAULT_MODEL_OPTIONS array.
2
 
3
- OpenRouter model routing:
4
- - Owl Alpha: openai/openrouter/owl-alpha (no :free β€” free by default on OpenRouter)
5
- - Gemini 2.0 Flash: openai/google/gemini-2.0-flash-001 (paid, no :free)
6
- - All other OpenRouter free models: need :free suffix
7
- - HF Inference models: bare model ID (no openai/ prefix, no suffix)
 
 
8
  """
9
 
10
  FILE = "/source/frontend/src/components/Chat/ChatInput.tsx"
@@ -25,52 +27,63 @@ if old_import in content:
25
  content = content.replace(old_import, new_import)
26
  print("βœ… Fixed imports")
27
  else:
28
- print("⚠ Import line not found!")
29
- # Try alternative format
30
- alt_import = """import { CLAUDE_OPUS_48_MODEL_PATH, GPT_55_MODEL_PATH, KIMI_K26_MODEL_PATH, isClaudePath } from '@/utils/model';"""
31
  if alt_import in content:
32
- content = content.replace(alt_import, new_import)
33
- print("βœ… Fixed imports (alt format)")
 
 
 
 
 
 
 
34
 
35
  # === Step 2: Replace DEFAULT_MODEL_OPTIONS array ===
36
  marker = "const DEFAULT_MODEL_OPTIONS: ModelOption[] = ["
37
  start = content.find(marker)
38
  if start < 0:
39
  print("❌ DEFAULT_MODEL_OPTIONS not found!")
40
- # Try to find where the array starts
41
- alt_marker = "DEFAULT_MODEL_OPTIONS"
42
- alt_start = content.find(alt_marker)
43
- if alt_start >= 0:
44
- print(f"Found DEFAULT_MODEL_OPTIONS at pos {alt_start}")
45
- # Print surrounding characters
46
- print(repr(content[alt_start:alt_start+200]))
47
  raise SystemExit(1)
48
 
 
49
  end = content.find("];", start)
50
  if end < 0:
51
  print("❌ Array closing ] not found!")
52
  raise SystemExit(1)
53
- end += 2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
 
55
  new_array = """const DEFAULT_MODEL_OPTIONS: ModelOption[] = [
56
- {
57
- id: 'owl-alpha',
58
- name: 'Owl Alpha',
59
- modelPath: 'openai/openrouter/owl-alpha',
60
- avatarUrl: 'https://huggingface.co/api/avatars/openrouter',
61
- recommended: true,
62
- },
63
- {
64
- id: 'gpt-5.5',
65
- name: 'GPT-5.5',
66
- modelPath: 'openai/gpt-5.5:fal-ai',
67
- avatarUrl: 'https://huggingface.co/api/avatars/openai',
68
- },
69
  {
70
  id: 'deepseek-v4-pro',
71
  name: 'DeepSeek V4 Pro',
72
  modelPath: 'deepseek-ai/DeepSeek-V4-Pro',
73
  avatarUrl: 'https://huggingface.co/api/avatars/deepseek-ai',
 
74
  },
75
  {
76
  id: 'deepseek-v4-flash',
@@ -79,16 +92,17 @@ new_array = """const DEFAULT_MODEL_OPTIONS: ModelOption[] = [
79
  avatarUrl: 'https://huggingface.co/api/avatars/deepseek-ai',
80
  },
81
  {
82
- id: 'deepseek-v4-flash-or',
83
- name: 'DeepSeek V4 Flash (OR)',
84
- modelPath: 'openai/deepseek/deepseek-v4-flash:free',
85
- avatarUrl: 'https://huggingface.co/api/avatars/deepseek-ai',
86
  },
87
  {
88
- id: 'nemotron-120b',
89
- name: 'Nemotron 3 Super 120B',
90
- modelPath: 'openai/nvidia/nemotron-3-super-120b-a12b:free',
91
- avatarUrl: 'https://huggingface.co/api/avatars/nvidia',
 
92
  },
93
  {
94
  id: 'gemma-3-1b',
@@ -97,19 +111,25 @@ new_array = """const DEFAULT_MODEL_OPTIONS: ModelOption[] = [
97
  avatarUrl: 'https://huggingface.co/api/avatars/google',
98
  recommended: true,
99
  },
100
- {
101
- id: 'qwen3-coder-next',
102
- name: 'Qwen3 Coder Next',
103
- modelPath: 'Qwen/Qwen3-Coder-Next',
104
- avatarUrl: 'https://huggingface.co/api/avatars/Qwen',
105
- recommended: true,
106
- },
107
  {
108
  id: 'gemini-2.0-flash',
109
  name: 'Gemini 2.0 Flash',
110
  modelPath: 'openai/google/gemini-2.0-flash-001',
111
  avatarUrl: 'https://huggingface.co/api/avatars/google',
112
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  {
114
  id: 'gemma-4-31b',
115
  name: 'Gemma 4 31B',
@@ -117,6 +137,12 @@ new_array = """const DEFAULT_MODEL_OPTIONS: ModelOption[] = [
117
  avatarUrl: 'https://huggingface.co/api/avatars/google',
118
  recommended: true,
119
  },
 
 
 
 
 
 
120
  {
121
  id: 'nemotron-3-ultra',
122
  name: 'Nemotron 3 Ultra 550B',
@@ -142,22 +168,20 @@ new_array = """const DEFAULT_MODEL_OPTIONS: ModelOption[] = [
142
  content = content[:start] + new_array + content[end:]
143
 
144
  # === Step 3: DEFAULT_FREE_MODEL_OPTION_ID ===
145
- if "DEFAULT_FREE_MODEL_OPTION_ID = 'kimi-k2.6'" in content:
146
- content = content.replace(
147
- "DEFAULT_FREE_MODEL_OPTION_ID = 'kimi-k2.6'",
148
- "DEFAULT_FREE_MODEL_OPTION_ID = 'deepseek-v4-pro'",
149
- )
150
  print("βœ… Set default free model to DeepSeek V4 Pro")
151
  elif "DEFAULT_FREE_MODEL_OPTION_ID" in content:
152
- print("⚠ Found DEFAULT_FREE_MODEL_OPTION_ID but not with kimi-k2.6 value")
153
- else:
154
- print("⚠ DEFAULT_FREE_MODEL_OPTION_ID not found!")
155
 
156
  with open(FILE, "w") as f:
157
  f.write(content)
158
 
159
- print("βœ… Frontend patched β€” 13 models, Owl Alpha has NO :free suffix")
160
- print(" Models: Owl Alpha, GPT-5.5, DeepSeek V4 Pro, DeepSeek V4 Flash,")
161
- print(" DeepSeek V4 Flash (OR), Nemotron 3 Super 120B, Gemma 3 1B,")
162
- print(" Qwen3 Coder Next, Gemini 2.0 Flash, Gemma 4 31B,")
163
- print(" Nemotron 3 Ultra 550B, Laguna M.1, Laguna XS.2")
 
1
  """Patch frontend ChatInput.tsx: Replace entire DEFAULT_MODEL_OPTIONS array.
2
 
3
+ OpenRouter model routing on backend:
4
+ - Models with openai/google/, openai/deepseek/, openai/nvidia/, openai/poolside/ β†’ OpenRouter
5
+ - Models starting with openai/openrouter/ β†’ OpenRouter
6
+ - All others β†’ HF Inference Router
7
+
8
+ Owl Alpha removed (provider Stealth broken on OpenRouter).
9
+ Replaced with Gemma 4 9B (free, reliable on OpenRouter).
10
  """
11
 
12
  FILE = "/source/frontend/src/components/Chat/ChatInput.tsx"
 
27
  content = content.replace(old_import, new_import)
28
  print("βœ… Fixed imports")
29
  else:
30
+ # Try single-line format
31
+ alt_import = "import { CLAUDE_OPUS_48_MODEL_PATH, GPT_55_MODEL_PATH, KIMI_K26_MODEL_PATH, isClaudePath } from '@/utils/model';"
 
32
  if alt_import in content:
33
+ content = content.replace(alt_import, "import { isClaudePath } from '@/utils/model';")
34
+ print("βœ… Fixed imports (single-line)")
35
+ else:
36
+ print("⚠ Could not find import line, checking if already patched...")
37
+ if "import { isClaudePath } from '@/utils/model'" in content:
38
+ print(" Already patched, skipping")
39
+ else:
40
+ print("❌ Import line not found!")
41
+ raise SystemExit(1)
42
 
43
  # === Step 2: Replace DEFAULT_MODEL_OPTIONS array ===
44
  marker = "const DEFAULT_MODEL_OPTIONS: ModelOption[] = ["
45
  start = content.find(marker)
46
  if start < 0:
47
  print("❌ DEFAULT_MODEL_OPTIONS not found!")
48
+ # Debug: find the actual position
49
+ alt = content.find("DEFAULT_MODEL_OPTIONS")
50
+ if alt >= 0:
51
+ print(f" Found 'DEFAULT_MODEL_OPTIONS' at pos {alt}")
52
+ print(f" Context: {repr(content[alt:alt+150])}")
 
 
53
  raise SystemExit(1)
54
 
55
+ # Find the end of the array by counting brackets
56
  end = content.find("];", start)
57
  if end < 0:
58
  print("❌ Array closing ] not found!")
59
  raise SystemExit(1)
60
+
61
+ # Validate we found the right ] by looking for the pattern
62
+ check_segment = content[start:end]
63
+ if "];" in check_segment:
64
+ # There might be nested arrays - find the outermost ]
65
+ depth = 0
66
+ for i, ch in enumerate(content[start:], start):
67
+ if ch == '[':
68
+ depth += 1
69
+ elif ch == ']':
70
+ depth -= 1
71
+ if depth == 0:
72
+ end = i + 1 # include the ;
73
+ # look for ; after ]
74
+ if end < len(content) and content[end] == ';':
75
+ end += 1
76
+ break
77
+ else:
78
+ end = end + 2
79
 
80
  new_array = """const DEFAULT_MODEL_OPTIONS: ModelOption[] = [
 
 
 
 
 
 
 
 
 
 
 
 
 
81
  {
82
  id: 'deepseek-v4-pro',
83
  name: 'DeepSeek V4 Pro',
84
  modelPath: 'deepseek-ai/DeepSeek-V4-Pro',
85
  avatarUrl: 'https://huggingface.co/api/avatars/deepseek-ai',
86
+ recommended: true,
87
  },
88
  {
89
  id: 'deepseek-v4-flash',
 
92
  avatarUrl: 'https://huggingface.co/api/avatars/deepseek-ai',
93
  },
94
  {
95
+ id: 'gpt-5.5',
96
+ name: 'GPT-5.5',
97
+ modelPath: 'openai/gpt-5.5:fal-ai',
98
+ avatarUrl: 'https://huggingface.co/api/avatars/openai',
99
  },
100
  {
101
+ id: 'qwen3-coder-next',
102
+ name: 'Qwen3 Coder Next',
103
+ modelPath: 'Qwen/Qwen3-Coder-Next',
104
+ avatarUrl: 'https://huggingface.co/api/avatars/Qwen',
105
+ recommended: true,
106
  },
107
  {
108
  id: 'gemma-3-1b',
 
111
  avatarUrl: 'https://huggingface.co/api/avatars/google',
112
  recommended: true,
113
  },
 
 
 
 
 
 
 
114
  {
115
  id: 'gemini-2.0-flash',
116
  name: 'Gemini 2.0 Flash',
117
  modelPath: 'openai/google/gemini-2.0-flash-001',
118
  avatarUrl: 'https://huggingface.co/api/avatars/google',
119
  },
120
+ {
121
+ id: 'deepseek-v4-flash-or',
122
+ name: 'DeepSeek V4 Flash (OR)',
123
+ modelPath: 'openai/deepseek/deepseek-v4-flash:free',
124
+ avatarUrl: 'https://huggingface.co/api/avatars/deepseek-ai',
125
+ },
126
+ {
127
+ id: 'gemma-4-9b',
128
+ name: 'Gemma 4 9B',
129
+ modelPath: 'openai/google/gemma-4-9b-it:free',
130
+ avatarUrl: 'https://huggingface.co/api/avatars/google',
131
+ recommended: true,
132
+ },
133
  {
134
  id: 'gemma-4-31b',
135
  name: 'Gemma 4 31B',
 
137
  avatarUrl: 'https://huggingface.co/api/avatars/google',
138
  recommended: true,
139
  },
140
+ {
141
+ id: 'nemotron-120b',
142
+ name: 'Nemotron 3 Super 120B',
143
+ modelPath: 'openai/nvidia/nemotron-3-super-120b-a12b:free',
144
+ avatarUrl: 'https://huggingface.co/api/avatars/nvidia',
145
+ },
146
  {
147
  id: 'nemotron-3-ultra',
148
  name: 'Nemotron 3 Ultra 550B',
 
168
  content = content[:start] + new_array + content[end:]
169
 
170
  # === Step 3: DEFAULT_FREE_MODEL_OPTION_ID ===
171
+ old_free = "DEFAULT_FREE_MODEL_OPTION_ID = 'kimi-k2.6'"
172
+ new_free = "DEFAULT_FREE_MODEL_OPTION_ID = 'deepseek-v4-pro'"
173
+ if old_free in content:
174
+ content = content.replace(old_free, new_free)
 
175
  print("βœ… Set default free model to DeepSeek V4 Pro")
176
  elif "DEFAULT_FREE_MODEL_OPTION_ID" in content:
177
+ print("⚠ DEFAULT_FREE_MODEL_OPTION_ID found, checking value...")
178
+ idx = content.find("DEFAULT_FREE_MODEL_OPTION_ID")
179
+ print(f" Context: {repr(content[idx:idx+80])}")
180
 
181
  with open(FILE, "w") as f:
182
  f.write(content)
183
 
184
+ print("βœ… Frontend patched β€” 13 models")
185
+ print(" Owl Alpha REMOVED (Stealth provider broken)")
186
+ print(" Replaced with: Gemma 4 9B (OpenRouter free)")
187
+ print(" Default: DeepSeek V4 Pro")