File size: 1,500 Bytes
94404c6
 
 
 
 
 
 
 
 
 
 
e4b501b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
---
title: Text To Sql Agent Api
emoji: 🐨
colorFrom: indigo
colorTo: indigo
sdk: docker
pinned: false
short_description: SQL agent to converse with structured databases
---

Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference

# Text-to-SQL Agent API

A FastAPI backend service that converts natural language queries into SQL and provides intelligent data insights using LangGraph agents.

## Overview

This API service enables natural language querying of SQL databases through an AI-powered agent that:
- Converts text queries to SQL statements
- Executes queries safely on SQLite databases
- Provides intelligent data analysis and insights
- Offers conversational interface for data exploration

Built with FastAPI, LangGraph, and SQLAlchemy for high-performance data querying.

## Quick Start

### Prerequisites
- Python 3.8+
- OpenAI API key

### Installation

1. **Clone and setup:**
```bash
git clone https://github.com/arthikrangan/text-to-sql-agent-api.git
cd text-to-sql-agent-api
python -m venv .venv
source .venv/bin/activate  # Windows: .venv\Scripts\activate
```

2. **Install dependencies:**
```bash
pip install -r requirements.txt
```

3. **Configure environment:**
```bash
cp .env.example .env
# Edit .env and add your OPENAI_API_KEY
```

4. **Run the server:**
```bash
uvicorn app.main:app --reload
```


### Docker
```bash
# Build and run
docker build -t text-to-sql-api .
docker run -p 8000:8000 --env-file .env text-to-sql-api
```