fix: 保证Gemini anyOf 字段唯一

This commit is contained in:
Raven95676
2025-05-02 10:56:05 +08:00
parent 05c686782c
commit 4d1a6994aa
+5 -2
View File
@@ -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