Spaces:
Paused
Paused
Fix: patch existing dropdown items exactly as specified
Browse files- patch_models.py +48 -32
patch_models.py
CHANGED
|
@@ -1,50 +1,63 @@
|
|
| 1 |
-
"""Patch backend:
|
| 2 |
import re, os
|
| 3 |
|
| 4 |
AGENT_FILE = "/app/backend/routes/agent.py"
|
| 5 |
with open(AGENT_FILE, "r") as f:
|
| 6 |
content = f.read()
|
| 7 |
|
| 8 |
-
#
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
''
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
# Fix title generation
|
| 37 |
old_patterns = [
|
| 38 |
'model="openai/openai/gpt-oss-120b:cerebras",\n api_base="https://router.huggingface.co/v1",\n api_key=api_key,',
|
| 39 |
-
'model="openai/openrouter/owl-alpha",\n api_base="https://openrouter.ai/api/v1",\n api_key=_os.environ.get("OPENROUTER_API_KEY", api_key),',
|
| 40 |
]
|
| 41 |
-
|
| 42 |
-
new_title_call = 'model="openai/openrouter/owl-alpha",\n api_base="https://openrouter.ai/api/v1",\n api_key=_os.environ.get("OPENROUTER_API_KEY", api_key),'
|
| 43 |
|
| 44 |
for old in old_patterns:
|
| 45 |
if old in content:
|
| 46 |
content = content.replace(old, new_title_call)
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
break
|
| 49 |
|
| 50 |
content = content.replace(' reasoning_effort="low",\n', '')
|
|
@@ -60,3 +73,6 @@ except SyntaxError as e:
|
|
| 60 |
with open(AGENT_FILE, "w") as f:
|
| 61 |
f.write(content)
|
| 62 |
print("β
Backend patched")
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Patch backend: modify existing AVAILABLE_MODELS entries + fix title generation."""
|
| 2 |
import re, os
|
| 3 |
|
| 4 |
AGENT_FILE = "/app/backend/routes/agent.py"
|
| 5 |
with open(AGENT_FILE, "r") as f:
|
| 6 |
content = f.read()
|
| 7 |
|
| 8 |
+
# Replace existing model entries in _available_models()
|
| 9 |
+
# 1. Kimi K2.6 β DeepSeek V4 Pro (HF Inference)
|
| 10 |
+
content = content.replace(
|
| 11 |
+
'"moonshotai/Kimi-K2.6"',
|
| 12 |
+
'"deepseek-ai/DeepSeek-V4-Pro"'
|
| 13 |
+
)
|
| 14 |
+
content = content.replace(
|
| 15 |
+
'"Kimi K2.6"',
|
| 16 |
+
'"DeepSeek V4 Pro"'
|
| 17 |
+
)
|
| 18 |
+
|
| 19 |
+
# 4. MiniMax M2.7 (novita) β deepseek/deepseek-v4-flash (openai/ prefix = OpenRouter)
|
| 20 |
+
content = content.replace(
|
| 21 |
+
'"MiniMaxAI/MiniMax-M2.7"',
|
| 22 |
+
'"openai/deepseek/deepseek-v4-flash"'
|
| 23 |
+
)
|
| 24 |
+
content = content.replace(
|
| 25 |
+
'"MiniMax M2.7"',
|
| 26 |
+
'"DeepSeek V4 Flash (OR)"'
|
| 27 |
+
)
|
| 28 |
+
|
| 29 |
+
# 5. GLM 5.1 (together) β DeepSeek-V4-Flash (HF Inference)
|
| 30 |
+
content = content.replace(
|
| 31 |
+
'"zai-org/GLM-5.1"',
|
| 32 |
+
'"deepseek-ai/DeepSeek-V4-Flash"'
|
| 33 |
+
)
|
| 34 |
+
content = content.replace(
|
| 35 |
+
'"GLM 5.1"',
|
| 36 |
+
'"DeepSeek V4 Flash (HF)"'
|
| 37 |
+
)
|
| 38 |
+
|
| 39 |
+
# Also fix DEFAULT_FREE_MODEL_ID since Kimi no longer exists
|
| 40 |
+
content = content.replace(
|
| 41 |
+
'DEFAULT_FREE_MODEL_ID = "moonshotai/Kimi-K2.6"',
|
| 42 |
+
'DEFAULT_FREE_MODEL_ID = "deepseek-ai/DeepSeek-V4-Pro"'
|
| 43 |
+
)
|
| 44 |
|
| 45 |
# Fix title generation
|
| 46 |
old_patterns = [
|
| 47 |
'model="openai/openai/gpt-oss-120b:cerebras",\n api_base="https://router.huggingface.co/v1",\n api_key=api_key,',
|
|
|
|
| 48 |
]
|
| 49 |
+
new_title_call = 'model="openrouter/openrouter/owl-alpha",\n api_key=_os.environ.get("OPENROUTER_API_KEY", api_key),'
|
|
|
|
| 50 |
|
| 51 |
for old in old_patterns:
|
| 52 |
if old in content:
|
| 53 |
content = content.replace(old, new_title_call)
|
| 54 |
+
# Need to add import os as _os
|
| 55 |
+
if '_os.environ' in content and 'import os as _os' not in content:
|
| 56 |
+
content = content.replace(
|
| 57 |
+
'AVAILABLE_MODELS = _available_models()\n',
|
| 58 |
+
'AVAILABLE_MODELS = _available_models()\nimport os as _os\n'
|
| 59 |
+
)
|
| 60 |
+
print("β
Title generation patched")
|
| 61 |
break
|
| 62 |
|
| 63 |
content = content.replace(' reasoning_effort="low",\n', '')
|
|
|
|
| 73 |
with open(AGENT_FILE, "w") as f:
|
| 74 |
f.write(content)
|
| 75 |
print("β
Backend patched")
|
| 76 |
+
print(" - Kimi K2.6 β deepseek-ai/DeepSeek-V4-Pro (HF)")
|
| 77 |
+
print(" - MiniMax M2.7 β openai/deepseek/deepseek-v4-flash (OR)")
|
| 78 |
+
print(" - GLM 5.1 β deepseek-ai/DeepSeek-V4-Flash (HF)")
|