Skip to content

Conversation

@Hardik450
Copy link


PR Description

Refactored the _convert_pydantic_to_genai_function function to improve compatibility with Gemini's function_declarations format. The internal logic was updated to ensure that a pydantic.BaseModel is properly converted to Gemini-compatible tool definitions. No changes were made to the function name, signature, or external interface.

Relevant issues

N/A

Type

🐛 Bug Fix
🧹 Refactoring

Changes

  • Rewrote the internal logic of _convert_pydantic_to_genai_function to:

    • Automatically generate the function_declarations list
    • Extract function name from model class name if not explicitly provided
    • Use model’s docstring for description

Copy link
Author

@Hardik450 Hardik450 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

},
)
return function_declaration
def _convert_pydantic_to_genai_function(model: BaseModel, function_name: str = None) -> dict:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add test and inline citation to the Gemini function tool schema? Also run lint please 🥺

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, it will take time for me so i will try to make updates within 2 weeks.

Copy link
Author

@Hardik450 Hardik450 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doing it now

@mdrxy mdrxy changed the title Improve _convert_pydantic_to_genai_function utility genai: improve _convert_pydantic_to_genai_function() Sep 17, 2025
@mdrxy mdrxy added the genai label Sep 17, 2025
@Hardik450 Hardik450 closed this Sep 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants