From 4d1a6994aa369da474a898d636efc04e3517d78d Mon Sep 17 00:00:00 2001 From: Raven95676 Date: Fri, 2 May 2025 10:56:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=9D=E8=AF=81Gemini=20anyOf=20?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E5=94=AF=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astrbot/core/provider/func_tool_manager.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/astrbot/core/provider/func_tool_manager.py b/astrbot/core/provider/func_tool_manager.py index c406dc804..1ce1efbae 100644 --- a/astrbot/core/provider/func_tool_manager.py +++ b/astrbot/core/provider/func_tool_manager.py @@ -457,6 +457,11 @@ class FuncCall: def convert_schema(schema: dict) -> dict: """转换 schema 为 Gemini API 格式""" + + # 如果 schema 包含 anyOf,则只返回 anyOf 字段 + if "anyOf" in schema: + return {"anyOf": [convert_schema(s) for s in schema["anyOf"]]} + result = {} if "type" in schema and schema["type"] in supported_types: @@ -495,8 +500,6 @@ class FuncCall: if "items" in schema: result["items"] = convert_schema(schema["items"]) - if "anyOf" in schema: - result["anyOf"] = [convert_schema(s) for s in schema["anyOf"]] return result