From ebe224b0a1c02f1b7bbb091fca45556c2385c99f Mon Sep 17 00:00:00 2001 From: SengokuCola <1026294844@qq.com> Date: Thu, 13 Nov 2025 23:43:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:bool=E5=92=8Cboolean=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/llm_models/model_client/gemini_client.py | 7 ++++++- src/llm_models/model_client/openai_client.py | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/llm_models/model_client/gemini_client.py b/src/llm_models/model_client/gemini_client.py index 7d74386f..444c5671 100644 --- a/src/llm_models/model_client/gemini_client.py +++ b/src/llm_models/model_client/gemini_client.py @@ -143,8 +143,13 @@ def _convert_tool_options(tool_options: list[ToolOption]) -> list[FunctionDeclar :param tool_option_param: 工具参数对象 :return: 转换后的工具参数字典 """ + # JSON Schema要求使用"boolean"而不是"bool" + param_type_value = tool_option_param.param_type.value + if param_type_value == "bool": + param_type_value = "boolean" + return_dict: dict[str, Any] = { - "type": tool_option_param.param_type.value, + "type": param_type_value, "description": tool_option_param.description, } if tool_option_param.enum_values: diff --git a/src/llm_models/model_client/openai_client.py b/src/llm_models/model_client/openai_client.py index 069dac74..01e12588 100644 --- a/src/llm_models/model_client/openai_client.py +++ b/src/llm_models/model_client/openai_client.py @@ -118,8 +118,13 @@ def _convert_tool_options(tool_options: list[ToolOption]) -> list[dict[str, Any] :param tool_option_param: 工具参数对象 :return: 转换后的工具参数字典 """ + # JSON Schema要求使用"boolean"而不是"bool" + param_type_value = tool_option_param.param_type.value + if param_type_value == "bool": + param_type_value = "boolean" + return_dict: dict[str, Any] = { - "type": tool_option_param.param_type.value, + "type": param_type_value, "description": tool_option_param.description, } if tool_option_param.enum_values: