Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llama_index_tools_vector_db-0.5.0.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llama_index_tools_vector_db-0.5.0-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file llama_index_tools_vector_db-0.5.0.tar.gz.

File metadata

  • Download URL: llama_index_tools_vector_db-0.5.0.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for llama_index_tools_vector_db-0.5.0.tar.gz
Algorithm Hash digest
SHA256 838562f5c6e8f75ee91e9e5821652a43be01f4fc9fd1dd7d3801c0761d46ab5a
MD5 5727a02ce12fe4d391e2a01e817824d9
BLAKE2b-256 f7cd72b4726cbd818ce89f8155d0b97cbd8dd047a32358af634b10de370e0476

See more details on using hashes here.

File details

Details for the file llama_index_tools_vector_db-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: llama_index_tools_vector_db-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for llama_index_tools_vector_db-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d24ee547cef93401c3c041571398b38feb7256ba6ac1230cec51e8d13069aa30
MD5 984188086e3301e5009a75d247de5db0
BLAKE2b-256 599363c420bf4cf0aab874025d46b0f00f511f7522f0ac3bd30f6702e8cda8e6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page