File size: 2,288 Bytes
4150671
0404053
6b00697
 
 
 
 
4150671
e38233f
 
4150671
e38233f
 
9a844a3
0ef7b61
 
90073ea
 
4150671
0ef7b61
2e719ba
e38233f
 
2e719ba
e38233f
 
 
 
 
4150671
3955f85
0ef7b61
4150671
0ef7b61
4150671
 
 
 
6b00697
 
4150671
 
6b00697
 
 
5585e5d
1
2
3
4
5
6
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
37
38
39
40
41
42
43
44
45
46
47
"""Patch backend: add new model IDs to AVAILABLE_MODELS + fix title generation."""
import re, os

AGENT_FILE = "/app/backend/routes/agent.py"
with open(AGENT_FILE, "r") as f:
    content = f.read()

# Add new models to AVAILABLE_MODELS
target = "AVAILABLE_MODELS = _available_models()\n"
patch = '''
# === PATCH: Add HF Inference + OpenRouter models ===
import os as _os
AVAILABLE_MODELS.extend([
    {"id": "deepseek-ai/DeepSeek-V4-Pro", "label": "DeepSeek V4 Pro", "provider": "huggingface", "tier": "free", "recommended": True},
    {"id": "deepseek-ai/DeepSeek-V4-Flash", "label": "DeepSeek V4 Flash", "provider": "huggingface", "tier": "free"},
    {"id": "openai/deepseek/deepseek-v4-flash", "label": "DeepSeek V4 Flash (OR)", "provider": "openrouter", "tier": "free"},
    {"id": "nvidia/nemotron-3-super-120b-a12b:free", "label": "Nemotron 3 Super 120B", "provider": "openrouter", "tier": "free"},
    {"id": "google/gemma-3-1b-it", "label": "Gemma 3 1B", "provider": "huggingface", "tier": "free", "recommended": True},
    {"id": "Qwen/Qwen3-Coder-Next", "label": "Qwen3 Coder Next", "provider": "huggingface", "tier": "free", "recommended": True},
    {"id": "openrouter/owl-alpha", "label": "Owl Alpha", "provider": "openrouter", "tier": "free", "recommended": True},
    {"id": "openai/google/gemini-2.0-flash-001", "label": "Gemini 2.0 Flash", "provider": "openrouter", "tier": "free"},
])
PREMIUM_MODEL_IDS = set()  # No premium gate
DEFAULT_FREE_MODEL_ID = "deepseek-ai/DeepSeek-V4-Pro"
# === END PATCH ===
'''

if target in content:
    content = content.replace(target, target + patch)
    print("✅ Added models to AVAILABLE_MODELS")

# Fix title generation - use huggingface/ prefix for litellm
old_title = 'model="openai/openai/gpt-oss-120b:cerebras",\n            api_base="https://router.huggingface.co/v1",\n            api_key=api_key,'
new_title = 'model="huggingface/deepseek-ai/DeepSeek-V4-Pro",\n            api_key=api_key,'
if old_title in content:
    content = content.replace(old_title, new_title)
    content = content.replace('            reasoning_effort="low",\n', '')
    print("✅ Title generation patched")

import ast
ast.parse(content)
print("✅ Syntax OK")

with open(AGENT_FILE, "w") as f:
    f.write(content)
print("✅ Backend patched")