feat(tools): Add LangExtract tool for structured information extraction#92
feat(tools): Add LangExtract tool for structured information extraction#92its-animay wants to merge 1 commit intogoogle:mainfrom
Conversation
Summary of ChangesHello @its-animay, 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 integrates Google's LangExtract library into the ADK community tools, providing a Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
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.
Code Review
This pull request introduces a LangExtractTool to integrate the langextract library for structured information extraction. The implementation is well-structured, including a tool class, a configuration class, and comprehensive unit tests. The use of asyncio.to_thread for the synchronous lx.extract call is correct and important for an async application. My main feedback is a suggestion to use Python's dataclasses for the configuration class to reduce boilerplate code, which is a common practice for such data-holding classes.
Add LangExtractTool to the community tools module, enabling ADK agents to extract structured data (entities, attributes, relationships) from unstructured text using Google's LangExtract library. - New: src/google/adk_community/tools/langextract_tool.py - New: src/google/adk_community/tools/__init__.py - New: tests/unittests/tools/test_langextract_tool.py - Updated: pyproject.toml with langextract optional dependency - Updated: adk_community __init__.py to expose tools module LangExtractToolConfig uses @DataClass for concise, idiomatic config.
d1874a4 to
6c77a0c
Compare
|
@gemini-cli /review |
|
🤖 Hi @DeanChensj, I've received your request, and I'm working on it now! You can track my progress in the logs for more details. |
There was a problem hiding this comment.
Thanks for the contribution! The tool implementation looks solid and the tests are comprehensive.
However, there is a critical issue with how the langextract dependency is handled. Since it's an optional dependency, it shouldn't cause an ImportError when the main package is imported. Currently, the module-level raise ImportError will break the package for any user who hasn't installed the langextract extra.
Please move the dependency check to be more lazy (e.g., inside __init__ or run_async).
I also noticed the default model_id is gemini-2.5-flash. While this matches some other samples in the repo, please confirm if this is the intended default or if it should be a publicly available model like gemini-2.0-flash.
| except ImportError as e: | ||
| raise ImportError( | ||
| 'LangExtract tools require pip install langextract.' | ||
| ) from e |
There was a problem hiding this comment.
This ImportError is raised at module load time. Since google.adk_community.tools is imported by google.adk_community.__init__, this will cause the entire package to fail on import if langextract is not installed.
Since langextract is an optional dependency in pyproject.toml, it should not block the import of the main package.
Consider moving the check inside the __init__ of LangExtractTool or handling it more gracefully at the module level (e.g., setting lx = None and checking it later).
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
Problem:
ADK community lacks a native tool integration for LangExtract, Google's library for extracting structured information from unstructured text using LLMs. Users must manually wrap `lx.extract()` in custom tool classes.
Solution:
Add `LangExtractTool(BaseTool)` to the `google.adk_community.tools` module. This was originally submitted to adk-python#4549 and redirected here by the maintainers.
Changes:
Testing Plan
Unit Tests:
Manual End-to-End (E2E) Tests:
Checklist
Additional context