fix TestOpenAIServingCompletion fail (#3368)

This commit is contained in:
memoryCoderC
2025-08-13 15:45:07 +08:00
committed by GitHub
parent d1a92e3e17
commit f702a675a1

View File

@@ -17,10 +17,10 @@ class TestOpenAIServingCompletion(unittest.TestCase):
engine_client.reasoning_parser = "ernie_x1"
# 创建一个OpenAIServingCompletion实例
serving_completion = OpenAIServingCompletion(engine_client, "pid", "ips", 360)
# 创建一个模拟的output并设置finish_reason为"tool_calls"
output = {"finish_reason": "tool_calls"}
# 创建一个模拟的output并设置finish_reason为"tool_call"
output = {"tool_call": "tool_call"}
# 调用calc_finish_reason方法
result = serving_completion.calc_finish_reason(None, 100, output)
result = serving_completion.calc_finish_reason(None, 100, output, False)
# 断言结果为"tool_calls"
assert result == "tool_calls"
@@ -33,7 +33,7 @@ class TestOpenAIServingCompletion(unittest.TestCase):
# 创建一个模拟的output并设置finish_reason为其他值
output = {"finish_reason": "other_reason"}
# 调用calc_finish_reason方法
result = serving_completion.calc_finish_reason(None, 100, output)
result = serving_completion.calc_finish_reason(None, 100, output, False)
# 断言结果为"stop"
assert result == "stop"
@@ -45,7 +45,7 @@ class TestOpenAIServingCompletion(unittest.TestCase):
# 创建一个模拟的output
output = {}
# 调用calc_finish_reason方法
result = serving_completion.calc_finish_reason(100, 100, output)
result = serving_completion.calc_finish_reason(100, 100, output, False)
# 断言结果为"length"
assert result == "length"
@@ -95,6 +95,7 @@ class TestOpenAIServingCompletion(unittest.TestCase):
model_name=model_name,
prompt_batched_token_ids=prompt_batched_token_ids,
completion_batched_token_ids=completion_batched_token_ids,
text_after_process_list=["1", "1"],
)
assert completion_response.id == request_id