-
Notifications
You must be signed in to change notification settings - Fork 303
refactor(utils): move part helpers & add artifact text extractor #517
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
refactor(utils): move part helpers & add artifact text extractor #517
Conversation
Summary of ChangesHello @martimfasantos, 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 codebase's maintainability and clarity by reorganizing utility functions. It isolates "Part" object handling into its own module, "src/a2a/utils/parts.py", and introduces a new function for extracting text from "Artifacts". These changes streamline the codebase, making it easier to understand and manage related functionalities. 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
|
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 does a good job of refactoring the part-related utility functions into a new parts.py module, which improves code organization. The addition of get_artifact_text is also a useful helper.
However, I've found a critical issue with circular dependencies introduced by the new imports in artifact.py and message.py. Both modules now import from the a2a.utils package, which itself imports from them, creating a cycle. My review comments provide suggestions to fix this by preventing runtime import errors.
Additionally, there are a couple of points regarding testing:
- The new function
get_artifact_textis missing unit tests. I've added a suggestion to include them. - The existing tests for the moved functions (
get_text_parts, etc.) intests/utils/test_message.pywill likely fail because the functions have been moved. These tests should be updated to import from the new location (a2a.utils.partsora2a.utils) and ideally moved to a newtests/utils/test_parts.pyfile to align with the new code structure. It seems the test files were not part of this PR, so you'll need to add them.
Description
This pull request refactors utility functions for handling
Partobjects by moving them fromsrc/a2a/utils/message.pyto a new dedicated modulesrc/a2a/utils/parts.py. It also introduces a new helper function for extracting text fromArtifactsand updates imports and exports to reflect these changes. The goal is to improve code organization and clarity by grouping similar functionality.Refactoring and organization:
get_text_parts,get_data_parts, andget_file_partsfromsrc/a2a/utils/message.pyinto a new modulesrc/a2a/utils/parts.py, providing better separation of concerns for part-handling utilities. [1] [2]src/a2a/utils/__init__.pyto re-export these part-handling functions from the newpartsmodule, and removed their previous import from themessagemodule. [1] [2] [3]New functionality:
get_artifact_texttosrc/a2a/utils/artifact.pyfor extracting and joining all text content from an artifact's parts, using the refactoredget_text_parts. [1] [2] [3] [4]These changes improve maintainability by clearly separating message-related and part-related utilities, and by introducing a helper for artifact text extraction.
BEGIN_COMMIT_OVERRIDE
refactor(utils): move part helpers to their own file
feat: add
get_artifact_text()helper methodRelease-As: 0.3.10
END_COMMIT_OVERRIDE