llama-index tools vector_db integration
Project description
VectorDB Tool
This tool wraps a VectorStoreIndex and enables a agent to call it with queries and filters to retrieve data.
Usage
from llama_index.tools.vector_db import VectorDB
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI
from llama_index.core.vector_stores import VectorStoreInfo
from llama_index.core import VectorStoreIndex
index = VectorStoreIndex(nodes=nodes)
tool_spec = VectorDB(index=index)
vector_store_info = VectorStoreInfo(
content_info="brief biography of celebrities",
metadata_info=[
MetadataInfo(
name="category",
type="str",
description="Category of the celebrity, one of [Sports, Entertainment, Business, Music]",
),
MetadataInfo(
name="country",
type="str",
description="Country of the celebrity, one of [United States, Barbados, Portugal]",
),
],
)
agent = FunctionAgent(
tools=tool_spec.to_tool_list(
func_to_metadata_mapping={
"auto_retrieve_fn": ToolMetadata(
name="celebrity_bios",
description=f"""\
Use this tool to look up biographical information about celebrities.
The vector database schema is given below:
{vector_store_info.json()}
{tool_spec.auto_retrieve_fn.__doc__}
""",
fn_schema=create_schema_from_function(
"celebrity_bios", tool_spec.auto_retrieve_fn
),
)
}
),
llm=OpenAI(model="gpt-4.1"),
)
print(
await agent.run("Tell me about two celebrities from the United States. ")
)
auto_retrieve_fn: Retrieves data from the index
This loader is designed to be used as a way to load data as a Tool in a Agent.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llama_index_tools_vector_db-0.4.0.tar.gz.
File metadata
- Download URL: llama_index_tools_vector_db-0.4.0.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
53edb88604a84636fd1c861a0309a143a9e0ee68900b7f264c9945597f616cf6
|
|
| MD5 |
ef51e68e7a51bb010392adf4e106c5ea
|
|
| BLAKE2b-256 |
c7adec53cb0e11f0fe670dcf9bbf04ae447376af517688dd4bd0c18c1498fe24
|
File details
Details for the file llama_index_tools_vector_db-0.4.0-py3-none-any.whl.
File metadata
- Download URL: llama_index_tools_vector_db-0.4.0-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01346ac5b3055dcb6ca1412c9432f4075119a4b522ee5c66f77ae26c38780ca7
|
|
| MD5 |
9b75c94298c12d62de82ae2fd8558c5e
|
|
| BLAKE2b-256 |
a5e7a6c9dd256025b8974d139c5511e34758bece92e64401c12ec39ca8c9d7f8
|