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.
Here's an example usage of the DatabaseToolSpec.
from llama_index.tools.database import DatabaseToolSpec
from llama_index.agent.openai 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.
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_database-0.3.0.tar.gz
.
File metadata
- Download URL: llama_index_tools_database-0.3.0.tar.gz
- Upload date:
- Size: 3.4 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 | 8bbce16005b99a311912e9fee3c087a8db2beaeb0855e20ebb808fee00047d44 |
|
MD5 | 43eae513258b12c7637390183a9ae2d4 |
|
BLAKE2b-256 | cfc1f7a3cac198cbd08f9a1624f944ea80692c55a9daa3bbae777a54dcc49a50 |
File details
Details for the file llama_index_tools_database-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: llama_index_tools_database-0.3.0-py3-none-any.whl
- Upload date:
- Size: 3.7 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 | d7820fb960dca18bbbc78e330a68769b97c73c514f26a813c47fc7cbb3870dc3 |
|
MD5 | 51130ab3be37cd89cbcaa43e6477b6bf |
|
BLAKE2b-256 | 482b7dd5118365de6d82e5bbc90081538e46abe255ee8f48f6dbabcdb5b4b64b |