From 3b964307ce3c9e25d08964e5c1b021fd7132e704 Mon Sep 17 00:00:00 2001 From: xiaoxi68 <3520824673@qq.com> Date: Thu, 11 Dec 2025 20:00:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E8=B0=83=E7=94=A8=20JSON=20Schema=20=E4=B8=AD=20float=20?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E5=AF=BC=E8=87=B4=E7=9A=84=20422=20=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/llm_models/model_client/gemini_client.py | 6 +++++- src/llm_models/model_client/openai_client.py | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/llm_models/model_client/gemini_client.py b/src/llm_models/model_client/gemini_client.py index b3fafca0..b52474e4 100644 --- a/src/llm_models/model_client/gemini_client.py +++ b/src/llm_models/model_client/gemini_client.py @@ -143,10 +143,14 @@ def _convert_tool_options(tool_options: list[ToolOption]) -> list[FunctionDeclar :param tool_option_param: 工具参数对象 :return: 转换后的工具参数字典 """ - # JSON Schema要求使用"boolean"而不是"bool" + # JSON Schema 类型名称修正: + # - 布尔类型使用 "boolean" 而不是 "bool" + # - 浮点数使用 "number" 而不是 "float" param_type_value = tool_option_param.param_type.value if param_type_value == "bool": param_type_value = "boolean" + elif param_type_value == "float": + param_type_value = "number" return_dict: dict[str, Any] = { "type": param_type_value, diff --git a/src/llm_models/model_client/openai_client.py b/src/llm_models/model_client/openai_client.py index f573d33e..5793d4f9 100644 --- a/src/llm_models/model_client/openai_client.py +++ b/src/llm_models/model_client/openai_client.py @@ -118,10 +118,14 @@ def _convert_tool_options(tool_options: list[ToolOption]) -> list[dict[str, Any] :param tool_option_param: 工具参数对象 :return: 转换后的工具参数字典 """ - # JSON Schema要求使用"boolean"而不是"bool" + # JSON Schema 类型名称修正: + # - 布尔类型使用 "boolean" 而不是 "bool" + # - 浮点数使用 "number" 而不是 "float" param_type_value = tool_option_param.param_type.value if param_type_value == "bool": param_type_value = "boolean" + elif param_type_value == "float": + param_type_value = "number" return_dict: dict[str, Any] = { "type": param_type_value,