"""Patch frontend ChatInput.tsx: add 3 new OpenRouter models to the model picker. New models (openai/ prefix routes to OpenRouter): - UPSTAGE Solar Pro 4 (openai/upstage/solar-pro4) - NVIDIA Nemotron 3.5 Lightning:free (openai/nvidia/nemotron-3.5-lightning:free) - Liquid LFM 2.5 2.6B:free (openai/liquid/lfm-2.5-2.6b:free) """ import os FILE = "/source/frontend/src/components/Chat/ChatInput.tsx" def patch(): if not os.path.exists(FILE): print(f"SKIP: {FILE} not found") return with open(FILE, "r", encoding="utf-8") as f: content = f.read() if "upstage-solar-pro4" in content: print("OK: models already present") return # Unique anchor: the deepseek-v4-flash-latest entry inside DEFAULT_MODEL_OPTIONS. # Insert the 3 new model objects immediately BEFORE that entry. anchor = " {\n id: 'deepseek-v4-flash-latest',\n" new_entries = ( " {\n" " id: 'upstage-solar-pro4',\n" " name: 'UPSTAGE Solar Pro 4',\n" " modelPath: 'openai/upstage/solar-pro4',\n" " avatarUrl: 'https://huggingface.co/api/avatars/upstage',\n" " recommended: true,\n" " },\n" " {\n" " id: 'nemotron-3.5-lightning',\n" " name: 'NVIDIA Nemotron 3.5 Lightning:free',\n" " modelPath: 'openai/nvidia/nemotron-3.5-lightning:free',\n" " avatarUrl: 'https://huggingface.co/api/avatars/nvidia',\n" " recommended: true,\n" " },\n" " {\n" " id: 'liquid-lfm-2.5-2.6b',\n" " name: 'Liquid LFM 2.5 2.6B:free',\n" " modelPath: 'openai/liquid/lfm-2.5-2.6b:free',\n" " avatarUrl: 'https://huggingface.co/api/avatars/liquid',\n" " recommended: true,\n" " },\n" ) if anchor in content: content = content.replace(anchor, new_entries + anchor, 1) print("OK: added 3 new models before deepseek-v4-flash-latest entry") else: # Fallback: find the deepseek id line by itself. alt = " id: 'deepseek-v4-flash-latest',\n" if alt in content: content = content.replace(alt, new_entries + " {\n" + alt, 1) print("OK: added 3 new models (fallback anchor)") else: print("FAIL: could not find insertion anchor in DEFAULT_MODEL_OPTIONS") return with open(FILE, "w", encoding="utf-8") as f: f.write(content) print("OK: ChatInput.tsx new models patched") if __name__ == "__main__": patch()