bep40 commited on
Commit
362b9e1
·
verified ·
1 Parent(s): cd5342c

Fix syntax error in patch_models.py - unclosed string

Browse files
Files changed (1) hide show
  1. patch_models.py +33 -93
patch_models.py CHANGED
@@ -72,7 +72,7 @@ content = content.replace(old_hosted, new_hosted)
72
 
73
  with open(IDS_FILE, "w") as f:
74
  f.write(content)
75
- print("OK: model_ids.py patched (Nex N2 + Ling 3.0 Flash added)")
76
 
77
  # === Step 2: Patch agent.py ===
78
  with open(AGENT_FILE) as f:
@@ -118,109 +118,49 @@ new_import = (
118
  )
119
  content = content.replace(old_import, new_import)
120
 
121
- new_func = '''def _available_models() -> list[dict[str, Any]]:
122
- models = [
123
- {
124
- "id": TENCENT_HY3_FREE_MODEL_ID,
125
- "label": "Tencent HY3:free",
126
- "recommended": True,
127
- },
128
- {
129
- "id": GEMMA_4_31B_FREE_MODEL_ID,
130
- "label": "Gemma 4 31B:free",
131
- "recommended": True,
132
- },
133
- {
134
- "id": LLAMA_3_3_70B_FREE_MODEL_ID,
135
- "label": "Llama 3.3 70B:free",
136
- "recommended": True,
137
- },
138
- {
139
- "id": LAGUNA_M1_FREE_MODEL_ID,
140
- "label": "Laguna M.1:free",
141
- "recommended": True,
142
- },
143
- {
144
- "id": DEFAULT_GPT_MODEL_ID,
145
- "label": "Laguna S 2.1:free",
146
- "recommended": True,
147
- },
148
- {
149
- "id": NEX_N2_MINI_MODEL_ID,
150
- "label": "nex-agi/nex-n2-mini",
151
- "recommended": True,
152
- },
153
- {
154
- "id": LING_3_0_FLASH_FREE_MODEL_ID,
155
- "label": "inclusionai/ling-3.0-flash:free",
156
- "recommended": True,
157
- },
158
- {
159
- "id": LLAMA_3_1_8B_MODEL_ID,
160
- "label": "Llama 3.1 8B",
161
- },
162
- {
163
- "id": KIMI_K27_CODE_MODEL_ID,
164
- "label": "DeepSeek V4 Pro",
165
- },
166
- {
167
- "id": MINIMAX_M3_MODEL_ID,
168
- "label": "DeepSeek V4 Flash",
169
- },
170
- {
171
- "id": DEFAULT_MODEL_ID,
172
- "label": "DeepSeek V4 Flash",
173
- },
174
- {
175
- "id": DEEPSEEK_V4_PRO_MODEL_ID,
176
- "label": "Nemotron 3 Super 120B",
177
- },
178
- ]
179
- return models'''
180
 
181
  func_pattern = re.compile(
182
- r'def _available_models\(\) -> list\[dict\[str, Any\]\]:\s*\n'
183
- r'\s+models\s*=\s*\[.*?\]\s*\n\s+return models',
184
  re.DOTALL
185
  )
186
 
187
  func_match = func_pattern.search(content)
188
  if func_match:
189
- content = content[:func_match.start()] + new_func + content[func_match.end():]
190
  print("OK: Replaced _available_models()")
191
  else:
192
  old_available = (
193
- 'def _available_models() -> list[dict[str, Any]]:\n'
194
- ' models = [\n'
195
- ' {\n'
196
- ' "id": CLAUDE_OPUS_48_MODEL_ID,\n'
197
- ' "label": "Claude Opus 4.8",\n'
198
- ' },\n'
199
- ' {\n'
200
- ' "id": DEFAULT_GPT_MODEL_ID,\n'
201
- ' "label": "GPT-5.5",\n'
202
- ' },\n'
203
- ' {\n'
204
- ' "id": KIMI_K27_CODE_MODEL_ID,\n'
205
- ' "label": "Kimi K2.7 Code",\n'
206
- ' },\n'
207
- ' {\n'
208
- ' "id": MINIMAX_M3_MODEL_ID,\n'
209
- ' "label": "MiniMax M3",\n'
210
- ' },\n'
211
- ' {\n'
212
- ' "id": DEFAULT_MODEL_ID,\n'
213
- ' "label": "GLM 5.2",\n'
214
- ' "recommended": True,\n'
215
- ' },\n'
216
- ' {\n'
217
- ' "id": DEEPSEEK_V4_PRO_MODEL_ID,\n'
218
- ' "label": "DeepSeek V4 Pro",\n'
219
- ' },\n'
220
- ' ]\n'
221
- ' return models'
222
  if old_available in content:
223
- content = content.replace(old_available, new_func)
224
  print("OK: String replace worked")
225
  else:
226
  print("FAIL: Cannot find _available_models()!")
 
72
 
73
  with open(IDS_FILE, "w") as f:
74
  f.write(content)
75
+ print("OK: model_ids.py patched")
76
 
77
  # === Step 2: Patch agent.py ===
78
  with open(AGENT_FILE) as f:
 
118
  )
119
  content = content.replace(old_import, new_import)
120
 
121
+ NEW_FUNC = (
122
+ "def _available_models() -> list[dict[str, Any]]:\n"
123
+ " models = [\n"
124
+ ' {\n "id": TENCENT_HY3_FREE_MODEL_ID,\n "label": "Tencent HY3:free",\n "recommended": True,\n },\n'
125
+ ' {\n "id": GEMMA_4_31B_FREE_MODEL_ID,\n "label": "Gemma 4 31B:free",\n "recommended": True,\n },\n'
126
+ ' {\n "id": LLAMA_3_3_70B_FREE_MODEL_ID,\n "label": "Llama 3.3 70B:free",\n "recommended": True,\n },\n'
127
+ ' {\n "id": LAGUNA_M1_FREE_MODEL_ID,\n "label": "Laguna M.1:free",\n "recommended": True,\n },\n'
128
+ ' {\n "id": DEFAULT_GPT_MODEL_ID,\n "label": "Laguna S 2.1:free",\n "recommended": True,\n },\n'
129
+ ' {\n "id": NEX_N2_MINI_MODEL_ID,\n "label": "nex-agi/nex-n2-mini",\n "recommended": True,\n },\n'
130
+ ' {\n "id": LING_3_0_FLASH_FREE_MODEL_ID,\n "label": "inclusionai/ling-3.0-flash:free",\n "recommended": True,\n },\n'
131
+ ' {\n "id": LLAMA_3_1_8B_MODEL_ID,\n "label": "Llama 3.1 8B",\n },\n'
132
+ ' {\n "id": KIMI_K27_CODE_MODEL_ID,\n "label": "DeepSeek V4 Pro",\n },\n'
133
+ ' {\n "id": MINIMAX_M3_MODEL_ID,\n "label": "DeepSeek V4 Flash",\n },\n'
134
+ ' {\n "id": DEFAULT_MODEL_ID,\n "label": "DeepSeek V4 Flash",\n },\n'
135
+ ' {\n "id": DEEPSEEK_V4_PRO_MODEL_ID,\n "label": "Nemotron 3 Super 120B",\n },\n'
136
+ " ]\n"
137
+ " return models"
138
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
 
140
  func_pattern = re.compile(
141
+ r'def _available_models\(\) -> list\[dict\[str, Any\]\]:.*?return models',
 
142
  re.DOTALL
143
  )
144
 
145
  func_match = func_pattern.search(content)
146
  if func_match:
147
+ content = content[:func_match.start()] + NEW_FUNC + content[func_match.end():]
148
  print("OK: Replaced _available_models()")
149
  else:
150
  old_available = (
151
+ "def _available_models() -> list[dict[str, Any]]:\n"
152
+ " models = [\n"
153
+ ' {\n "id": CLAUDE_OPUS_48_MODEL_ID,\n "label": "Claude Opus 4.8",\n },\n'
154
+ ' {\n "id": DEFAULT_GPT_MODEL_ID,\n "label": "GPT-5.5",\n },\n'
155
+ ' {\n "id": KIMI_K27_CODE_MODEL_ID,\n "label": "Kimi K2.7 Code",\n },\n'
156
+ ' {\n "id": MINIMAX_M3_MODEL_ID,\n "label": "MiniMax M3",\n },\n'
157
+ ' {\n "id": DEFAULT_MODEL_ID,\n "label": "GLM 5.2",\n "recommended": True,\n },\n'
158
+ ' {\n "id": DEEPSEEK_V4_PRO_MODEL_ID,\n "label": "DeepSeek V4 Pro",\n },\n'
159
+ " ]\n"
160
+ " return models"
161
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
162
  if old_available in content:
163
+ content = content.replace(old_available, NEW_FUNC)
164
  print("OK: String replace worked")
165
  else:
166
  print("FAIL: Cannot find _available_models()!")