google / google/adk-python-community

Add RedisVL Search Tools for Knowledge Base Retrieval

Đang mở
#42 0 bình luận 8 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
Python
Star
184
Fork
76
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

ADK has retrieval tools for Google Cloud (Vertex AI Search, Discovery Engine), but no self-hosted option for developers who need full control over their infrastructure. RAG is a fundamental pattern for building useful agents, these tools let developers add vector search, keyword search, and hybrid retrieval to their existing Redis infrastructure. [RedisVL](https://github.com/redis/redis-vl-python) is the official Redis Vector Search library that's also well adopted.

Moreover, the repo has `RedisSessionService` for session persistence, but there are no tools for agents to search Redis-based knowledge bases without building it themselves.

## Solution

Add `redisvl` as an optional dependency with four search tools that wrap RedisVL's query capabilities as ADK `BaseTool` implementations.

**pyproject.toml change:**
```toml
[project.optional-dependencies]
redis-vl = [
"redisvl>=0.13.0",
"nltk>=3.8.0",
"sentence-transformers>=2.2.0",
]
```

**Installation:**
```bash
# Existing functionality unchanged
pip install google-adk-community

# Opt-in to vector search capabilities
pip install google-adk-community[redis-vl]
```

This aligns with the community repository's stated philosophy:

> "This approach allows the **core ADK to remain stable and lightweight**, while giving the community the freedom to build and share powerful extensions."

### Tools Proposed

| Tool | Search Type | Use Case |
|------|-------------|----------|
| `RedisVectorSearchTool` | KNN vector similarity | Semantic/conceptual queries |
| `RedisTextSearchTool` | BM25 full-text | Exact terms, acronyms, API names |
| `RedisHybridSearchTool` | Vector + BM25 combined | Best of both worlds |
| `RedisRangeSearchTool` | Distance threshold | Exhaustive retrieval, quality filtering |

### Developer Experience

```python
from google.adk import Agent
from google.adk_community.tools.redis import RedisVectorSearchTool
from redisvl.index import SearchIndex
from redisvl.utils.vectorize import HFTextVectorizer

index = SearchIndex.from_yaml("schema.yaml")
index.connect("redis://localhost:6379")
vectorizer = HFTextVectorizer(model="redis/langcache-embed-v2")

tool = RedisVectorSearchTool(
index=index,
vectorizer=vectorizer,
num_results=5,
return_fields=["title", "content", "url"],
)

agent = Agent(model="gemini-2.0-flash", tools=[tool])
```

### Common Features Across All Tools

- **Filtering**: Tag, numeric, and geo filters via `filter_expression`
- **Field selection**: Control returned fields via `return_fields`
- **Async support**: Works with both `SearchIndex` and `AsyncSearchIndex`
- **Score normalization**: Convert distances to 0-1 similarity via `normalize_vector_distance=True`
- **Full parameter exposure**: All RedisVL query parameters are configurable

## Describe alternatives you've considered

1. **Implement vector search with raw Redis commands** — Would duplicate existing, maintained code in RedisVL. Users would get a degraded experience compared to using RedisVL directly.

2. **Require users to install RedisVL separately** — Creates friction and doesn't provide ADK-native abstractions like `BaseTool` wrappers with proper function declarations for LLMs.

## Why RedisVL?

[RedisVL](https://github.com/redis/redis-vl-python) is the official Redis vector library (~50MB footprint). It provides:
- Schema-driven index management
- Multiple query types (vector, text, hybrid, range)
- Built-in vectorizers
- Both sync and async APIs

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

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

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với pyproject.toml và RedisSessionService hiện có, sau đó kiểm tra interface BaseTool của ADK cùng các API SearchIndex và AsyncSearchIndex của RedisVL. Xác định cách bốn công cụ được đề xuất cung cấp các tham số truy vấn RedisVL, chức năng lọc, các trường được chọn và điểm số đã chuẩn hóa; được xem là hoàn tất khi dependency tùy chọn và cả bốn tool wrapper đều hỗ trợ trải nghiệm dành cho developer được mô tả trong tài liệu.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python, redis
Lĩnh vực
backend, databases, tooling
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

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.