Spaces:
Running
Running
| """Patch frontend ChatInput.tsx: Replace DEFAULT_MODEL_OPTIONS array + fix imports.""" | |
| import re | |
| import sys | |
| FILE = "/source/frontend/src/components/Chat/ChatInput.tsx" | |
| with open(FILE, "r", encoding="utf-8") as f: | |
| content = f.read() | |
| # === Step 1: Fix imports === | |
| content = content.replace( | |
| "import {\n" | |
| " CLAUDE_OPUS_48_MODEL_PATH,\n" | |
| " GPT_55_MODEL_PATH,\n" | |
| " KIMI_K26_MODEL_PATH,\n" | |
| " isClaudePath,\n" | |
| "} from '@/utils/model';", | |
| "import { isClaudePath } from '@/utils/model';" | |
| ) | |
| # === Step 2: Replace DEFAULT_MODEL_OPTIONS array using regex === | |
| pattern = r'const DEFAULT_MODEL_OPTIONS: ModelOption\[\] = \[.*?\];' | |
| match = re.search(pattern, content, re.DOTALL) | |
| if not match: | |
| print("FAIL: Could not find DEFAULT_MODEL_OPTIONS array!") | |
| sys.exit(1) | |
| print(f"OK: Found array at pos {match.start()}-{match.end()}") | |
| new_array = """const DEFAULT_MODEL_OPTIONS: ModelOption[] = [ | |
| { | |
| id: 'owl-alpha', | |
| name: 'Owl Alpha', | |
| modelPath: 'openai/openrouter/owl-alpha', | |
| avatarUrl: 'https://huggingface.co/api/avatars/openrouter', | |
| recommended: true, | |
| }, | |
| { | |
| id: 'deepseek-v4-pro', | |
| name: 'DeepSeek V4 Pro', | |
| modelPath: 'deepseek-ai/DeepSeek-V4-Pro', | |
| avatarUrl: 'https://huggingface.co/api/avatars/deepseek-ai', | |
| recommended: true, | |
| }, | |
| { | |
| id: 'deepseek-v4-flash', | |
| name: 'DeepSeek V4 Flash', | |
| modelPath: 'deepseek-ai/DeepSeek-V4-Flash', | |
| avatarUrl: 'https://huggingface.co/api/avatars/deepseek-ai', | |
| }, | |
| { | |
| id: 'gpt-5.5', | |
| name: 'GPT-5.5', | |
| modelPath: 'openai/gpt-5.5:fal-ai', | |
| avatarUrl: 'https://huggingface.co/api/avatars/openai', | |
| }, | |
| { | |
| id: 'qwen3-coder-next', | |
| name: 'Qwen3 Coder Next', | |
| modelPath: 'Qwen/Qwen3-Coder-Next', | |
| avatarUrl: 'https://huggingface.co/api/avatars/Qwen', | |
| recommended: true, | |
| }, | |
| { | |
| id: 'gemma-3-1b', | |
| name: 'Gemma 3 1B', | |
| modelPath: 'google/gemma-3-1b-it', | |
| avatarUrl: 'https://huggingface.co/api/avatars/google', | |
| recommended: true, | |
| }, | |
| { | |
| id: 'gemini-2.0-flash', | |
| name: 'Gemini 2.0 Flash', | |
| modelPath: 'openai/google/gemini-2.0-flash-001', | |
| avatarUrl: 'https://huggingface.co/api/avatars/google', | |
| }, | |
| { | |
| id: 'deepseek-v4-flash-or', | |
| name: 'DeepSeek V4 Flash (OR)', | |
| modelPath: 'openai/deepseek/deepseek-v4-flash:free', | |
| avatarUrl: 'https://huggingface.co/api/avatars/deepseek-ai', | |
| }, | |
| { | |
| id: 'gemma-4-9b', | |
| name: 'Gemma 4 9B', | |
| modelPath: 'openai/google/gemma-4-9b-it:free', | |
| avatarUrl: 'https://huggingface.co/api/avatars/google', | |
| recommended: true, | |
| }, | |
| { | |
| id: 'gemma-4-31b', | |
| name: 'Gemma 4 31B', | |
| modelPath: 'openai/google/gemma-4-31b-it:free', | |
| avatarUrl: 'https://huggingface.co/api/avatars/google', | |
| recommended: true, | |
| }, | |
| { | |
| id: 'riverflow-fast', | |
| name: 'Riverflow V2.5 Fast', | |
| modelPath: 'openai/sourceful/riverflow-v2.5-fast:free', | |
| avatarUrl: 'https://huggingface.co/api/avatars/sourceful', | |
| recommended: true, | |
| }, | |
| { | |
| id: 'riverflow-pro', | |
| name: 'Riverflow V2.5 Pro', | |
| modelPath: 'openai/sourceful/riverflow-v2.5-pro:free', | |
| avatarUrl: 'https://huggingface.co/api/avatars/sourceful', | |
| recommended: true, | |
| }, | |
| { | |
| id: 'nemotron-120b', | |
| name: 'Nemotron 3 Super 120B', | |
| modelPath: 'openai/nvidia/nemotron-3-super-120b-a12b:free', | |
| avatarUrl: 'https://huggingface.co/api/avatars/nvidia', | |
| }, | |
| { | |
| id: 'nemotron-3-ultra', | |
| name: 'Nemotron 3 Ultra 550B', | |
| modelPath: 'openai/nvidia/nemotron-3-ultra-550b-a55b:free', | |
| avatarUrl: 'https://huggingface.co/api/avatars/nvidia', | |
| recommended: true, | |
| }, | |
| { | |
| id: 'laguna-m', | |
| name: 'Laguna M.1', | |
| modelPath: 'openai/poolside/laguna-m.1:free', | |
| avatarUrl: 'https://huggingface.co/api/avatars/poolside', | |
| recommended: true, | |
| }, | |
| { | |
| id: 'laguna-xs', | |
| name: 'Laguna XS.2', | |
| modelPath: 'openai/poolside/laguna-xs.2:free', | |
| avatarUrl: 'https://huggingface.co/api/avatars/poolside', | |
| }, | |
| ];""" | |
| content = content[:match.start()] + new_array + content[match.end():] | |
| # === Step 3: DEFAULT_FREE_MODEL_OPTION_ID = owl-alpha === | |
| content = content.replace( | |
| "DEFAULT_FREE_MODEL_OPTION_ID = 'kimi-k2.6'", | |
| "DEFAULT_FREE_MODEL_OPTION_ID = 'owl-alpha'" | |
| ) | |
| with open(FILE, "w", encoding="utf-8") as f: | |
| f.write(content) | |
| print("OK: Frontend patched - 16 models, owl-alpha default") |