ml-intern / patch_flint_free_frontend.py
bep40's picture
Upload patch_flint_free_frontend.py
266c03f verified
Raw History Blame Contribute Delete
1.67 kB
"""Patch frontend ChatInput.tsx: add recursive/flint-v1.0:free (OpenRouter).
Uses the same `openai/` modelPath convention as Laguna S 2.1:free.
The frontend modelPath is sent to the backend, which strips the `openai/`
prefix and routes to OpenRouter via the existing catch-all in _resolve_llm_params.
Runs AFTER patch_frontend_xing_nemotron_vl.py (which already rewrote
DEFAULT_MODEL_OPTIONS). Idempotent.
"""
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 "flint-v1.0" in content:
print("OK: recursive/flint-v1.0:free already present in ChatInput.tsx (idempotent)")
return
# Anchor: the deepseek-v4-flash-latest entry at the end of DEFAULT_MODEL_OPTIONS.
anchor = " {\n id: 'deepseek-v4-flash-latest',\n"
new_entry = (
" {\n"
" id: 'flint-v1.0-free',\n"
" name: 'recursive/flint-v1.0:free',\n"
" modelPath: 'openai/recursive/flint-v1.0:free',\n"
" avatarUrl: 'https://huggingface.co/api/avatars/recursive',\n"
" recommended: true,\n"
" },\n"
)
if anchor in content:
content = content.replace(anchor, new_entry + anchor, 1)
with open(FILE, "w", encoding="utf-8") as f:
f.write(content)
print("OK: added recursive/flint-v1.0:free to ChatInput.tsx DEFAULT_MODEL_OPTIONS")
else:
print("FAIL: deepseek anchor not found in ChatInput.tsx")
return
if __name__ == "__main__":
patch()