DBASSISTANT
An Open-Source Text-to-SQL Library for Analyzing and Visualizing Data in Large Databases.
Why use DBAssistant instead of other tools?
- Speed Through Adaptive Learning: In larger databases, agents often require multiple attempts to identify correct schemata and tables. DBAssistant accelerates future requests by learning from prior interactions. With user feedback, it refines its understanding of schemas and tables, reducing redundant steps and delivering faster results over time.
- Accuracy via Focused Architecture: Unlike most tools that rely on complex multi-agent orchestration, DBAssistant has a streamlined single-agent design. By mechanistically curating the model's context window with relevant information, it minimizes errors caused by too many degrees of freedom. This approach works especially well in large, complex, or poorly documented databases.
How DBAssistant Works
DBAssistant combines the function-calling abilities of OpenAI's Assistants API with a code execution environment.
Phase 1: Initial Database Exploration
Upon connecting to a database, DBAssistant performs an automated analysis that includes:
- Schema Summarization: Generates concise summary files for each schema, explaining its purpose and the role of its tables.
- Assistant Description: Writes a one-line summary of each schema to use in the assistant's initial context during a user request.
Phase 2: Handling User Requests
When a user submits a query, DBAssistant follows a structured, collaborative process:
1. Schema Identification: Identifies relevant schemas for the task and confirms selections with the user.
- Once the user confirms, the program injects pre-generated schema summaries into the context window to guide the agent.
3. Query Execution: Generates and runs the SQL query, saving results locally (or via OpenAI's Code Interpreter) to preserve context space.
4. Data Processing & Visualization: Uses code execution to analyze results, creating tables, graphs, or other outputs as requested.
5. Continuous Learning: Before the thread is closed, the assistant is automatically prompted to tell the user what it learned about each schema. If the user approves, the new learnings are added to the pre-generated schema summaries and used in the next runs.