-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat: Reflect Pydantic Field metadata (description and required) in function declarations #3353
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
base: main
Are you sure you want to change the base?
feat: Reflect Pydantic Field metadata (description and required) in function declarations #3353
Conversation
…unction declarations
Summary of ChangesHello @t-miyak, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the function declaration generation process by integrating Pydantic Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Response from ADK Triaging Agent Hello @t-miyak, thank you for creating this PR! To help reviewers evaluate your contribution, could you please address the following points from our contribution guidelines:
This information will help us to review your PR more efficiently. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request adds a valuable feature to reflect Pydantic Field metadata, such as descriptions and required status, in the generated function declaration schemas. The implementation correctly extracts this information, and the new unit test is comprehensive, covering various scenarios with nested models and different field types. I have one suggestion to slightly refactor the code for improved efficiency and clarity. Overall, the changes are well-implemented and tested.
| schema.required = [ | ||
| field_name | ||
| for field_name, field_info in param.annotation.model_fields.items() | ||
| if field_info.is_required() | ||
| ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For better performance and code clarity, you can determine the required fields within the main loop that processes each field (lines 291-305), rather than iterating over model_fields a second time here. You could initialize schema.required = [] before the loop, and then append field_name to it inside the loop when field_info.is_required() is true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed by 7709595...ad8a0e4
|
Hi @t-miyak , Thank you for your contribution! |
Summary
Implements support for propagating Pydantic
Fieldmetadata (descriptions and required fields) to function declaration schemas, enabling LLMs to receive accurate parameter information when using Pydantic models as function tool arguments.