1212pytestmark = pytest .mark .threadleak (enabled = False )
1313
1414
15- @pytest .fixture (scope = "module" , ids = ["GPT-OSS-20B" ])
16- def model ():
17- return "gpt_oss/gpt-oss-20b/"
15+ @pytest .fixture (scope = "module" ,
16+ params = [
17+ "gpt_oss/gpt-oss-20b" , "DeepSeek-R1-Distill-Qwen-1.5B" ,
18+ "Qwen3/Qwen3-0.6B"
19+ ])
20+ def model (request ):
21+ return request .param
1822
1923
2024@pytest .fixture (scope = "module" )
2125def server (model : str ):
2226 model_path = get_model_path (model )
23- with RemoteOpenAIServer (model_path ) as remote_server :
27+
28+ args = []
29+ if model .startswith ("Qwen3" ):
30+ args .extend (["--reasoning_parser" , "qwen3" ])
31+ elif model .startswith ("DeepSeek-R1" ):
32+ args .extend (["--reasoning_parser" , "deepseek-r1" ])
33+
34+ if not model .startswith ("gpt_oss" ):
35+ args .extend (["--tool_parser" , "qwen3" ])
36+
37+ with RemoteOpenAIServer (model_path , args ) as remote_server :
2438 yield remote_server
2539
2640
@@ -43,24 +57,30 @@ def check_reponse(response, prefix=""):
4357
4458def check_tool_calling (response , first_resp = True , prefix = "" ):
4559 reasoning_exist , tool_call_exist , message_exist = False , False , False
60+ reasoning_content , message_content = "" , ""
4661 function_call = None
4762 for output in response .output :
4863 if output .type == "reasoning" :
4964 reasoning_exist = True
65+ reasoning_content = output .content [0 ].text
5066 elif output .type == "function_call" :
5167 tool_call_exist = True
5268 function_call = output
5369 elif output .type == "message" :
5470 message_exist = True
71+ message_content = output .content [0 ].text
5572
73+ err_msg = f"{ prefix } Invalid tool calling { '1st' if first_resp else '2nd' } response:"
5674 if first_resp :
57- assert reasoning_exist and tool_call_exist , f"{ prefix } Invalid tool calling 1st response"
58- assert not message_exist , f"{ prefix } Invalid tool calling 1st response"
75+ assert reasoning_exist , f"{ err_msg } reasoning content not exists! ({ reasoning_content } )"
76+ assert tool_call_exist , f"{ err_msg } tool call content not exists! ({ function_call } )"
77+ assert not message_exist , f"{ err_msg } message content should not exist! ({ message_content } )"
5978
6079 return function_call
6180 else :
62- assert reasoning_exist and message_exist , f"{ prefix } Invalid tool calling 2nd response"
63- assert not tool_call_exist , f"{ prefix } Invalid tool calling 2nd response"
81+ assert reasoning_exist , f"{ err_msg } reasoning content not exists! ({ reasoning_content } )"
82+ assert message_exist , f"{ err_msg } message content not exists! ({ message_content } )"
83+ assert not tool_call_exist , f"{ err_msg } tool call content should not exist! ({ function_call } )"
6484
6585
6686@pytest .mark .asyncio (loop_scope = "module" )
@@ -124,6 +144,9 @@ def get_current_weather(location: str, format: str = "celsius") -> dict:
124144
125145@pytest .mark .asyncio (loop_scope = "module" )
126146async def test_tool_calls (client : openai .AsyncOpenAI , model : str ):
147+ if model .startswith ("DeepSeek-R1" ):
148+ pytest .skip ("DeepSeek-R1 does not support tool calls" )
149+
127150 tool_get_current_weather = {
128151 "type" : "function" ,
129152 "name" : "get_current_weather" ,
@@ -193,6 +216,9 @@ async def test_streaming(client: openai.AsyncOpenAI, model: str):
193216
194217@pytest .mark .asyncio (loop_scope = "module" )
195218async def test_streaming_tool_call (client : openai .AsyncOpenAI , model : str ):
219+ if model .startswith ("DeepSeek-R1" ):
220+ pytest .skip ("DeepSeek-R1 does not support tool calls" )
221+
196222 tool_get_current_weather = {
197223 "type" : "function" ,
198224 "name" : "get_current_weather" ,
@@ -231,6 +257,8 @@ async def test_streaming_tool_call(client: openai.AsyncOpenAI, model: str):
231257 elif isinstance (event , ResponseReasoningTextDeltaEvent ):
232258 reasoning_deltas .append (event .delta )
233259
260+ assert function_call is not None , "function call not exists!"
261+
234262 reasoning = "" .join (reasoning_deltas )
235263 tool_args = json .loads (function_call .arguments )
236264
0 commit comments