Invicto69 commited on
Commit
d3bfe40
·
verified ·
1 Parent(s): 6cfa9f4

Synced repo using 'sync_with_huggingface' Github Action

Browse files
Files changed (1) hide show
  1. readme.md +79 -0
readme.md ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SQLchat
2
+
3
+ This project is a **SQL Chatbot** built with **LangChain** and **Streamlit**, designed to generate SQL queries and execute queries
4
+ based on database table schemas and structure. The chatbot can interact with users to understand their requirements
5
+ and translate them into SQL queries, leveraging relational database information provided via URI and schema definitions.
6
+
7
+ ## Features
8
+
9
+ - **SQL Query Generator**: Automatically generates SQL queries based on user inputs and database structure.
10
+ - **SQL Query Execution**: Automatically executes SQL queries generated by chatbot.
11
+ - **Interactive Chat Interface**: Built with Streamlit for a user-friendly conversational experience.
12
+ - **Database Schema Integration**: Parses table schemas from a database URI to provide accurate SQL generation capabilities.
13
+ - **Customizable LLM Configuration**: Supports various large language models (LLMs) for generating responses.
14
+
15
+ ## Installation
16
+
17
+ 1. Clone the repository:
18
+
19
+ ```bash
20
+ git clone https://github.com/arthiondaena/SQLchat.git
21
+ cd SQLchat
22
+ ```
23
+
24
+ 2. Set up a virtual environment:
25
+
26
+ ```bash
27
+ python -m venv venv
28
+ source venv/bin/activate # On Windows: venv\Scripts\activate
29
+ ```
30
+
31
+ 3. Install dependencies:
32
+
33
+ ```bash
34
+ pip install -r requirements.txt
35
+ ```
36
+
37
+ ## Usage
38
+
39
+ Run the application using Streamlit:
40
+
41
+ ```bash
42
+ streamlit run app.py
43
+ ```
44
+
45
+ This will launch the chatbot interface in your default web browser. The chatbot can then process user inputs and generate SQL queries based on the database schema.
46
+
47
+ ## Setup
48
+
49
+ 1. **Configure Database Connection**:
50
+ - Set up the `URI` configuration in the streamlit app to connect to your relational database.
51
+ - Ensure the database has the necessary permissions to allow schema queries.
52
+
53
+ 2. **Table Schemas**:
54
+ - The chatbot extracts table structures and schemas from the database for generating SQL queries. Make sure the database contains valid schema definitions.
55
+
56
+ 3. **API Key Configuration**:
57
+ - Provide your Groq API key for LLM integration within the script.
58
+
59
+ 4. **System Prompt Customization**:
60
+ - Adjust the instructions as per your specific SQL generation use case.
61
+ - The chatbot can remember upto last 4 conversations.
62
+
63
+ ## Features in Detail
64
+
65
+ 1. **SQL Query Generation**:
66
+ - The chatbot uses relational database schemas to intelligently generate SQL queries.
67
+ - Supports basic and complex queries tailored to the provided database structure.
68
+
69
+ 2. **Database Schema Utilization**:
70
+ - Extracts table information (columns, types, relationships) from the connected database.
71
+ - Leverages this knowledge to produce highly precise SQL queries.
72
+
73
+ 3. **Customizable Model Prompts**:
74
+ - Custom system prompts and instructions can be added to suit diverse database use cases.
75
+
76
+ ## Example Workflow
77
+ 1. Connect the chatbot to your database by specifying the database URI.
78
+ 2. Provide the chatbot with your SQL query requirement in plain language (e.g., "Fetch the top 10 customers by revenue").
79
+ 3. The chatbot generates and returns an accurate SQL query based on the schema.