Skip to content

Fix(FlowiseChatGoogleGenerativeAI): 400 Bad Request errors from Gemini API when converting tool schemas - MCP tools. #4294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 14, 2025

Conversation

toi500
Copy link
Contributor

@toi500 toi500 commented Apr 13, 2025

Issue

This PR fixes the 400 Bad Request errors when using function calling with Gemini API when MCP tools are used. The main issue was that some properties in the tool schemas were missing explicit type definitions when converting from Zod schemas to Gemini's function declarations format.

image

Changes

  • Enhanced zodToGeminiParameters function to properly infer types
  • Added explicit handling for enum types
  • Improved type inference based on property characteristics
  • Added fallback to string type when type cannot be inferred

Breaking Changes

None. This is a backward compatible enhancement to the existing functionality.

@HenryHengZJ HenryHengZJ merged commit 4009eb2 into FlowiseAI:main Apr 14, 2025
2 checks passed
Yshayy pushed a commit to Yshayy/Flowise that referenced this pull request Apr 23, 2025
…i API when converting tool schemas - MCP tools. (FlowiseAI#4294)

* fix: 400 Bad Request errors from Gemini API when converting tool schemas (MCP tools).

* Update FlowiseChatGoogleGenerativeAI.ts

---------

Co-authored-by: Henry Heng <[email protected]>
@toi500 toi500 deleted the gemini-fix-mcp branch April 23, 2025 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants