Skip to content

Commit 646ec15

Browse files
author
1bcMax
committed
fix: format router.py with black
1 parent 0342d5b commit 646ec15

1 file changed

Lines changed: 140 additions & 31 deletions

File tree

blockrun_llm/router.py

Lines changed: 140 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -52,45 +52,153 @@ class ScoringResult(TypedDict):
5252
# Multilingual keywords for 14-dimension scoring
5353

5454
CODE_KEYWORDS = [
55-
"function", "class", "import", "def", "SELECT", "async", "await",
56-
"const", "let", "var", "return", "```",
57-
"函数", "类", "导入", "定义", "查询", "异步", "等待", "常量", "变量", "返回",
58-
"関数", "クラス", "インポート", "非同期", "定数", "変数",
59-
"функция", "класс", "импорт", "определ", "запрос", "асинхронный",
55+
"function",
56+
"class",
57+
"import",
58+
"def",
59+
"SELECT",
60+
"async",
61+
"await",
62+
"const",
63+
"let",
64+
"var",
65+
"return",
66+
"```",
67+
"函数",
68+
"类",
69+
"导入",
70+
"定义",
71+
"查询",
72+
"异步",
73+
"等待",
74+
"常量",
75+
"变量",
76+
"返回",
77+
"関数",
78+
"クラス",
79+
"インポート",
80+
"非同期",
81+
"定数",
82+
"変数",
83+
"функция",
84+
"класс",
85+
"импорт",
86+
"определ",
87+
"запрос",
88+
"асинхронный",
6089
]
6190

6291
REASONING_KEYWORDS = [
63-
"prove", "theorem", "derive", "step by step", "chain of thought",
64-
"formally", "mathematical", "proof", "logically",
65-
"证明", "定理", "推导", "逐步", "思维链", "形式化", "数学", "逻辑",
66-
"доказать", "теорема", "вывести", "шаг за шагом", "логически",
92+
"prove",
93+
"theorem",
94+
"derive",
95+
"step by step",
96+
"chain of thought",
97+
"formally",
98+
"mathematical",
99+
"proof",
100+
"logically",
101+
"证明",
102+
"定理",
103+
"推导",
104+
"逐步",
105+
"思维链",
106+
"形式化",
107+
"数学",
108+
"逻辑",
109+
"доказать",
110+
"теорема",
111+
"вывести",
112+
"шаг за шагом",
113+
"логически",
67114
]
68115

69116
SIMPLE_KEYWORDS = [
70-
"what is", "define", "translate", "hello", "yes or no",
71-
"capital of", "how old", "who is", "when was",
72-
"什么是", "定义", "翻译", "你好", "是否", "首都",
73-
"что такое", "определение", "перевести", "привет",
117+
"what is",
118+
"define",
119+
"translate",
120+
"hello",
121+
"yes or no",
122+
"capital of",
123+
"how old",
124+
"who is",
125+
"when was",
126+
"什么是",
127+
"定义",
128+
"翻译",
129+
"你好",
130+
"是否",
131+
"首都",
132+
"что такое",
133+
"определение",
134+
"перевести",
135+
"привет",
74136
]
75137

76138
TECHNICAL_KEYWORDS = [
77-
"algorithm", "optimize", "architecture", "distributed",
78-
"kubernetes", "microservice", "database", "infrastructure",
79-
"算法", "优化", "架构", "分布式", "微服务", "数据库",
139+
"algorithm",
140+
"optimize",
141+
"architecture",
142+
"distributed",
143+
"kubernetes",
144+
"microservice",
145+
"database",
146+
"infrastructure",
147+
"算法",
148+
"优化",
149+
"架构",
150+
"分布式",
151+
"微服务",
152+
"数据库",
80153
]
81154

82155
CREATIVE_KEYWORDS = [
83-
"story", "poem", "compose", "brainstorm", "creative", "imagine", "write a",
84-
"故事", "诗", "创作", "头脑风暴", "创意", "想象",
156+
"story",
157+
"poem",
158+
"compose",
159+
"brainstorm",
160+
"creative",
161+
"imagine",
162+
"write a",
163+
"故事",
164+
"诗",
165+
"创作",
166+
"头脑风暴",
167+
"创意",
168+
"想象",
85169
]
86170

87171
AGENTIC_KEYWORDS = [
88-
"read file", "read the file", "look at", "check the", "open the",
89-
"edit", "modify", "update the", "change the", "write to", "create file",
90-
"execute", "deploy", "install", "npm", "pip", "compile",
91-
"after that", "and also", "once done", "step 1", "step 2",
92-
"fix", "debug", "until it works", "keep trying", "iterate",
93-
"make sure", "verify", "confirm",
172+
"read file",
173+
"read the file",
174+
"look at",
175+
"check the",
176+
"open the",
177+
"edit",
178+
"modify",
179+
"update the",
180+
"change the",
181+
"write to",
182+
"create file",
183+
"execute",
184+
"deploy",
185+
"install",
186+
"npm",
187+
"pip",
188+
"compile",
189+
"after that",
190+
"and also",
191+
"once done",
192+
"step 1",
193+
"step 2",
194+
"fix",
195+
"debug",
196+
"until it works",
197+
"keep trying",
198+
"iterate",
199+
"make sure",
200+
"verify",
201+
"confirm",
94202
]
95203

96204
# Tier boundaries on weighted score axis
@@ -122,7 +230,11 @@ class ScoringResult(TypedDict):
122230
},
123231
"MEDIUM": {
124232
"primary": "xai/grok-code-fast-1",
125-
"fallback": ["google/gemini-2.5-flash", "deepseek/deepseek-chat", "xai/grok-4-1-fast-non-reasoning"],
233+
"fallback": [
234+
"google/gemini-2.5-flash",
235+
"deepseek/deepseek-chat",
236+
"xai/grok-4-1-fast-non-reasoning",
237+
],
126238
},
127239
"COMPLEX": {
128240
"primary": "google/gemini-3-pro-preview",
@@ -302,10 +414,7 @@ def classify_by_rules(
302414
agentic_score = 0.0
303415

304416
# Compute weighted score
305-
weighted_score = sum(
306-
scores.get(dim, 0) * weight
307-
for dim, weight in DIMENSION_WEIGHTS.items()
308-
)
417+
weighted_score = sum(scores.get(dim, 0) * weight for dim, weight in DIMENSION_WEIGHTS.items())
309418

310419
# Check for reasoning override (2+ reasoning markers = REASONING)
311420
reasoning_matches = [kw for kw in REASONING_KEYWORDS if kw.lower() in user_text]
@@ -327,13 +436,13 @@ def classify_by_rules(
327436
tier = "MEDIUM"
328437
distance = min(
329438
weighted_score - TIER_BOUNDARIES["simple_medium"],
330-
TIER_BOUNDARIES["medium_complex"] - weighted_score
439+
TIER_BOUNDARIES["medium_complex"] - weighted_score,
331440
)
332441
elif weighted_score < TIER_BOUNDARIES["complex_reasoning"]:
333442
tier = "COMPLEX"
334443
distance = min(
335444
weighted_score - TIER_BOUNDARIES["medium_complex"],
336-
TIER_BOUNDARIES["complex_reasoning"] - weighted_score
445+
TIER_BOUNDARIES["complex_reasoning"] - weighted_score,
337446
)
338447
else:
339448
tier = "REASONING"

0 commit comments

Comments
 (0)