From ffe3d0b2cdb2160af9352dbdfa6d0c8c45f8b368 Mon Sep 17 00:00:00 2001 From: ehhuang Date: Thu, 1 May 2025 13:17:36 -0700 Subject: [PATCH] fix: nullable param type for function call (#2086) Nullable param type is not supported, e.g. ['string', 'null'], since it fails type validation. Tests: Run inference with messages: - content: You are a helpful assistant that can use tools to get information. role: system - content: What's the temperature in San Francisco in celsius? role: user tools: - function: description: Get current temperature for a given location. name: get_weather parameters: additionalProperties: false properties: location: description: "City and country e.g. Bogot\xE1, Colombia" type: string unit: description: "Unit of temperature, default to celsius" type: [string, "null"] # <= nullable type required: - location type: object type: function Co-authored-by: Eric Huang --- llama_stack/providers/utils/inference/openai_compat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llama_stack/providers/utils/inference/openai_compat.py b/llama_stack/providers/utils/inference/openai_compat.py index 1a8d82de2..d9dfba110 100644 --- a/llama_stack/providers/utils/inference/openai_compat.py +++ b/llama_stack/providers/utils/inference/openai_compat.py @@ -873,7 +873,7 @@ def _convert_openai_request_tools(tools: Optional[List[Dict[str, Any]]] = None) tool_param_properties = tool_params.get("properties", {}) for tool_param_key, tool_param_value in tool_param_properties.items(): tool_param_def = ToolParamDefinition( - param_type=tool_param_value.get("type", None), + param_type=str(tool_param_value.get("type", None)), description=tool_param_value.get("description", None), ) lls_tool_params[tool_param_key] = tool_param_def