Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions astrbot/core/provider/sources/openai_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,18 @@ async def _query(self, payloads: dict, tools: ToolSet | None) -> LLMResponse:
omit_empty_parameter_field=omit_empty_param_field,
)
if tool_list:
# 清洗Gemini中的examples字段
if "gemini" in model:
def remove_examples(schema):
if isinstance(schema, dict):
schema.pop("examples", None)
for val in schema.values():
remove_examples(val)
elif isinstance(schema, list):
for item in schema:
remove_examples(item)

remove_examples(tool_list)
Comment thread
konodiodaaaaa1 marked this conversation as resolved.
Outdated
payloads["tools"] = tool_list
payloads["tool_choice"] = payloads.get("tool_choice", "auto")

Expand Down Expand Up @@ -599,6 +611,18 @@ async def _query_stream(
omit_empty_parameter_field=omit_empty_param_field,
)
if tool_list:
# 清洗Gemini中的examples字段
if "gemini" in model:
def remove_examples(schema):
if isinstance(schema, dict):
schema.pop("examples", None)
for val in schema.values():
remove_examples(val)
elif isinstance(schema, list):
for item in schema:
remove_examples(item)

remove_examples(tool_list)
Comment thread
konodiodaaaaa1 marked this conversation as resolved.
Outdated
payloads["tools"] = tool_list
payloads["tool_choice"] = payloads.get("tool_choice", "auto")

Expand Down