devjas1 commited on
Commit
1a4aef5
Β·
1 Parent(s): 9fea9b9

Update README.md to enhance project documentation with detailed features, installation instructions, usage examples, and project structure.

Browse files
Files changed (1) hide show
  1. README.md +70 -0
README.md CHANGED
@@ -7,3 +7,73 @@ sdk: static
7
  pinned: false
8
  app_file: index.html
9
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  pinned: false
8
  app_file: index.html
9
  ---
10
+
11
+ ## Build AI Agent Text-to-SQL
12
+
13
+ πŸ—£οΈ **Text-to-SQL AI Agent**
14
+ A demonstration project for building an intelligent agent that translates natural language queries into SQL, executes them, and returns results using [smolagents](https://github.com/smol-ai/smol-agent), [SQLAlchemy](https://www.sqlalchemy.org/), and [python-dotenv](https://pypi.org/project/python-dotenv/).
15
+
16
+ ---
17
+
18
+ ## Features
19
+
20
+ - Converts plain English questions into SQL queries.
21
+ - Executes queries on an in-memory SQLite database.
22
+ - Supports multiple tables and table joins.
23
+ - Uses LLMs for advanced query understanding.
24
+ - Easily extensible for new tables and schemas.
25
+
26
+ ## Installation
27
+
28
+ ````bash
29
+ git clone https://github.com/your-username/txt-to-sql-agent.git
30
+ cd txt-to-sql-agent
31
+ pip install -r requirements.txt
32
+ ```plaintext
33
+
34
+ ## Usage
35
+
36
+ Edit `text_to_sql.py` to define your tables and sample data.
37
+ Run the agent:
38
+
39
+ ```bash
40
+ python text_to_sql.py
41
+ ````
42
+
43
+ ## Example
44
+
45
+ Ask the agent:
46
+
47
+ > "Which waiter received the highest total amount in tips?"
48
+
49
+ The agent will generate and execute the appropriate SQL query, returning the answer.
50
+
51
+ ## Project Structure
52
+
53
+ ```text
54
+ .
55
+ β”œβ”€β”€ README.md
56
+ β”œβ”€β”€ text_to_sql.py
57
+ β”œβ”€β”€ index.html
58
+ ```
59
+
60
+ ## How It Works
61
+
62
+ - Defines tables (`receipts`, `waiters`) using SQLAlchemy.
63
+ - Loads sample data into an in-memory SQLite database.
64
+ - Uses smolagents to create a CodeAgent with SQL querying tools.
65
+ - The agent interprets natural language and generates SQL queries.
66
+ - Results are printed to the console.
67
+
68
+ ## Contributing
69
+
70
+ Pull requests and suggestions are welcome!
71
+ Please open an issue for bugs or feature requests.
72
+
73
+ ## License
74
+
75
+ [![License](https://img.shields.io/badge/Apache--2.0-green?style=for-the-badge)](https://opensource.org/licenses/Apache-2.0)
76
+
77
+ ---
78
+
79
+ [![HF Space](https://img.shields.io/badge/-HuggingFace-FDEE21?style=for-the-badge&logo=HuggingFace&logoColor=black)](https://huggingface.co/spaces/dev-jas/text-to-sql-smolagent)