google / google/adk-python

feat: Add LangExtract tool integration for structured information extraction

Đã đóng
#4,548 1 bình luận 0 reaction 1 người được giao Được @GWeale nhận Xem trên GitHub
community repo needs review tools
Ngôn ngữ chính
Python
Star
21.5k
Fork
4k
Merge trung bình
1 ngày 14 giờ
Pull request đã merge (30 ngày)
37

Mô tả

## 🔴 Required Information

### Is your feature request related to a specific problem?

ADK currently has tool adapters for LangChain (`LangchainTool`) and CrewAI (`CrewaiTool`), but lacks a native integration for [LangExtract](https://github.com/google/langextract) — Google's own library for extracting structured information from unstructured text using LLMs with precise source grounding.

Users who want to use LangExtract within ADK agents currently have to manually wrap `lx.extract()` in a `FunctionTool` or `BaseTool` subclass, which requires boilerplate and doesn't follow ADK conventions.

### Describe the Solution You'd Like

Add a first-class `LangExtractTool` adapter in `src/google/adk/tools/langextract_tool.py` that:

- Extends `BaseTool` with a custom function declaration exposing `text` and `prompt_description` as LLM-visible parameters
- Pre-configures extraction settings (examples, model_id, extraction_passes, etc.) at construction time
- Runs `lx.extract()` via `asyncio.to_thread()` to avoid blocking the event loop
- Includes a companion `LangExtractToolConfig` for YAML-based agent configuration
- Follows the same patterns as `LangchainTool` and `CrewaiTool` (ImportError handling, `from_config()`, etc.)

### Impact on your work

This enables ADK agents to perform structured extraction (entities, attributes, relationships) from documents out of the box, which is a common use case for enterprise AI workflows. Since LangExtract is a Google library, having native ADK support is a natural fit.

### Willingness to contribute

Yes — I have an implementation ready to submit as a PR.

---

## 🟡 Recommended Information

### Proposed API / Implementation

```python
import langextract as lx
from google.adk.tools.langextract_tool import LangExtractTool

tool = LangExtractTool(
name='extract_entities',
description='Extract named entities from text.',
examples=[lx.data.ExampleData(...)],
model_id='gemini-2.5-flash',
)

agent = Agent(model='gemini-2.5-flash', name='extraction_agent', tools=[tool])
```

### Additional Context

- LangExtract repo: https://github.com/google/langextract
- Follows the same adapter pattern as `LangchainTool` and `CrewaiTool`
- Includes unit tests with mocked `lx.extract()` calls

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.