The Database ChatBot is a Streamlit-based application designed to allow users to query a MySQL or PostgreSQL database using natural language. By leveraging Langchain for natural language processing, it automatically generates SQL queries based on user input. The chatbot also supports multilingual responses, provides text-to-speech functionality, and allows users to download responses or copy them to the clipboard.
- Natural Language Querying: Generate SQL queries automatically based on user questions in plain text.
- Database Connectivity: Seamlessly connect to MySQL or PostgreSQL databases.
- Multilingual Support: Responds in multiple languages.
- Text-to-Speech: Convert text responses into speech and download them as MP3 files.
- Download & Clipboard Features: Download text responses, audio responses, and copy text responses to the clipboard.
- Session Management: Chat history persists during the session, and you can clear it at any time.
User Input & Customization
Database Connection
Generated Response
-
Clone the Repository:
git clone https://github.com/CodeWizardl/Database-Chatbot.git cd Database-Chatbot
-
Install Dependencies:
pip install -r requirements.txt
-
Download and install the LLaMA 3 model from Ollama:
- Go to Ollama and download the LLaMA 3 model.
- Follow the installation instructions provided on the Ollama website.
- Once installed, ensure that it is properly configured and accessible from your environment.
-
Run the Streamlit Application:
streamlit run app.py
-
Connect to the Database:
- In the sidebar, select MySQL or PostgreSQL and provide connection details (host, port, username, password, and database name).
-
Ask Questions:
- Type a question in natural language (e.g., How many employees are in the database?).
-
View SQL Query and Response:
- The chatbot will generate the SQL query (e.g.,
SELECT COUNT(*) FROM employees;
) and display the result as a natural language response.
- The chatbot will generate the SQL query (e.g.,
-
Multilingual Support:
- Choose a language for responses from the sidebar (English, Hindi, Spanish, etc.).
-
Actions:
- Download: Download the response as text or audio.
- Copy to Clipboard: Copy the text response to the clipboard.
- Text-to-Speech: Listen to the response or download it as an MP3 file.
- User question: How many products are available?
- Generated SQL query:
SELECT COUNT(*) FROM products;
- Response: There are 100 products available.
- Available actions:
- Download the response as text or audio.
- Copy the text to the clipboard.
- Listen to the audio directly in the app.
The chatbot currently supports the following languages:
- Indian Languages: Hindi, Bengali, Telugu, Tamil, Gujarati, Kannada, Punjabi, Malayalam
- Foreign Languages: English, Spanish, French, German, Italian, Portuguese, Arabic, Russian
Using gTTS (Google Text-to-Speech), users can convert text responses into audio files, which are available for download. This feature is especially useful for multilingual responses.
- Query Generation: The application uses Langchain to generate SQL queries based on natural language input.
- Text-to-Speech: The app leverages the gTTS library for generating speech from text, supporting the same set of languages.
- Translation: For translating responses, the Translate library is used, ensuring accurate translations into the supported languages.
- Python (3.8+)
- Streamlit
- Langchain Community (for query generation)
- gTTS (for text-to-speech)
- Pyperclip (for clipboard operations)
- Translate (for translations)
We plan to enhance the Database ChatBot with the following features:
-
Support for More Databases:
- Extend connectivity to other popular databases like MongoDB, SQLite, and Oracle.
-
Advanced Query Optimization:
- Implement advanced query optimization techniques to handle more complex queries and improve response times for large datasets.
-
Contextual Conversations:
- Introduce session-based contextual awareness so the chatbot can maintain context and follow up on previous queries, improving conversational flow.
-
Voice Input Support:
- Integrate voice input features, allowing users to interact with the chatbot using speech, with real-time transcription into text queries.
-
Improved Multimodal Support:
- Extend support for image-based queries where users can upload charts, graphs, or other images, and the chatbot will analyze and respond based on the visual data.
This project is licensed under the MIT License.