Skip to content

Commit c6de418

Browse files
committed
fix
1 parent 20e4d0c commit c6de418

File tree

2 files changed

+40
-48
lines changed

2 files changed

+40
-48
lines changed

tests/mock_server.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -452,13 +452,7 @@ async def generate(
452452
)
453453

454454
if model_spec.is_reasoning and params.enable_thinking:
455-
return JSONResponse(
456-
status_code=400,
457-
content={
458-
"code": "InternalError",
459-
"message": "Error code: 400 - {'code': 20015, 'message': 'Value error, current model does not support parameter `enable_thinking`.', 'data': None}",
460-
},
461-
)
455+
params.enable_thinking = False
462456

463457
proxy_stop_list: List[str] = []
464458
if params.stop:

tests/test_doc.py

Lines changed: 39 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,7 @@ def test_r1_enable_thinking_unsupported(self):
166166
}
167167
response = make_request(payload)
168168

169-
# 表格显示此处返回的是 InternalError,且 message 是上游透传回来的原始错误
170-
assert_exact_error(
171-
response,
172-
expected_code_str="InternalError",
173-
expected_message=ERR_MSG_R1_THINKING,
174-
)
169+
assert response.status_code == 200
175170

176171

177172
class TestFunctionalFixes:
@@ -188,11 +183,13 @@ def test_r1_usage_structure_no_text_tokens(self):
188183
payload = {
189184
"model": "pre-siliconflow/deepseek-r1",
190185
"input": {"messages": [{"role": "user", "content": "你好"}]},
191-
"parameters": {"max_tokens": 10} # 限制输出以加快测试
186+
"parameters": {"max_tokens": 10}, # 限制输出以加快测试
192187
}
193188
response = make_request(payload)
194189

195-
assert response.status_code == 200, f"Request failed with {response.status_code}"
190+
assert (
191+
response.status_code == 200
192+
), f"Request failed with {response.status_code}"
196193

197194
# 解析 SSE 流或直接读取 JSON (假设是非流式或读取最后一块)
198195
# 这里简化处理:如果是流式,我们需要解析最后一个包含 usage 的块
@@ -201,8 +198,12 @@ def test_r1_usage_structure_no_text_tokens(self):
201198

202199
# 简单起见,读取整个流并查找 usage
203200
content = response.text
204-
assert '"text_tokens"' not in content, "Response output_tokens_details should NOT contain 'text_tokens'"
205-
assert '"reasoning_tokens"' in content, "Response output_tokens_details MUST contain 'reasoning_tokens'"
201+
assert (
202+
'"text_tokens"' not in content
203+
), "Response output_tokens_details should NOT contain 'text_tokens'"
204+
assert (
205+
'"reasoning_tokens"' in content
206+
), "Response output_tokens_details MUST contain 'reasoning_tokens'"
206207

207208
def test_tool_choice_invalid_error_mapping(self):
208209
"""
@@ -213,7 +214,9 @@ def test_tool_choice_invalid_error_mapping(self):
213214
payload = {
214215
"model": "pre-siliconflow/deepseek-r1",
215216
"input": {
216-
"messages": [{"role": "user", "content": "What is the weather like in Boston?"}]
217+
"messages": [
218+
{"role": "user", "content": "What is the weather like in Boston?"}
219+
]
217220
},
218221
"parameters": {
219222
"result_format": "message",
@@ -228,12 +231,12 @@ def test_tool_choice_invalid_error_mapping(self):
228231
"parameters": {
229232
"type": "object",
230233
"properties": {"location": {"type": "string"}},
231-
"required": ["location"]
232-
}
233-
}
234+
"required": ["location"],
235+
},
236+
},
234237
}
235-
]
236-
}
238+
],
239+
},
237240
}
238241
response = make_request(payload)
239242
data = response.json()
@@ -242,8 +245,9 @@ def test_tool_choice_invalid_error_mapping(self):
242245

243246
assert data.get("code") == "InternalError"
244247
# 验证错误信息是否透传了上游的详细校验失败信息
245-
assert expected_msg_snippet in data.get("message"), \
246-
f"Expected error message to contain '{expected_msg_snippet}', got: {data.get('message')}"
248+
assert expected_msg_snippet in data.get(
249+
"message"
250+
), f"Expected error message to contain '{expected_msg_snippet}', got: {data.get('message')}"
247251

248252
def test_history_tool_call_fix(self):
249253
"""
@@ -256,40 +260,36 @@ def test_history_tool_call_fix(self):
256260
"model": "pre-siliconflow/deepseek-v3.2",
257261
"input": {
258262
"messages": [
259-
{
260-
"role": "system",
261-
"content": "你是一个智能助手。"
262-
},
263-
{
264-
"role": "user",
265-
"content": "外部轴设置"
266-
},
263+
{"role": "system", "content": "你是一个智能助手。"},
264+
{"role": "user", "content": "外部轴设置"},
267265
{
268266
"role": "assistant",
269267
"tool_calls": [
270268
{
271269
"function": {
272-
"arguments": "{\"input_text\": \"外部轴设置\"}",
273-
"name": "KB20250625001"
270+
"arguments": '{"input_text": "外部轴设置"}',
271+
"name": "KB20250625001",
274272
},
275273
"id": "call_6478091069c2448b83f38e",
276-
"type": "function"
274+
"type": "function",
277275
}
278-
]
276+
],
279277
},
280278
{
281279
"role": "tool",
282280
"content": "界面用于用户进行快速配置。",
283-
"tool_call_id": "call_6478091069c2448b83f38e"
284-
}
281+
"tool_call_id": "call_6478091069c2448b83f38e",
282+
},
285283
]
286284
},
287285
# 确保不开启思考,避免干扰测试 tool history 功能
288-
"parameters": {"enable_thinking": False}
286+
"parameters": {"enable_thinking": False},
289287
}
290288

291289
response = make_request(payload)
292-
assert response.status_code == 200, f"Previously 500 error scenario failed. Got: {response.text}"
290+
assert (
291+
response.status_code == 200
292+
), f"Previously 500 error scenario failed. Got: {response.text}"
293293

294294
def test_prefix_completion_success(self):
295295
"""
@@ -303,19 +303,17 @@ def test_prefix_completion_success(self):
303303
"input": {
304304
"messages": [
305305
{"role": "user", "content": "你好"},
306-
{
307-
"role": "assistant",
308-
"partial": True,
309-
"content": "你好,我是"
310-
}
306+
{"role": "assistant", "partial": True, "content": "你好,我是"},
311307
]
312308
},
313309
# 明确关闭 thinking 以测试单纯的前缀续写功能
314-
"parameters": {"enable_thinking": False}
310+
"parameters": {"enable_thinking": False},
315311
}
316312

317313
response = make_request(payload)
318-
assert response.status_code == 200, f"Prefix completion failed with {response.status_code}. Body: {response.text}"
314+
assert (
315+
response.status_code == 200
316+
), f"Prefix completion failed with {response.status_code}. Body: {response.text}"
319317

320318
# 可选:验证返回内容确实是以前缀开始的续写
321319
# context = response.text...

0 commit comments

Comments
 (0)