Suresh Beekhani commited on
Commit
35b6602
Β·
unverified Β·
1 Parent(s): b2cbba7

Update readme.md

Browse files
Files changed (1) hide show
  1. readme.md +51 -73
readme.md CHANGED
@@ -1,83 +1,61 @@
1
  ---
2
- title: "Chat-with-MySQL" # Display title for the Space
3
- emoji: "πŸ“°" # Space emoji (emoji-only character allowed)
4
- colorFrom: "blue" # Color for Thumbnail gradient
5
- colorTo: "green" # Color for Thumbnail gradient
6
- sdk: streamlit # SDK being used (gradio, streamlit, docker, or static)
7
- sdk_version: "1.38.0" # Specify the version of the selected SDK
8
- app_file: "src/app.py" # Path to your main application file
9
- pinned: false # Whether the Space stays on top of your profile
10
  ---
11
- # MySQL Python Chatbot with GPT-4 and Mistral AI
12
 
13
- Welcome to the GitHub repository for our tutorial on building a natural language SQL chatbot using GPT-4! This project guides you through the development of a chatbot that can interpret natural language queries, generate SQL queries, and fetch results from a SQL database, all in an intuitive and user-friendly way. It utilizes the power of OpenAI's GPT-4 model, integrated with a Streamlit GUI for an enhanced interaction experience.
14
 
15
- 🟑 This repository serves as supporting material for the [YouTube video tutorial](https://youtu.be/YqqRkuizNN4).
16
 
17
  ## Features
18
- - **Natural Language Processing**: Uses GPT-4 to interpret and respond to user queries in natural language.
19
- - **SQL Query Generation**: Dynamically generates SQL queries based on the user's natural language input.
20
- - **Database Interaction**: Connects to a SQL database to retrieve query results, demonstrating practical database interaction.
21
- - **Streamlit GUI**: Features a user-friendly interface built with Streamlit, making it easy for users of all skill levels.
22
- - **Python-based**: Entirely coded in Python, showcasing best practices in software development with modern technologies.
23
-
24
- ## Brief Explanation of How the Chatbot Works
25
-
26
- The chatbot works by taking a user's natural language query, converting it into a SQL query using GPT-4, executing the query on a SQL database, and then presenting the results back to the user in natural language. This process involves several steps of data processing and interaction with the OpenAI API and a SQL database, all seamlessly integrated into a Streamlit application.
27
-
28
- Consider the following diagram to understand how the different chains and components are built:
29
-
30
- ![Chatbot Architecture](./docs/mysql-chains.png)
31
-
32
- For a more detailed explanation and a step-by-step guide, refer this other video: [YouTube video tutorial](https://youtu.be/9ccl1_Wu24Q).
33
-
34
- For a more detailed explanation and a step-by-step guide, refer to the [YouTube video tutorial](Chat with MySQL Database with Python | LangChain Tutorial).
35
-
36
- ## Installation
37
- Ensure you have Python installed on your machine. Then clone this repository:
38
-
39
- ```bash
40
- git clone [repository-link]
41
- cd [repository-directory]
42
- ```
43
-
44
- Install the required packages:
45
-
46
- ```bash
47
  pip install -r requirements.txt
48
- ```
49
-
50
- Create your own .env file with the necessary variables, including your OpenAI API key:
51
-
52
- ```bash
53
- OPENAI_API_KEY=[your-openai-api-key]
54
- ```
55
-
56
- ## Usage
57
- To launch the Streamlit app and interact with the chatbot:
58
-
59
- ```bash
 
60
  streamlit run app.py
61
- ```
62
-
63
- ## Contributing
64
- As this repository accompanies the [YouTube video tutorial](https://youtu.be/YqqRkuizNN4), we are primarily focused on providing a comprehensive learning experience. Contributions for bug fixes or typos are welcome.
65
 
66
- ## License
67
- This project is licensed under the MIT License - see the LICENSE file for details.
68
-
69
- ---
70
-
71
- **Note**: This project is intended for educational and research purposes. Please ensure compliance with the terms of use and guidelines of any APIs or services used.
72
-
73
- ---
74
 
75
- We hope this repository aids in your exploration of integrating AI with web technologies. For more informative tutorials, be sure to check out [Your YouTube Channel].
76
-
77
- Happy Coding! πŸš€πŸ‘¨β€πŸ’»πŸ€–
78
-
79
- ---
80
-
81
- *If you find this project helpful, please consider giving it a star!*
82
-
83
- ---
 
1
  ---
2
+ title: Chat with MySQL
3
+ emoji: πŸ’¬
4
+ colorFrom: purple
5
+ colorTo: blue
6
+ sdk: streamlit
7
+ sdk_version: "1.0"
8
+ app_file: app.py
9
+ pinned: false
10
  ---
 
11
 
12
+ # Chat with MySQL
13
 
14
+ This is a Streamlit application that allows users to interact with a MySQL database via natural language queries. The app uses LangChain, Groq, and Streamlit to generate SQL queries and respond with database results in natural language.
15
 
16
  ## Features
17
+ - Connect to your MySQL database and chat with it using natural language.
18
+ - Automatically generate SQL queries based on your questions.
19
+ - Receive responses both in SQL and human-readable formats.
20
+
21
+ ## Libraries and Tools Used
22
+ - **dotenv**: Loads environment variables from a `.env` file.
23
+ - **LangChain**: Handles the prompt templates and chains for generating SQL queries and responses.
24
+ - **Groq**: Utilized as the model for chat-based interactions and SQL generation.
25
+ - **Streamlit**: Provides the interface for interacting with the database and handling the conversation.
26
+ - **SQLDatabase**: LangChain's utility to manage SQL database connections and queries.
27
+
28
+ ## Setup Instructions
29
+
30
+ 1. Clone the repository:
31
+ ```bash
32
+ git clone https://github.com/your-repo/chat-with-mysql.git
33
+ cd chat-with-mysql
34
+ Install the required Python libraries:
35
+
36
+ bash
37
+ Copy code
 
 
 
 
 
 
 
 
38
  pip install -r requirements.txt
39
+ Create a .env file in the root directory of the project and add your database credentials:
40
+
41
+ bash
42
+ Copy code
43
+ DB_USER=root
44
+ DB_PASSWORD=admin
45
+ DB_HOST=localhost
46
+ DB_PORT=3306
47
+ DB_NAME=Chinook
48
+ Run the application:
49
+
50
+ bash
51
+ Copy code
52
  streamlit run app.py
53
+ Open your browser and go to the Streamlit web app, typically at http://localhost:8501.
 
 
 
54
 
55
+ How It Works
56
+ The app connects to a MySQL database using credentials from environment variables.
57
+ It uses a LangChain model to process user queries, convert them into SQL statements, and return the results.
58
+ You can view the SQL query generated from your questions and the corresponding response.
59
+ Configuration
60
+ Check out the configuration reference at Hugging Face Spaces Config Reference.
 
 
61