Gemini: Only register custom tools when there are no function tools

This commit is contained in:
Cohee
2025-11-28 20:22:05 +02:00
parent 068c6bdccd
commit 3b59eae7c0
+6 -1
View File
@@ -423,6 +423,7 @@ async function sendMakerSuiteRequest(request, response) {
if (Array.isArray(request.body.tools) && request.body.tools.length > 0 && !enableImageModality && !isGemma) {
const functionDeclarations = [];
const customTools = [];
for (const tool of request.body.tools) {
if (tool.type === 'function') {
if (tool.function.parameters?.$schema) {
@@ -433,12 +434,16 @@ async function sendMakerSuiteRequest(request, response) {
}
functionDeclarations.push(tool.function);
} else if (tool[tool.type]) {
tools.push({ [tool.type]: tool[tool.type] });
customTools.push({ [tool.type]: tool[tool.type] });
}
}
if (functionDeclarations.length > 0) {
tools.push({ function_declarations: functionDeclarations });
}
// Custom tools are only supported when no function calling is present
if (functionDeclarations.length === 0 && customTools.length > 0) {
tools.push(...customTools);
}
}
if (enableWebSearch && !enableImageModality && !isGemma && !isLearnLM && !noSearchModels.includes(model)) {