bep40 commited on
Commit
6d19910
·
verified ·
1 Parent(s): e9e0d7a

Upload patch_frontend.py

Browse files
Files changed (1) hide show
  1. patch_frontend.py +24 -34
patch_frontend.py CHANGED
@@ -1,4 +1,4 @@
1
- """Patch frontend: Remove Owl Alpha, add models with openai/ prefix for OpenRouter routing."""
2
 
3
  import re
4
  import sys
@@ -6,7 +6,7 @@ import sys
6
  FILE = "/source/frontend/src/components/Chat/ChatInput.tsx"
7
  MODEL_FILE = "/source/frontend/src/utils/model.ts"
8
 
9
- # === Step 1: Patch model.ts constants ===
10
  with open(MODEL_FILE, "r") as f:
11
  model_content = f.read()
12
 
@@ -35,7 +35,7 @@ print("OK: model.ts constants updated")
35
  with open(FILE, "r", encoding="utf-8") as f:
36
  content = f.read()
37
 
38
- # Fix imports — replace model constants imports with just isClaudePath
39
  import_pattern = re.compile(
40
  r'import\s*\{[^}]+\}\s*from\s*[\'"]@/utils/model[\'"];'
41
  )
@@ -43,22 +43,20 @@ match = import_pattern.search(content)
43
  if match:
44
  content = content.replace(match.group(0), "import { isClaudePath } from '@/utils/model';")
45
  print("OK: Replaced imports")
46
- else:
47
- print("OK: Imports not found")
48
 
49
  # Remove Owl Alpha references
50
  content = content.replace("'Owl Alpha'", "'Claude Opus 4.8'")
51
  content = content.replace('"Owl Alpha"', '"Claude Opus 4.8"')
52
 
53
- # Row 3: Kimi K2.7 Code → DeepSeek V4 Pro
54
  content = content.replace("'Kimi K2.7 Code'", "'DeepSeek V4 Pro'")
55
  content = content.replace('"Kimi K2.7 Code"', '"DeepSeek V4 Pro"')
56
 
57
- # Row 4: MiniMax M3 → DeepSeek V4 Flash
58
  content = content.replace("'MiniMax M3'", "'DeepSeek V4 Flash'")
59
  content = content.replace('"MiniMax M3"', '"DeepSeek V4 Flash"')
60
 
61
- # Row 5: GLM 5.2 → DeepSeek V4 Flash
62
  content = content.replace("'GLM 5.2'", "'DeepSeek V4 Flash'")
63
  content = content.replace('"GLM 5.2"', '"DeepSeek V4 Flash"')
64
 
@@ -68,24 +66,7 @@ content = content.replace(
68
  " {\n id: 'nemotron-120b',\n name: 'nvidia/nemotron-3-super-120b-a12b:free',\n modelPath: DEEPSEEK_V4_PRO_MODEL_PATH,\n avatarUrl: 'https://huggingface.co/api/avatars/nvidia',\n },"
69
  )
70
 
71
- # Remove ALL old custom model blocks
72
- old_blocks = [
73
- 'modelPath: \'google/gemma-4-31b-it:free\'',
74
- 'modelPath: \'tencent/hy3:free\'',
75
- 'modelPath: \'tencent/hy3\'',
76
- 'modelPath: \'meta-llama/llama-3.1-8b-instruct\'',
77
- 'modelPath: \'meta-llama/llama-3.3-70b-instruct:free\'',
78
- 'modelPath: \'google/gemma-2-9b-it\'',
79
- 'modelPath: \'nvidia/llama-3.1-nemotron-70b-instruct\'',
80
- 'modelPath: \'openai/tencent/hy3:free\'',
81
- 'id: \'gemma-4-31b\'',
82
- 'id: \'llama-3.1-8b\'',
83
- 'id: \'llama-3.3-70b\'',
84
- 'id: \'nemotron-70b\'',
85
- 'id: \'gemma-2-9b\'',
86
- 'id: \'tencent-hy3\'',
87
- ]
88
- # Use simpler approach: find and replace entire DEFAULT_MODEL_OPTIONS array
89
  pattern = r'const DEFAULT_MODEL_OPTIONS: ModelOption\[\] = \[.*?\];'
90
  match = re.search(pattern, content, re.DOTALL)
91
 
@@ -94,6 +75,13 @@ if not match:
94
  sys.exit(1)
95
 
96
  new_array = """const DEFAULT_MODEL_OPTIONS: ModelOption[] = [
 
 
 
 
 
 
 
97
  {
98
  id: 'gemma-4-31b',
99
  name: 'Gemma 4 31B:free',
@@ -108,18 +96,19 @@ new_array = """const DEFAULT_MODEL_OPTIONS: ModelOption[] = [
108
  avatarUrl: 'https://huggingface.co/api/avatars/meta-llama',
109
  recommended: true,
110
  },
 
 
 
 
 
 
 
111
  {
112
  id: 'llama-3.1-8b',
113
  name: 'Llama 3.1 8B',
114
  modelPath: 'openai/meta-llama/llama-3.1-8b-instruct',
115
  avatarUrl: 'https://huggingface.co/api/avatars/meta-llama',
116
  },
117
- {
118
- id: 'tencent-hy3',
119
- name: 'Tencent HY3:free',
120
- modelPath: 'openai/tencent/hy3:free',
121
- avatarUrl: 'https://huggingface.co/api/avatars/tencent',
122
- },
123
  {
124
  id: 'qwen3-coder-next',
125
  name: 'Qwen3 Coder Next',
@@ -139,7 +128,7 @@ content = content[:match.start()] + new_array + content[match.end():]
139
  # Update DEFAULT_MODEL_PATH
140
  dm_path = re.search(r'const DEFAULT_MODEL_PATH\s*=.*?;', content)
141
  if dm_path:
142
- content = content.replace(dm_path.group(0), "const DEFAULT_MODEL_PATH = 'openai/google/gemma-4-31b-it:free';")
143
  print("OK: Replaced DEFAULT_MODEL_PATH")
144
  else:
145
  print("OK: DEFAULT_MODEL_PATH not found")
@@ -147,4 +136,5 @@ else:
147
  with open(FILE, "w", encoding="utf-8") as f:
148
  f.write(content)
149
 
150
- print("OK: Frontend patched - Gemma 4 31B:free DEFAULT (openai/ prefix for OpenRouter routing)")
 
 
1
+ """Patch frontend: Replace DEFAULT_MODEL_OPTIONS with OpenRouter models."""
2
 
3
  import re
4
  import sys
 
6
  FILE = "/source/frontend/src/components/Chat/ChatInput.tsx"
7
  MODEL_FILE = "/source/frontend/src/utils/model.ts"
8
 
9
+ # === Step 1: Patch model.ts ===
10
  with open(MODEL_FILE, "r") as f:
11
  model_content = f.read()
12
 
 
35
  with open(FILE, "r", encoding="utf-8") as f:
36
  content = f.read()
37
 
38
+ # Fix imports
39
  import_pattern = re.compile(
40
  r'import\s*\{[^}]+\}\s*from\s*[\'"]@/utils/model[\'"];'
41
  )
 
43
  if match:
44
  content = content.replace(match.group(0), "import { isClaudePath } from '@/utils/model';")
45
  print("OK: Replaced imports")
 
 
46
 
47
  # Remove Owl Alpha references
48
  content = content.replace("'Owl Alpha'", "'Claude Opus 4.8'")
49
  content = content.replace('"Owl Alpha"', '"Claude Opus 4.8"')
50
 
51
+ # Row 3: Kimi → DeepSeek V4 Pro
52
  content = content.replace("'Kimi K2.7 Code'", "'DeepSeek V4 Pro'")
53
  content = content.replace('"Kimi K2.7 Code"', '"DeepSeek V4 Pro"')
54
 
55
+ # Row 4: MiniMax → DeepSeek V4 Flash
56
  content = content.replace("'MiniMax M3'", "'DeepSeek V4 Flash'")
57
  content = content.replace('"MiniMax M3"', '"DeepSeek V4 Flash"')
58
 
59
+ # Row 5: GLM → DeepSeek V4 Flash
60
  content = content.replace("'GLM 5.2'", "'DeepSeek V4 Flash'")
61
  content = content.replace('"GLM 5.2"', '"DeepSeek V4 Flash"')
62
 
 
66
  " {\n id: 'nemotron-120b',\n name: 'nvidia/nemotron-3-super-120b-a12b:free',\n modelPath: DEEPSEEK_V4_PRO_MODEL_PATH,\n avatarUrl: 'https://huggingface.co/api/avatars/nvidia',\n },"
67
  )
68
 
69
+ # Replace entire DEFAULT_MODEL_OPTIONS array
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  pattern = r'const DEFAULT_MODEL_OPTIONS: ModelOption\[\] = \[.*?\];'
71
  match = re.search(pattern, content, re.DOTALL)
72
 
 
75
  sys.exit(1)
76
 
77
  new_array = """const DEFAULT_MODEL_OPTIONS: ModelOption[] = [
78
+ {
79
+ id: 'tencent-hy3',
80
+ name: 'Tencent HY3:free',
81
+ modelPath: 'openai/tencent/hy3:free',
82
+ avatarUrl: 'https://huggingface.co/api/avatars/tencent',
83
+ recommended: true,
84
+ },
85
  {
86
  id: 'gemma-4-31b',
87
  name: 'Gemma 4 31B:free',
 
96
  avatarUrl: 'https://huggingface.co/api/avatars/meta-llama',
97
  recommended: true,
98
  },
99
+ {
100
+ id: 'laguna-m1',
101
+ name: 'Laguna M.1:free',
102
+ modelPath: 'openai/poolside/laguna-m.1:free',
103
+ avatarUrl: 'https://huggingface.co/api/avatars/poolside',
104
+ recommended: true,
105
+ },
106
  {
107
  id: 'llama-3.1-8b',
108
  name: 'Llama 3.1 8B',
109
  modelPath: 'openai/meta-llama/llama-3.1-8b-instruct',
110
  avatarUrl: 'https://huggingface.co/api/avatars/meta-llama',
111
  },
 
 
 
 
 
 
112
  {
113
  id: 'qwen3-coder-next',
114
  name: 'Qwen3 Coder Next',
 
128
  # Update DEFAULT_MODEL_PATH
129
  dm_path = re.search(r'const DEFAULT_MODEL_PATH\s*=.*?;', content)
130
  if dm_path:
131
+ content = content.replace(dm_path.group(0), "const DEFAULT_MODEL_PATH = 'openai/tencent/hy3:free';")
132
  print("OK: Replaced DEFAULT_MODEL_PATH")
133
  else:
134
  print("OK: DEFAULT_MODEL_PATH not found")
 
136
  with open(FILE, "w", encoding="utf-8") as f:
137
  f.write(content)
138
 
139
+ print("OK: Frontend patched - Tencent HY3:free DEFAULT")
140
+ print(" Models: HY3:free, Gemma 4 31B:free, Llama 3.3 70B:free, Laguna M.1:free, Llama 3.1 8B")