llama-index tools database integration
Project description
Database Tool
This tool connects to a database (using SQLAlchemy under the hood) and allows an Agent to query the database and get information about the tables.
Usage
This tool has more extensive example usage documented in a Jupyter notebook here and here
Here's an example usage of the DatabaseToolSpec.
from llama_index.tools.database import DatabaseToolSpec
from llama_index.agent import OpenAIAgent
db_tools = DatabaseToolSpec(
scheme="postgresql", # Database Scheme
host="localhost", # Database Host
port="5432", # Database Port
user="postgres", # Database User
password="FakeExamplePassword", # Database Password
dbname="postgres", # Database Name
)
agent = OpenAIAgent.from_tools(db_tools.to_tool_list())
agent.chat("What tables does this database contain")
agent.chat("Describe the first table")
agent.chat("Retrieve the first row of that table")
The tools available are:
list_tables
: A tool to list the tables in the database schema
describe_tables
: A tool to describe the schema of a table
load_data
: A tool that accepts an SQL query and returns the result
This loader is designed to be used as a way to load data as a Tool in a Agent. See here for examples.
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
Hashes for llama_index_tools_database-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2fd3913b4811b9b64c442a14877068b4c0874d0fa5acc5226a00848bf8c913f3 |
|
MD5 | 418e0fdf99ca33bc8deabd18b63b5f0e |
|
BLAKE2b-256 | 372cd105553d5b31560ab8e2a2d1a6b816d1bc7f97bafb61246c0a55dc9f1883 |
Hashes for llama_index_tools_database-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4fd0b79570db7b0ffc630c1e61e750c3bbeae7b70ac983a61e434874fb8ef10c |
|
MD5 | 40b45b71bfbbd4fd9cf1a664c033d72c |
|
BLAKE2b-256 | 3993f2140971d9fefa774ab239d010e9c2ca0248d8ee384204709700aa86ce6f |