devjas1
Update README.md to enhance project documentation with detailed features, installation instructions, usage examples, and project structure.
1a4aef5
metadata
title: Build AI Agent Text-to-SQL
emoji: πŸ—£οΈ
colorFrom: green
colorTo: blue
sdk: static
pinned: false
app_file: index.html

Build AI Agent Text-to-SQL

πŸ—£οΈ Text-to-SQL AI Agent
A demonstration project for building an intelligent agent that translates natural language queries into SQL, executes them, and returns results using smolagents, SQLAlchemy, and python-dotenv.


Features

  • Converts plain English questions into SQL queries.
  • Executes queries on an in-memory SQLite database.
  • Supports multiple tables and table joins.
  • Uses LLMs for advanced query understanding.
  • Easily extensible for new tables and schemas.

Installation

git clone https://github.com/your-username/txt-to-sql-agent.git
cd txt-to-sql-agent
pip install -r requirements.txt
```plaintext

## Usage

Edit `text_to_sql.py` to define your tables and sample data.
Run the agent:

```bash
python text_to_sql.py

Example

Ask the agent:

"Which waiter received the highest total amount in tips?"

The agent will generate and execute the appropriate SQL query, returning the answer.

Project Structure

.
β”œβ”€β”€ README.md
β”œβ”€β”€ text_to_sql.py
β”œβ”€β”€ index.html

How It Works

  • Defines tables (receipts, waiters) using SQLAlchemy.
  • Loads sample data into an in-memory SQLite database.
  • Uses smolagents to create a CodeAgent with SQL querying tools.
  • The agent interprets natural language and generates SQL queries.
  • Results are printed to the console.

Contributing

Pull requests and suggestions are welcome!
Please open an issue for bugs or feature requests.

License

License


HF Space