Skip to content

Commit

Permalink
🔧 Refactor Gemini payload generation: improve tool processing and add…
Browse files Browse the repository at this point in the history
… conditional tool inclusion
  • Loading branch information
yym68686 committed Feb 1, 2025
1 parent 1b165d5 commit 93e2902
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions request.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,18 +287,20 @@ async def get_gemini_payload(request, engine, provider):
prop_value["description"] = f"{description}\nDefault: {default_value}"
# 删除 default 字段
del prop_value["default"]
processed_tools.append({"function": function_def})

payload.update({
"tools": [{
"function_declarations": [tool["function"] for tool in processed_tools]
}],
"tool_config": {
"function_calling_config": {
"mode": "AUTO"
if function_def["name"] != "googleSearch" and function_def["name"] != "googleSearch":
processed_tools.append({"function": function_def})

if processed_tools:
payload.update({
"tools": [{
"function_declarations": [tool["function"] for tool in processed_tools]
}],
"tool_config": {
"function_calling_config": {
"mode": "AUTO"
}
}
}
})
})
elif field == "temperature":
generation_config["temperature"] = value
elif field == "max_tokens":
Expand Down

0 comments on commit 93e2902

Please sign in to comment.