feat(tools): Add LangExtract tool integration for structured extraction#4549
feat(tools): Add LangExtract tool integration for structured extraction#4549its-animay wants to merge 2 commits intogoogle:mainfrom
Conversation
Add LangExtractTool as a first-class tool adapter in ADK, enabling agents to extract structured information from unstructured text using Google's LangExtract library. Follows the same integration pattern as LangchainTool and CrewaiTool.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
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 enhances the ADK by providing a first-class tool integration for Google's 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
|
|
Response from ADK Triaging Agent Hello @its-animay, thank you for your contribution! It looks like the Contributor License Agreement (CLA) is not signed yet. Please sign the CLA so that we can proceed with the review process. You can find more information in the "Details" link of the Thanks! |
There was a problem hiding this comment.
Code Review
This pull request introduces a new LangExtractTool for structured data extraction, along with its configuration and comprehensive unit tests. The implementation is clean and follows existing patterns in the codebase. I've provided a couple of suggestions to improve maintainability and test coverage. Overall, this is a great addition.
- Simplify from_config() using dict unpacking instead of passing each arg manually, improving maintainability - Parameterize _get_declaration test to cover both JSON schema and types.Schema code paths via temporary_feature_override
|
Hi @its-animay , Thank you for your contribution! We appreciate you taking the time to submit this pull request. |
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):
2. Or, if no issue exists, describe the change:
N/A — see linked issue above.
Problem:
ADK 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)as a first-class tool adapter following the same patterns asLangchainToolandCrewaiTool.Changes:
src/google/adk/tools/langextract_tool.py—LangExtractToolclass extendingBaseToolwith custom function declaration,asyncio.to_thread()execution,from_config()support, and companionLangExtractToolConfigtests/unittests/tools/test_langextract_tool.py— 8 unit tests covering initialization, schema, execution, error handling, and configpyproject.toml— Addedlangextract>=0.1.0totestandextensionsoptional dependenciesTesting Plan
Unit Tests:
Existing tests also pass with no regressions (
test_langchain_tool.py,test_base_tool.py).Manual End-to-End (E2E) Tests:
Usage example:
Checklist
Additional context
LangchainTool(langchain_tool.py) andCrewaiTool(crewai_tool.py)BaseTool(notFunctionTool) because LangExtract exposes an API function rather than tool objectsasyncio.to_thread()for non-blocking execution of the synchronouslx.extract()_get_declaration()supporting bothparameters_json_schemaandtypes.Schema(matchingBaseRetrievalToolpattern)pyinkandisortper project conventions