Spaces:
Sleeping
Sleeping
arthi.kasturirangan@informa.com commited on
Commit ·
c0e4bce
1
Parent(s): 8be7bcb
readme
Browse files
README.md
CHANGED
|
@@ -1,11 +1,53 @@
|
|
| 1 |
-
--
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Text-to-SQL Agent API
|
| 2 |
+
|
| 3 |
+
A FastAPI backend service that converts natural language queries into SQL and provides intelligent data insights using LangGraph agents.
|
| 4 |
+
|
| 5 |
+
## Overview
|
| 6 |
+
|
| 7 |
+
This API service enables natural language querying of SQL databases through an AI-powered agent that:
|
| 8 |
+
- Converts text queries to SQL statements
|
| 9 |
+
- Executes queries safely on SQLite databases
|
| 10 |
+
- Provides intelligent data analysis and insights
|
| 11 |
+
- Offers conversational interface for data exploration
|
| 12 |
+
|
| 13 |
+
Built with FastAPI, LangGraph, and SQLAlchemy for high-performance data querying.
|
| 14 |
+
|
| 15 |
+
## Quick Start
|
| 16 |
+
|
| 17 |
+
### Prerequisites
|
| 18 |
+
- Python 3.8+
|
| 19 |
+
- OpenAI API key
|
| 20 |
+
|
| 21 |
+
### Installation
|
| 22 |
+
|
| 23 |
+
1. **Clone and setup:**
|
| 24 |
+
```bash
|
| 25 |
+
git clone https://github.com/arthikrangan/text-to-sql-agent-api.git
|
| 26 |
+
cd text-to-sql-agent-api
|
| 27 |
+
python -m venv .venv
|
| 28 |
+
source .venv/bin/activate # Windows: .venv\Scripts\activate
|
| 29 |
+
```
|
| 30 |
+
|
| 31 |
+
2. **Install dependencies:**
|
| 32 |
+
```bash
|
| 33 |
+
pip install -r requirements.txt
|
| 34 |
+
```
|
| 35 |
+
|
| 36 |
+
3. **Configure environment:**
|
| 37 |
+
```bash
|
| 38 |
+
cp .env.example .env
|
| 39 |
+
# Edit .env and add your OPENAI_API_KEY
|
| 40 |
+
```
|
| 41 |
+
|
| 42 |
+
4. **Run the server:**
|
| 43 |
+
```bash
|
| 44 |
+
uvicorn app.main:app --reload
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
### Docker
|
| 49 |
+
```bash
|
| 50 |
+
# Build and run
|
| 51 |
+
docker build -t text-to-sql-api .
|
| 52 |
+
docker run -p 8000:8000 --env-file .env text-to-sql-api
|
| 53 |
+
```
|