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.agent.openai import OpenAIAgent
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 = OpenAIAgent.from_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
),
)
}
),
verbose=True,
)
agent.chat("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
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
Close
Hashes for llama_index_tools_vector_db-0.2.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30364d4961d21c88930462c29d666623f4216ab5a9f994eb44b0f23c8ff60ce2 |
|
MD5 | 36afbb66916f8e16877207e10dacc632 |
|
BLAKE2b-256 | 0852c3daf39f041eda6e9236b6591fa74736f1df0e12888a3bab705cde30bd9a |
Close
Hashes for llama_index_tools_vector_db-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 737f683bda7e6f9154655e0f9b2979125ae4cd0a4cd719277e81f0b8c19e4d94 |
|
MD5 | e5b93456d03cefa53cb0ea27e8e9e6af |
|
BLAKE2b-256 | 3a8bd5e15356f7e8493f1bd4a7d06b9e755887ab6a80b6c95f35fee31cf894ae |