| 433 | } | 434 | } |
| 434 | functionDeclarations.push(tool.function); | 435 | functionDeclarations.push(tool.function); |
| 435 | } else if (tool[tool.type]) { | 436 | } else if (tool[tool.type]) { |
| 436 | tools.push({ [tool.type]: tool[tool.type] }); | 437 | customTools.push({ [tool.type]: tool[tool.type] }); |
| 437 | } | 438 | } |
| 438 | } | 439 | } |
| 439 | if (functionDeclarations.length > 0) { | 440 | if (functionDeclarations.length > 0) { |
| 440 | tools.push({ function_declarations: functionDeclarations }); | 441 | tools.push({ function_declarations: functionDeclarations }); |
| 441 | } | 442 | } |
| | 443 | // Custom tools are only supported when no function calling is present |
| | 444 | if (functionDeclarations.length === 0 && customTools.length > 0) { |
| | 445 | tools.push(...customTools); |
| | 446 | } |
| 442 | } | 447 | } |
| 443 | | 448 | |
| 444 | if (enableWebSearch && !enableImageModality && !isGemma && !isLearnLM && !noSearchModels.includes(model)) { | 449 | if (enableWebSearch && !enableImageModality && !isGemma && !isLearnLM && !noSearchModels.includes(model)) { |