diff --git a/python/sglang/test/tool_call_test_runner.py b/python/sglang/test/tool_call_test_runner.py index b94ec14da..a030d5605 100644 --- a/python/sglang/test/tool_call_test_runner.py +++ b/python/sglang/test/tool_call_test_runner.py @@ -77,15 +77,28 @@ ADD_TOOL_STRICT = { "function": {**ADD_TOOL["function"], "strict": True}, } +WEATHER_TOOL_STRICT = { + "type": "function", + "function": {**WEATHER_TOOL["function"], "strict": True}, +} -def _call(client, model, content, tools=None, tool_choice="required", **kwargs): + +def _call( + client, + model, + content, + tools=None, + tool_choice="required", + temperature=0.1, + **kwargs, +): """Single-turn tool call request. Defaults to ADD_TOOL_STRICT + required.""" return client.chat.completions.create( model=model, messages=[{"role": "user", "content": content}], tools=tools or [ADD_TOOL_STRICT], tool_choice=tool_choice, - temperature=0.1, + temperature=temperature, **kwargs, ) @@ -265,8 +278,10 @@ def _test_parallel(client, model): response = _call( client, model, - "What is 3+5 and what is the weather in Tokyo?", - tools=[ADD_TOOL, WEATHER_TOOL], + "Please call both functions: use add to compute 3+5, and use get_weather to check the weather in Tokyo.", + tools=[ADD_TOOL_STRICT, WEATHER_TOOL_STRICT], + tool_choice="auto", + temperature=0, ) tc = response.choices[0].message.tool_calls assert tc and len(tc) >= 2, f"expected >= 2 tool calls, got {len(tc) if tc else 0}" @@ -329,11 +344,11 @@ def run_tool_call_test( """Launch server, run enabled test cases, return results.""" base_url = base_url or DEFAULT_URL_FOR_TEST - print(f"\n{'='*60}") + print(f"\n{'=' * 60}") print(f"Running TOOL CALL test for {model.model_path}") if model.variant: print(f" Variant: {model.variant}") - print(f"{'='*60}\n") + print(f"{'=' * 60}\n") process = None try: