Spaces:
Paused
Paused
Set DEFAULT_FREE_MODEL_ID to openrouter/owl-alpha
Browse files- patch_models.py +6 -23
patch_models.py
CHANGED
|
@@ -11,15 +11,15 @@ patch = '''
|
|
| 11 |
# === PATCH: Add HF Inference + OpenRouter models ===
|
| 12 |
import os as _os
|
| 13 |
AVAILABLE_MODELS.extend([
|
|
|
|
| 14 |
{"id": "deepseek-ai/DeepSeek-V4-Pro", "label": "DeepSeek V4 Pro", "provider": "huggingface", "tier": "free", "recommended": True},
|
| 15 |
{"id": "Qwen/Qwen3-Coder-Next", "label": "Qwen3 Coder Next", "provider": "huggingface", "tier": "free", "recommended": True},
|
| 16 |
-
{"id": "openrouter/owl-alpha", "label": "Owl Alpha", "provider": "openrouter", "tier": "free", "recommended": True},
|
| 17 |
{"id": "MiniMaxAI/MiniMax-M2.7", "label": "MiniMax M2.7", "provider": "huggingface", "tier": "free"},
|
| 18 |
{"id": "zai-org/GLM-5.1", "label": "GLM 5.1", "provider": "huggingface", "tier": "free"},
|
| 19 |
{"id": "openai/google/gemini-2.0-flash-001", "label": "Gemini 2.0 Flash", "provider": "openrouter", "tier": "free"},
|
| 20 |
])
|
| 21 |
PREMIUM_MODEL_IDS = set() # No premium gate
|
| 22 |
-
DEFAULT_FREE_MODEL_ID = "
|
| 23 |
# === END PATCH ===
|
| 24 |
'''
|
| 25 |
|
|
@@ -27,39 +27,22 @@ if target in content:
|
|
| 27 |
content = content.replace(target, target + patch)
|
| 28 |
print("✅ Added models to AVAILABLE_MODELS")
|
| 29 |
|
| 30 |
-
# Fix title generation
|
| 31 |
-
# The original uses openai/openai/gpt-oss-120b:cerebras with HF router
|
| 32 |
-
# We replace with openrouter/owl-alpha which works
|
| 33 |
old_patterns = [
|
| 34 |
'model="openai/openai/gpt-oss-120b:cerebras",\n api_base="https://router.huggingface.co/v1",\n api_key=api_key,',
|
| 35 |
'model="huggingface/deepseek-ai/DeepSeek-V4-Pro",\n api_key=api_key,',
|
| 36 |
-
'model="deepseek-ai/DeepSeek-V4-Pro",\n api_base=_os.environ.get("OPENAI_API_BASE", "https://router.huggingface.co/v1"),\n api_key=_os.environ.get("OPENAI_API_KEY", api_key),',
|
| 37 |
]
|
| 38 |
|
| 39 |
new_title_call = 'model="openrouter/owl-alpha",\n api_key=_os.environ.get("OPENROUTER_API_KEY", api_key),'
|
| 40 |
|
| 41 |
-
replaced = False
|
| 42 |
for old in old_patterns:
|
| 43 |
if old in content:
|
| 44 |
content = content.replace(old, new_title_call)
|
| 45 |
-
|
| 46 |
-
print(f"✅ Title generation patched (matched pattern)")
|
| 47 |
break
|
| 48 |
|
| 49 |
-
|
| 50 |
-
print("⚠️ Could not find title pattern, trying regex...")
|
| 51 |
-
# Try regex to find the title generation acompletion call
|
| 52 |
-
import re
|
| 53 |
-
pattern = r'(model=")[^"]*(",\s*\n\s*api_base="[^"]*",\s*\n\s*api_key=)[^,]*,'
|
| 54 |
-
if re.search(pattern, content):
|
| 55 |
-
content = re.sub(pattern, r'model="openrouter/owl-alpha",\n api_key=_os.environ.get("OPENROUTER_API_KEY", api_key),', content, count=1)
|
| 56 |
-
print("✅ Title generation patched via regex")
|
| 57 |
-
else:
|
| 58 |
-
print("❌ Could not patch title generation")
|
| 59 |
-
|
| 60 |
-
# Remove reasoning_effort if present (owl-alpha doesn't support it)
|
| 61 |
content = content.replace(' reasoning_effort="low",\n', '')
|
| 62 |
-
print("✅ Removed reasoning_effort")
|
| 63 |
|
| 64 |
import ast
|
| 65 |
try:
|
|
@@ -71,4 +54,4 @@ except SyntaxError as e:
|
|
| 71 |
|
| 72 |
with open(AGENT_FILE, "w") as f:
|
| 73 |
f.write(content)
|
| 74 |
-
print("✅ Backend patched")
|
|
|
|
| 11 |
# === PATCH: Add HF Inference + OpenRouter models ===
|
| 12 |
import os as _os
|
| 13 |
AVAILABLE_MODELS.extend([
|
| 14 |
+
{"id": "openrouter/owl-alpha", "label": "Owl Alpha", "provider": "openrouter", "tier": "free", "recommended": True},
|
| 15 |
{"id": "deepseek-ai/DeepSeek-V4-Pro", "label": "DeepSeek V4 Pro", "provider": "huggingface", "tier": "free", "recommended": True},
|
| 16 |
{"id": "Qwen/Qwen3-Coder-Next", "label": "Qwen3 Coder Next", "provider": "huggingface", "tier": "free", "recommended": True},
|
|
|
|
| 17 |
{"id": "MiniMaxAI/MiniMax-M2.7", "label": "MiniMax M2.7", "provider": "huggingface", "tier": "free"},
|
| 18 |
{"id": "zai-org/GLM-5.1", "label": "GLM 5.1", "provider": "huggingface", "tier": "free"},
|
| 19 |
{"id": "openai/google/gemini-2.0-flash-001", "label": "Gemini 2.0 Flash", "provider": "openrouter", "tier": "free"},
|
| 20 |
])
|
| 21 |
PREMIUM_MODEL_IDS = set() # No premium gate
|
| 22 |
+
DEFAULT_FREE_MODEL_ID = "openrouter/owl-alpha"
|
| 23 |
# === END PATCH ===
|
| 24 |
'''
|
| 25 |
|
|
|
|
| 27 |
content = content.replace(target, target + patch)
|
| 28 |
print("✅ Added models to AVAILABLE_MODELS")
|
| 29 |
|
| 30 |
+
# Fix title generation
|
|
|
|
|
|
|
| 31 |
old_patterns = [
|
| 32 |
'model="openai/openai/gpt-oss-120b:cerebras",\n api_base="https://router.huggingface.co/v1",\n api_key=api_key,',
|
| 33 |
'model="huggingface/deepseek-ai/DeepSeek-V4-Pro",\n api_key=api_key,',
|
|
|
|
| 34 |
]
|
| 35 |
|
| 36 |
new_title_call = 'model="openrouter/owl-alpha",\n api_key=_os.environ.get("OPENROUTER_API_KEY", api_key),'
|
| 37 |
|
|
|
|
| 38 |
for old in old_patterns:
|
| 39 |
if old in content:
|
| 40 |
content = content.replace(old, new_title_call)
|
| 41 |
+
print(f"✅ Title generation patched")
|
|
|
|
| 42 |
break
|
| 43 |
|
| 44 |
+
# Remove reasoning_effort (owl-alpha doesn't support it)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
content = content.replace(' reasoning_effort="low",\n', '')
|
|
|
|
| 46 |
|
| 47 |
import ast
|
| 48 |
try:
|
|
|
|
| 54 |
|
| 55 |
with open(AGENT_FILE, "w") as f:
|
| 56 |
f.write(content)
|
| 57 |
+
print("✅ Backend patched - default model: openrouter/owl-alpha")
|