| """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() |
|
|
| |
| 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") |
|
|
| |
| 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") |
|
|