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
File details
Details for the file llama_index_tools_vector_db-0.3.0.tar.gz
.
File metadata
- Download URL: llama_index_tools_vector_db-0.3.0.tar.gz
- Upload date:
- Size: 2.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.10 Darwin/22.3.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb134bc94e50f7b4d916d2f1de4b4a8a974065cb75642479a8c0593628220617 |
|
MD5 | d0073ecccccabf913507d6570591eb11 |
|
BLAKE2b-256 | 063514466b4c874fcba98db9e32c0b2ded44a048921c1bb636db63770d55c4b5 |
File details
Details for the file llama_index_tools_vector_db-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: llama_index_tools_vector_db-0.3.0-py3-none-any.whl
- Upload date:
- Size: 2.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.10 Darwin/22.3.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 66d9aaecc01c1792e18f441c67c3067a6c8efd304815f11a644da499b11a893c |
|
MD5 | 46d160eb7a9b692a00729ac20feec4d4 |
|
BLAKE2b-256 | 1b046614482680ed986d101662ddf29ab186a1d7a64da7405a4e2ac12b811856 |