Spaces:
Running
Running
Upload patch_flint_free_frontend.py
Browse files- patch_flint_free_frontend.py +51 -0
patch_flint_free_frontend.py
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Patch frontend ChatInput.tsx: add recursive/flint-v1.0:free (OpenRouter).
|
| 2 |
+
|
| 3 |
+
Uses the same `openai/` modelPath convention as Laguna S 2.1:free.
|
| 4 |
+
The frontend modelPath is sent to the backend, which strips the `openai/`
|
| 5 |
+
prefix and routes to OpenRouter via the existing catch-all in _resolve_llm_params.
|
| 6 |
+
|
| 7 |
+
Runs AFTER patch_frontend_xing_nemotron_vl.py (which already rewrote
|
| 8 |
+
DEFAULT_MODEL_OPTIONS). Idempotent.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import os
|
| 12 |
+
|
| 13 |
+
FILE = "/source/frontend/src/components/Chat/ChatInput.tsx"
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def patch():
|
| 17 |
+
if not os.path.exists(FILE):
|
| 18 |
+
print(f"SKIP: {FILE} not found")
|
| 19 |
+
return
|
| 20 |
+
|
| 21 |
+
with open(FILE, "r", encoding="utf-8") as f:
|
| 22 |
+
content = f.read()
|
| 23 |
+
|
| 24 |
+
if "flint-v1.0" in content:
|
| 25 |
+
print("OK: recursive/flint-v1.0:free already present in ChatInput.tsx (idempotent)")
|
| 26 |
+
return
|
| 27 |
+
|
| 28 |
+
# Anchor: the deepseek-v4-flash-latest entry at the end of DEFAULT_MODEL_OPTIONS.
|
| 29 |
+
anchor = " {\n id: 'deepseek-v4-flash-latest',\n"
|
| 30 |
+
new_entry = (
|
| 31 |
+
" {\n"
|
| 32 |
+
" id: 'flint-v1.0-free',\n"
|
| 33 |
+
" name: 'recursive/flint-v1.0:free',\n"
|
| 34 |
+
" modelPath: 'openai/recursive/flint-v1.0:free',\n"
|
| 35 |
+
" avatarUrl: 'https://huggingface.co/api/avatars/recursive',\n"
|
| 36 |
+
" recommended: true,\n"
|
| 37 |
+
" },\n"
|
| 38 |
+
)
|
| 39 |
+
|
| 40 |
+
if anchor in content:
|
| 41 |
+
content = content.replace(anchor, new_entry + anchor, 1)
|
| 42 |
+
with open(FILE, "w", encoding="utf-8") as f:
|
| 43 |
+
f.write(content)
|
| 44 |
+
print("OK: added recursive/flint-v1.0:free to ChatInput.tsx DEFAULT_MODEL_OPTIONS")
|
| 45 |
+
else:
|
| 46 |
+
print("FAIL: deepseek anchor not found in ChatInput.tsx")
|
| 47 |
+
return
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
if __name__ == "__main__":
|
| 51 |
+
patch()
|