Spaces:
Running
Running
File size: 4,694 Bytes
74c83d8 6e21c1d 957804c 62ab37d 957804c 62ab37d e6d3fc4 74c83d8 e6d3fc4 74c83d8 6e21c1d d9832d2 74c83d8 fcbd243 74c83d8 fcbd243 74c83d8 fcbd243 74c83d8 fcbd243 74c83d8 e6d3fc4 fcbd243 e6d3fc4 34932a2 957804c 62ab37d d9832d2 fcbd243 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | """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 — replace any model-constants import block ===
import_pattern = re.compile(
r'import\s*\{[^}]+\}\s*from\s*[\'"]@/utils/model[\'"];'
)
match = import_pattern.search(content)
if match:
content = content.replace(match.group(0), "import { isClaudePath } from '@/utils/model';")
print("OK: Replaced imports with just isClaudePath")
else:
print("OK: Imports already clean or not found")
# === 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:novita',
avatarUrl: 'https://huggingface.co/api/avatars/deepseek-ai',
recommended: true,
},
{
id: 'deepseek-v4-flash',
name: 'DeepSeek V4 Flash',
modelPath: 'deepseek-ai/DeepSeek-V4-Flash:novita',
avatarUrl: 'https://huggingface.co/api/avatars/deepseek-ai',
},
{
id: 'gpt-oss-120b',
name: 'gpt-oss-120b',
modelPath: 'openai/gpt-oss-120b',
avatarUrl: 'https://huggingface.co/api/avatars/openai',
},
{
id: 'qwen3-coder-next',
name: 'Qwen3 Coder Next',
modelPath: 'Qwen/Qwen3-Coder-Next:novita',
avatarUrl: 'https://huggingface.co/api/avatars/Qwen',
recommended: true,
},
{
id: 'gemma-3-1b',
name: 'Gemma 3 1B',
modelPath: 'google/gemma-3-1b-it:novita',
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',
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: 'hy3-preview',
name: 'Hy3 Preview',
modelPath: 'openai/tencent/hy3-preview',
avatarUrl: 'https://huggingface.co/api/avatars/tencent',
recommended: true,
},
{
id: 'north-mini-code',
name: 'north-mini-code:free',
modelPath: 'openai/cohere/north-mini-code:free',
avatarUrl: 'https://huggingface.co/api/avatars/cohere',
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: Replace DEFAULT_MODEL_PATH = first recommended model ===
dm_path = re.search(r'const DEFAULT_MODEL_PATH\s*=.*?;', content)
if dm_path:
content = content.replace(dm_path.group(0), "const DEFAULT_MODEL_PATH = 'deepseek-ai/DeepSeek-V4-Pro:novita';")
print("OK: Replaced DEFAULT_MODEL_PATH")
else:
print("OK: DEFAULT_MODEL_PATH not found")
with open(FILE, "w", encoding="utf-8") as f:
f.write(content)
print("OK: Frontend patched - 16 models, deepseek-ai/DeepSeek-V4-Pro:novita default") |