tools¶
tools
¶
Redis tools for ADK.
CreateMemoryTool
¶
CreateMemoryTool(*, config: MemoryToolConfig | None = None, name: str = 'create_memory', description: str = 'Creates a new long-term memory. Use this when the user asks you to remember something.')
Bases: BaseMemoryTool
Tool for creating new long-term memories.
This tool allows the LLM to explicitly store information in long-term memory. Use this when the user asks to remember something specific.
Example
Initialize the Create Memory Tool.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
MemoryToolConfig | None
|
Configuration for the tool. If None, uses defaults. |
None
|
name
|
str
|
The name of the tool (exposed to LLM). |
'create_memory'
|
description
|
str
|
The description of the tool (exposed to LLM). |
'Creates a new long-term memory. Use this when the user asks you to remember something.'
|
Source code in src/adk_redis/tools/memory/create.py
run_async
async
¶
Create a new long-term memory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
The content of the memory to store. |
required | |
topics
|
Optional list of topics/tags. |
required | |
memory_type
|
Type of memory (semantic, episodic, message). |
required | |
namespace
|
Optional namespace override. |
required | |
user_id
|
Optional user ID override. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary with status and memory_id. |
Source code in src/adk_redis/tools/memory/create.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | |
DeleteMemoryTool
¶
DeleteMemoryTool(*, config: MemoryToolConfig | None = None, name: str = 'delete_memory', description: str = 'Deletes one or more long-term memories by ID. Use this when the user asks you to forget something.')
Bases: BaseMemoryTool
Tool for deleting long-term memories.
This tool allows the LLM to delete specific memories by ID. Use this when the user asks to forget something.
Example
Initialize the Delete Memory Tool.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
MemoryToolConfig | None
|
Configuration for the tool. If None, uses defaults. |
None
|
name
|
str
|
The name of the tool (exposed to LLM). |
'delete_memory'
|
description
|
str
|
The description of the tool (exposed to LLM). |
'Deletes one or more long-term memories by ID. Use this when the user asks you to forget something.'
|
Source code in src/adk_redis/tools/memory/delete.py
run_async
async
¶
Delete long-term memories by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
memory_ids
|
List of memory IDs to delete. |
required | |
namespace
|
Optional namespace override. |
required | |
user_id
|
Optional user ID override. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary with status and deleted_count. |
Source code in src/adk_redis/tools/memory/delete.py
GetMemoryTool
¶
GetMemoryTool(*, config: MemoryToolConfig | None = None, name: str = 'get_memory', description: str = 'Retrieves a specific long-term memory by its ID. Use this when you need the full details of a known memory.')
Bases: BaseMemoryTool
Tool for retrieving a specific long-term memory by ID.
This tool allows the LLM to retrieve a specific memory when it knows the memory ID. Use this when you need to access the full details of a memory that was previously found via search.
Example
Initialize the Get Memory Tool.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
MemoryToolConfig | None
|
Configuration for the tool. If None, uses defaults. |
None
|
name
|
str
|
The name of the tool (exposed to LLM). |
'get_memory'
|
description
|
str
|
The description of the tool (exposed to LLM). |
'Retrieves a specific long-term memory by its ID. Use this when you need the full details of a known memory.'
|
Source code in src/adk_redis/tools/memory/get.py
run_async
async
¶
Retrieve a specific memory by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
memory_id
|
The unique ID of the memory to retrieve. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary with status and memory details. |
Source code in src/adk_redis/tools/memory/get.py
MemoryPromptTool
¶
MemoryPromptTool(*, config: MemoryToolConfig | None = None, name: str = 'memory_prompt', description: str = 'Enriches a prompt with relevant memories from long-term storage. Use this to provide personalized context based on past interactions.')
Bases: BaseMemoryTool
Tool for enriching prompts with relevant memories.
This tool searches long-term memory for relevant context and enriches a system prompt with the retrieved memories. It's useful for providing the LLM with personalized context based on past interactions.
Example
Initialize the Memory Prompt Tool.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
MemoryToolConfig | None
|
Configuration for the tool. If None, uses defaults. |
None
|
name
|
str
|
The name of the tool (exposed to LLM). |
'memory_prompt'
|
description
|
str
|
The description of the tool (exposed to LLM). |
'Enriches a prompt with relevant memories from long-term storage. Use this to provide personalized context based on past interactions.'
|
Source code in src/adk_redis/tools/memory/prompt.py
run_async
async
¶
Enrich a prompt with relevant memories.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
The query to search for relevant memories. |
required | |
system_prompt
|
Optional base system prompt to enrich. |
required | |
namespace
|
Optional namespace override. |
required | |
user_id
|
Optional user ID override. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary with status and enriched_prompt. |
Source code in src/adk_redis/tools/memory/prompt.py
MemoryToolConfig
¶
Bases: BaseModel
Shared configuration for all Redis Agent Memory tools.
This configuration is used by all memory tools to connect to the Agent Memory Server and manage memory operations.
Attributes:
| Name | Type | Description |
|---|---|---|
api_base_url |
str
|
Base URL of the Agent Memory Server. |
timeout |
float
|
HTTP request timeout in seconds. |
default_namespace |
str
|
Default namespace for memory operations. |
default_user_id |
str | None
|
Default user ID for memory operations (optional). |
search_top_k |
int
|
Default maximum number of memories to retrieve. |
distance_threshold |
float | None
|
Maximum distance threshold for search (0.0-1.0). |
recency_boost |
bool
|
Enable recency-aware re-ranking of search results. |
semantic_weight |
float
|
Weight for semantic similarity (0.0-1.0). |
recency_weight |
float
|
Weight for recency score (0.0-1.0). |
freshness_weight |
float
|
Weight for freshness within recency score. |
novelty_weight |
float
|
Weight for novelty within recency score. |
half_life_last_access_days |
float
|
Half-life in days for last_accessed decay. |
half_life_created_days |
float
|
Half-life in days for created_at decay. |
deduplicate |
bool
|
Enable deduplication when creating memories. |
Example
SearchMemoryTool
¶
SearchMemoryTool(*, config: MemoryToolConfig | None = None, name: str = 'search_memory', description: str = 'Searches long-term memory for relevant information. Use this to recall facts, preferences, or past interactions.')
Bases: BaseMemoryTool
Tool for searching long-term memories.
This tool performs semantic search against long-term memory with optional recency boosting. Use this when the LLM needs to recall specific information from past interactions.
Example
Initialize the Search Memory Tool.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
MemoryToolConfig | None
|
Configuration for the tool. If None, uses defaults. |
None
|
name
|
str
|
The name of the tool (exposed to LLM). |
'search_memory'
|
description
|
str
|
The description of the tool (exposed to LLM). |
'Searches long-term memory for relevant information. Use this to recall facts, preferences, or past interactions.'
|
Source code in src/adk_redis/tools/memory/search.py
run_async
async
¶
Search for relevant memories.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
The search query. |
required | |
limit
|
Maximum number of memories to return. |
required | |
namespace
|
Optional namespace override. |
required | |
user_id
|
Optional user ID override. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary with status and list of memories. |
Source code in src/adk_redis/tools/memory/search.py
UpdateMemoryTool
¶
UpdateMemoryTool(*, config: MemoryToolConfig | None = None, name: str = 'update_memory', description: str = 'Updates an existing long-term memory. Use this when the user asks to modify or correct stored information.')
Bases: BaseMemoryTool
Tool for updating existing long-term memories.
This tool allows the LLM to modify the content or metadata of existing memories. Use this when the user asks to update or correct previously stored information.
Example
Initialize the Update Memory Tool.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
MemoryToolConfig | None
|
Configuration for the tool. If None, uses defaults. |
None
|
name
|
str
|
The name of the tool (exposed to LLM). |
'update_memory'
|
description
|
str
|
The description of the tool (exposed to LLM). |
'Updates an existing long-term memory. Use this when the user asks to modify or correct stored information.'
|
Source code in src/adk_redis/tools/memory/update.py
run_async
async
¶
Update an existing long-term memory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
memory_id
|
The ID of the memory to update. |
required | |
content
|
New content for the memory. |
required | |
topics
|
New list of topics/tags. |
required | |
namespace
|
Optional namespace override. |
required | |
user_id
|
Optional user ID override. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary with status and updated memory info. |
Source code in src/adk_redis/tools/memory/update.py
BaseRedisSearchTool
¶
BaseRedisSearchTool(*, name: str, description: str, index: SearchIndex | AsyncSearchIndex, return_fields: list[str] | None = None)
Bases: BaseTool
Base class for ALL Redis search tools using RedisVL.
This class provides common functionality shared by all Redis search tools: - Index management (sync and async) - Query execution with proper async handling - Standard response formatting - Error handling
Subclasses should use _run_search to execute queries with consistent
error handling and response formatting.
Initialize the base Redis search tool.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the tool (exposed to LLM). |
required |
description
|
str
|
The description of the tool (exposed to LLM). |
required |
index
|
SearchIndex | AsyncSearchIndex
|
The RedisVL SearchIndex or AsyncSearchIndex to query. |
required |
return_fields
|
list[str] | None
|
Optional list of fields to return in results. |
None
|
Source code in src/adk_redis/tools/search/_base.py
RedisAggregatedHybridQueryConfig
¶
Bases: BaseModel
Configuration for aggregated (client-side) Redis hybrid search queries.
.. deprecated:: This config is for older Redis/RedisVL versions. For newer setups (RedisVL >= 0.13.0, Redis >= 8.4.0), prefer RedisHybridQueryConfig which uses native server-side hybrid search for better performance.
This config uses AggregateHybridQuery which performs client-side hybrid search using FT.AGGREGATE with weighted score combination. It works with any Redis version that has RediSearch installed.
Recommended for
- Redis < 8.4.0
- RedisVL < 0.13.0
- Environments where native FT.HYBRID is not available
Example
Attributes:
| Name | Type | Description |
|---|---|---|
text_field_name |
str
|
Name of the text field for BM25 search. |
vector_field_name |
str
|
Name of the vector field for similarity search. |
text_scorer |
str
|
Text scoring algorithm (default: "BM25STD"). |
alpha |
float
|
Weight for text score (default: 0.7). Higher values favor text matching over vector similarity. Combined score is: alpha * text_score + (1 - alpha) * vector_score |
num_results |
int
|
Number of results to return. |
dtype |
str
|
Data type of the vector. |
stopwords |
str | set[str] | None
|
Stopwords to remove from query. |
dialect |
int
|
RediSearch query dialect version. |
text_weights |
dict[str, float] | None
|
Optional field weights for text scoring. |
to_query_kwargs
¶
to_query_kwargs(text: str, vector: list[float], return_fields: list[str] | None = None, filter_expression: Any | None = None) -> dict[str, Any]
Convert config to AggregateHybridQuery kwargs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The query text for BM25 matching. |
required |
vector
|
list[float]
|
The query vector embedding. |
required |
return_fields
|
list[str] | None
|
Optional list of fields to return. |
None
|
filter_expression
|
Any | None
|
Optional filter expression to apply. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary of kwargs suitable for AggregateHybridQuery constructor. |
Source code in src/adk_redis/tools/search/_config.py
RedisHybridQueryConfig
¶
Bases: BaseModel
Configuration for native Redis hybrid search queries.
Uses Redis's native FT.HYBRID command for server-side hybrid search combining semantic vector similarity with keyword-based BM25 text matching.
Requirements
- RedisVL >= 0.13.0
- Redis >= 8.4.0
- redis-py >= 7.1.0
For older Redis/RedisVL versions, use RedisAggregatedHybridQueryConfig instead.
Example
Attributes:
| Name | Type | Description |
|---|---|---|
text_field_name |
str
|
Name of the text field for BM25 search. |
vector_field_name |
str
|
Name of the vector field for similarity search. |
vector_param_name |
str
|
Name of the parameter substitution for vector blob. |
text_scorer |
str
|
Text scoring algorithm (default: "BM25STD"). |
yield_text_score_as |
str | None
|
Field name to yield the text score as. |
vector_search_method |
str | None
|
Vector search method - "KNN" or "RANGE". |
knn_ef_runtime |
int
|
Exploration factor for HNSW when using KNN. |
range_radius |
float | None
|
Search radius when using RANGE vector search. |
range_epsilon |
float
|
Epsilon for RANGE search accuracy. |
yield_vsim_score_as |
str | None
|
Field name to yield vector similarity score as. |
combination_method |
str | None
|
Score combination method - "RRF" or "LINEAR". |
linear_alpha |
float
|
Weight of text score when using LINEAR (0.0-1.0). |
rrf_window |
int
|
Window size for RRF combination. |
rrf_constant |
int
|
Constant for RRF combination. |
yield_combined_score_as |
str | None
|
Field name to yield combined score as. |
num_results |
int
|
Number of results to return. |
dtype |
str
|
Data type of the vector. |
stopwords |
str | set[str] | None
|
Stopwords to remove from query. |
text_weights |
dict[str, float] | None
|
Optional field weights for text scoring. |
to_query_kwargs
¶
to_query_kwargs(text: str, vector: list[float], return_fields: list[str] | None = None, filter_expression: Any | None = None) -> dict[str, Any]
Convert config to native HybridQuery kwargs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The query text for BM25 matching. |
required |
vector
|
list[float]
|
The query vector embedding. |
required |
return_fields
|
list[str] | None
|
Optional list of fields to return. |
None
|
filter_expression
|
Any | None
|
Optional filter expression to apply. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary of kwargs suitable for HybridQuery constructor. |
Source code in src/adk_redis/tools/search/_config.py
RedisHybridSearchTool
¶
RedisHybridSearchTool(*, index: SearchIndex | AsyncSearchIndex, vectorizer: BaseVectorizer, config: RedisHybridQueryConfig | RedisAggregatedHybridQueryConfig | None = None, return_fields: list[str] | None = None, filter_expression: Any | None = None, name: str = 'redis_hybrid_search', description: str = 'Search using both semantic similarity and keyword matching.')
Bases: VectorizedSearchTool
Hybrid search tool combining vector similarity and BM25 text search.
This tool performs a hybrid search that combines semantic vector similarity with keyword-based BM25 text matching. It automatically detects the installed RedisVL version and uses the appropriate implementation:
- RedisVL >= 0.13.0: Uses native FT.HYBRID command (server-side fusion) with RedisHybridQueryConfig. Requires Redis >= 8.4.0.
- RedisVL < 0.13.0: Uses AggregateHybridQuery (client-side fusion) with RedisAggregatedHybridQueryConfig. Works with any Redis version.
Example (native mode - RedisVL >= 0.13.0):
from adk_redis import (
RedisHybridSearchTool,
RedisHybridQueryConfig,
)
config = RedisHybridQueryConfig(
text_field_name="content",
combination_method="LINEAR",
linear_alpha=0.7, # 70% text, 30% vector
)
tool = RedisHybridSearchTool(
index=index,
vectorizer=vectorizer,
config=config,
)
Example (aggregate mode - older versions):
from adk_redis import (
RedisHybridSearchTool,
RedisAggregatedHybridQueryConfig,
)
config = RedisAggregatedHybridQueryConfig(
text_field_name="content",
alpha=0.7, # 70% text, 30% vector
)
tool = RedisHybridSearchTool(
index=index,
vectorizer=vectorizer,
config=config,
)
Initialize the hybrid search tool.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
SearchIndex | AsyncSearchIndex
|
The RedisVL SearchIndex or AsyncSearchIndex to query. |
required |
vectorizer
|
BaseVectorizer
|
The vectorizer for embedding queries. |
required |
config
|
RedisHybridQueryConfig | RedisAggregatedHybridQueryConfig | None
|
Configuration for query parameters. Can be either: - RedisHybridQueryConfig: For native FT.HYBRID (RedisVL >= 0.13.0) - RedisAggregatedHybridQueryConfig: For client-side hybrid (older) If None, auto-detects based on installed RedisVL version. |
None
|
return_fields
|
list[str] | None
|
Optional list of fields to return in results. |
None
|
filter_expression
|
Any | None
|
Optional filter expression to narrow results. |
None
|
name
|
str
|
The name of the tool (exposed to LLM). |
'redis_hybrid_search'
|
description
|
str
|
The description of the tool (exposed to LLM). |
'Search using both semantic similarity and keyword matching.'
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If RedisHybridQueryConfig is used with RedisVL < 0.13.0. |
Warns:
| Type | Description |
|---|---|
DeprecationWarning
|
If RedisAggregatedHybridQueryConfig is used when native hybrid is available (RedisVL >= 0.13.0). |
Source code in src/adk_redis/tools/search/hybrid.py
run_async
async
¶
Execute the vector-based search query.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
dict[str, Any]
|
Arguments from the LLM, must include 'query'. |
required |
tool_context
|
ToolContext
|
The tool execution context. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary with status, count, and results. |
Source code in src/adk_redis/tools/search/_base.py
RedisRangeQueryConfig
¶
Bases: BaseModel
Configuration for Redis vector range search queries.
Range search finds all documents within a specified distance threshold from the query vector, rather than returning a fixed number of results.
Attributes:
| Name | Type | Description |
|---|---|---|
vector_field_name |
str
|
Name of the vector field in the index. |
distance_threshold |
float
|
Maximum distance for results (default: 0.2). |
num_results |
int
|
Maximum number of results to return. |
dtype |
str
|
Data type of the vector (default: "float32"). |
return_score |
bool
|
Whether to return vector distance scores. |
dialect |
int
|
RediSearch query dialect version. |
sort_by |
SortSpec
|
Field(s) to order results by. |
in_order |
bool
|
Require query terms in same order as document. |
normalize_vector_distance |
bool
|
Convert distance to 0-1 similarity score. |
epsilon |
float | None
|
Range search approximation factor for HNSW/SVS-VAMANA. |
to_query_kwargs
¶
Convert config to VectorRangeQuery kwargs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vector
|
list[float]
|
The query vector embedding. |
required |
filter_expression
|
Any | None
|
Optional filter expression to apply. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary of kwargs suitable for VectorRangeQuery constructor. |
Source code in src/adk_redis/tools/search/_config.py
RedisRangeSearchTool
¶
RedisRangeSearchTool(*, index: SearchIndex | AsyncSearchIndex, vectorizer: BaseVectorizer, config: RedisRangeQueryConfig | None = None, return_fields: list[str] | None = None, filter_expression: Any | None = None, name: str = 'redis_range_search', description: str = 'Find all documents within a similarity threshold.')
Bases: VectorizedSearchTool
Vector range search tool using distance threshold.
This tool finds all documents within a specified distance threshold from the query vector. Unlike KNN search which returns a fixed number of results, range search returns all documents that are "close enough" based on the threshold.
Example
from redisvl.index import SearchIndex
from redisvl.utils.vectorize import HFTextVectorizer
from adk_redis import (
RedisRangeSearchTool,
RedisRangeQueryConfig,
)
index = SearchIndex.from_yaml("schema.yaml")
vectorizer = HFTextVectorizer(model="redis/langcache-embed-v2")
# Using config object (recommended)
config = RedisRangeQueryConfig(
distance_threshold=0.3, # Only return docs within 0.3 distance
)
tool = RedisRangeSearchTool(
index=index,
vectorizer=vectorizer,
config=config,
return_fields=["title", "content"],
)
agent = Agent(model="gemini-2.5-flash", tools=[tool])
Initialize the range search tool.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
SearchIndex | AsyncSearchIndex
|
The RedisVL SearchIndex or AsyncSearchIndex to query. |
required |
vectorizer
|
BaseVectorizer
|
The vectorizer for embedding queries. |
required |
config
|
RedisRangeQueryConfig | None
|
Configuration for query parameters. If None, uses defaults. See RedisRangeQueryConfig for available options including distance_threshold, vector_field_name, and epsilon. |
None
|
return_fields
|
list[str] | None
|
Optional list of fields to return in results. |
None
|
filter_expression
|
Any | None
|
Optional filter expression to narrow results. |
None
|
name
|
str
|
The name of the tool (exposed to LLM). |
'redis_range_search'
|
description
|
str
|
The description of the tool (exposed to LLM). |
'Find all documents within a similarity threshold.'
|
Source code in src/adk_redis/tools/search/range.py
run_async
async
¶
Execute the vector-based search query.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
dict[str, Any]
|
Arguments from the LLM, must include 'query'. |
required |
tool_context
|
ToolContext
|
The tool execution context. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary with status, count, and results. |
Source code in src/adk_redis/tools/search/_base.py
RedisSQLSearchTool
¶
RedisSQLSearchTool(*, index: SearchIndex | AsyncSearchIndex, sql_redis_options: dict[str, Any] | None = None, return_fields: list[str] | None = None, name: str = 'redis_sql_search', description: str = _DEFAULT_DESCRIPTION)
Bases: BaseRedisSearchTool
Search tool that lets the LLM issue SQL SELECT statements.
Wraps redisvl.query.SQLQuery, which translates SQL into Redis
FT.SEARCH / FT.AGGREGATE commands via the optional sql-redis
extra. Use this when an agent benefits from expressing filters and
projections directly in SQL rather than configuring query parameters
field by field.
Example
Note
Requires the sql-redis optional dependency. Install with
pip install 'adk-redis[sql]'.
Initialize the SQL search tool.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
SearchIndex | AsyncSearchIndex
|
The RedisVL SearchIndex or AsyncSearchIndex to query. |
required |
sql_redis_options
|
dict[str, Any] | None
|
Optional passthrough options forwarded to the
sql-redis executor. For example, |
None
|
return_fields
|
list[str] | None
|
Ignored. SQL SELECT clauses already specify the projection. Accepted for API symmetry with sibling tools. |
None
|
name
|
str
|
The name of the tool (exposed to LLM). |
'redis_sql_search'
|
description
|
str
|
The description of the tool (exposed to LLM). |
_DEFAULT_DESCRIPTION
|
Source code in src/adk_redis/tools/search/sql.py
run_async
async
¶
Execute the SQL query.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
dict[str, Any]
|
Arguments from the LLM. Must include |
required |
tool_context
|
ToolContext
|
The tool execution context. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary with status, count, and results (or error). |
Source code in src/adk_redis/tools/search/sql.py
RedisTextQueryConfig
¶
Bases: BaseModel
Configuration for Redis full-text search queries.
This config groups all query-specific parameters for TextQuery, using BM25 scoring for keyword-based search.
Attributes:
| Name | Type | Description |
|---|---|---|
text_field_name |
str
|
Name of the text field to search. |
text_scorer |
str
|
Text scoring algorithm (default: "BM25STD"). |
num_results |
int
|
Number of results to return (default: 10). |
return_score |
bool
|
Whether to return the text score. |
dialect |
int
|
RediSearch query dialect version. |
sort_by |
SortSpec
|
Field(s) to order results by. |
in_order |
bool
|
Require query terms in same order as document. |
stopwords |
str | set[str] | None
|
Stopwords to remove from query (default: "english"). |
to_query_kwargs
¶
to_query_kwargs(text: str, return_fields: list[str] | None = None, filter_expression: Any | None = None) -> dict[str, Any]
Convert config to TextQuery kwargs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The query text for BM25 matching. |
required |
return_fields
|
list[str] | None
|
Optional list of fields to return. |
None
|
filter_expression
|
Any | None
|
Optional filter expression to apply. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary of kwargs suitable for TextQuery constructor. |
Source code in src/adk_redis/tools/search/_config.py
RedisTextSearchTool
¶
RedisTextSearchTool(*, index: SearchIndex | AsyncSearchIndex, config: RedisTextQueryConfig | None = None, return_fields: list[str] | None = None, filter_expression: Any | None = None, name: str = 'redis_text_search', description: str = 'Search for documents using keyword matching.')
Bases: BaseRedisSearchTool
Full-text search tool using BM25 scoring.
This tool performs keyword-based full-text search using BM25 scoring. Unlike vector search, it doesn't require embeddings - it matches documents based on keyword relevance.
Example
from redisvl.index import SearchIndex
from adk_redis import (
RedisTextSearchTool,
RedisTextQueryConfig,
)
index = SearchIndex.from_yaml("schema.yaml")
# Using config object (recommended)
config = RedisTextQueryConfig(
text_field_name="content",
num_results=10,
text_scorer="BM25STD",
)
tool = RedisTextSearchTool(
index=index,
config=config,
return_fields=["title", "content"],
)
agent = Agent(model="gemini-2.5-flash", tools=[tool])
Initialize the text search tool.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
SearchIndex | AsyncSearchIndex
|
The RedisVL SearchIndex or AsyncSearchIndex to query. |
required |
config
|
RedisTextQueryConfig | None
|
Configuration for text query parameters. If not provided, defaults will be used. |
None
|
return_fields
|
list[str] | None
|
Optional list of fields to return in results. |
None
|
filter_expression
|
Any | None
|
Optional filter expression to narrow results. |
None
|
name
|
str
|
The name of the tool (exposed to LLM). |
'redis_text_search'
|
description
|
str
|
The description of the tool (exposed to LLM). |
'Search for documents using keyword matching.'
|
Source code in src/adk_redis/tools/search/text.py
run_async
async
¶
Execute the text search query.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
dict[str, Any]
|
Arguments from the LLM, must include 'query'. |
required |
tool_context
|
ToolContext
|
The tool execution context. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary with status, count, and results. |
Source code in src/adk_redis/tools/search/text.py
RedisVectorQueryConfig
¶
Bases: BaseModel
Configuration for Redis vector similarity search queries.
This config groups all query-specific parameters for VectorQuery, separating them from tool-level concerns like index and vectorizer.
Attributes:
| Name | Type | Description |
|---|---|---|
vector_field_name |
str
|
Name of the vector field in the index. |
num_results |
int
|
Number of results to return (default: 10). |
dtype |
str
|
Data type of the vector (default: "float32"). |
return_score |
bool
|
Whether to return vector distance scores. |
dialect |
int
|
RediSearch query dialect version. |
sort_by |
SortSpec
|
Field(s) to order results by. |
in_order |
bool
|
Require query terms in same order as document. |
normalize_vector_distance |
bool
|
Convert distance to 0-1 similarity score. |
hybrid_policy |
str | None
|
Filter application policy - "BATCHES" or "ADHOC_BF". |
batch_size |
int | None
|
Batch size when hybrid_policy is "BATCHES". |
ef_runtime |
int | None
|
HNSW exploration factor at query time. |
search_window_size |
int | None
|
SVS-VAMANA search window size. |
use_search_history |
str | None
|
SVS-VAMANA history mode - "OFF", "ON", or "AUTO". |
search_buffer_capacity |
int | None
|
SVS-VAMANA 2-level compression tuning. |
to_query_kwargs
¶
Convert config to VectorQuery kwargs, excluding None version-dependent params.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vector
|
list[float]
|
The query vector embedding. |
required |
filter_expression
|
Any | None
|
Optional filter expression to apply. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary of kwargs suitable for VectorQuery constructor. |
Source code in src/adk_redis/tools/search/_config.py
RedisVectorSearchTool
¶
RedisVectorSearchTool(*, index: SearchIndex | AsyncSearchIndex, vectorizer: BaseVectorizer, config: RedisVectorQueryConfig | None = None, return_fields: list[str] | None = None, filter_expression: Any | None = None, name: str = 'redis_vector_search', description: str = 'Search for semantically similar documents using vector similarity with Redis.')
Bases: VectorizedSearchTool
Vector similarity search tool using RedisVL.
This tool performs K-nearest neighbor (KNN) vector similarity search over a Redis index. It embeds the query text using the provided vectorizer and finds the most similar documents.
Example
from redisvl.index import SearchIndex
from redisvl.utils.vectorize import HFTextVectorizer
from redisvl.query.filter import Tag
from adk_redis import (
RedisVectorSearchTool,
RedisVectorQueryConfig,
)
index = SearchIndex.from_yaml("schema.yaml")
vectorizer = HFTextVectorizer(model="redis/langcache-embed-v2")
# Using config object (recommended)
config = RedisVectorQueryConfig(
num_results=5,
ef_runtime=100, # Higher = better recall
)
tool = RedisVectorSearchTool(
index=index,
vectorizer=vectorizer,
config=config,
return_fields=["title", "content", "url"],
filter_expression=Tag("category") == "redis",
)
# Use with an agent
agent = Agent(model="gemini-2.5-flash", tools=[tool])
Initialize the vector search tool.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
SearchIndex | AsyncSearchIndex
|
The RedisVL SearchIndex to query. |
required |
vectorizer
|
BaseVectorizer
|
The vectorizer for embedding queries. |
required |
config
|
RedisVectorQueryConfig | None
|
Configuration for query parameters. If None, uses defaults. See RedisVectorQueryConfig for available options including num_results, vector_field_name, dtype, and version-dependent parameters like ef_runtime and hybrid_policy. |
None
|
return_fields
|
list[str] | None
|
Optional list of fields to return in results. |
None
|
filter_expression
|
Any | None
|
Optional RedisVL FilterExpression to narrow results. |
None
|
name
|
str
|
The name of the tool (exposed to LLM). |
'redis_vector_search'
|
description
|
str
|
The description of the tool (exposed to LLM). |
'Search for semantically similar documents using vector similarity with Redis.'
|
Source code in src/adk_redis/tools/search/vector.py
run_async
async
¶
Execute the vector-based search query.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
dict[str, Any]
|
Arguments from the LLM, must include 'query'. |
required |
tool_context
|
ToolContext
|
The tool execution context. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary with status, count, and results. |
Source code in src/adk_redis/tools/search/_base.py
VectorizedSearchTool
¶
VectorizedSearchTool(*, name: str, description: str, index: SearchIndex | AsyncSearchIndex, vectorizer: BaseVectorizer, return_fields: list[str] | None = None)
Bases: BaseRedisSearchTool
Base class for Redis search tools that require vector embeddings.
This class extends BaseRedisSearchTool with: - Required vectorizer for embedding queries - Abstract _build_query method for subclasses to implement
Use this as the base class for vector-based search tools like VectorSearchTool, HybridSearchTool, and RangeSearchTool.
Initialize the vectorized search tool.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the tool (exposed to LLM). |
required |
description
|
str
|
The description of the tool (exposed to LLM). |
required |
index
|
SearchIndex | AsyncSearchIndex
|
The RedisVL SearchIndex or AsyncSearchIndex to query. |
required |
vectorizer
|
BaseVectorizer
|
The vectorizer for embedding queries (required). |
required |
return_fields
|
list[str] | None
|
Optional list of fields to return in results. |
None
|
Source code in src/adk_redis/tools/search/_base.py
run_async
async
¶
Execute the vector-based search query.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
dict[str, Any]
|
Arguments from the LLM, must include 'query'. |
required |
tool_context
|
ToolContext
|
The tool execution context. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary with status, count, and results. |