- Introduction
- Features
- Technologies Used
- Installation
- Usage
- Database Setup
- Contributing
- License
- Contact
Welcome to the Ollama-MultiChatbot project! This application provides an interactive web interface that allows users to interact with a MySQL database, process PDFs, and engage in free-form conversations using natural language queries. By leveraging Streamlit for the frontend and LangChain integrated with the ChatOllama language model, the application translates plain English questions into actionable commands, executes them, and returns the results in an easy-to-understand format.
- Natural Language Processing: Input queries in everyday language, which are converted into SQL statements or PDF processing commands by the language model.
- Interactive Chat Interface: Seamless conversation with the system, maintaining chat history for context.
- Dynamic Database Connection: Connect to any MySQL database by entering your credentials through the sidebar.
- PDF Processing: Upload and interact with PDF documents using natural language commands.
- Automated Response Generation: Executes queries and processes results or PDF content, translating them back into human-readable responses.
- Session Management: Maintains state across user interactions to ensure a smooth user experience.
- Streamlit: For building the interactive web application.
- LangChain: To integrate the language model for interpreting and generating SQL queries and PDF processing commands.
- MySQL: As the relational database management system.
- ChatOllama (LLM): For processing natural language inputs and producing corresponding SQL queries or PDF commands.
- Python 3.7+: Programming language used for development.
Follow these steps to set up and run the application locally.
- Python 3.7 or higher installed on your machine.
- MySQL Server running and accessible.
- Git installed to clone the repository.
-
Clone the Repository
git clone https://github.com/hamidtech/Ollama-MultiChatbot.git cd Ollama-MultiChatbot
-
Create a Virtual Environment
It's recommended to use a virtual environment to manage dependencies.
python3 -m venv venv source venv/bin/activate # On Windows, use venv\Scripts\activate
-
Install Required Libraries
pip install -r requirements.txt
If a
requirements.txt
file is not present, you can install the necessary packages directly:pip install streamlit langchain_community mysql-connector-python
-
Set Up Environment Variables (Optional but Recommended)
To securely manage database credentials, consider using environment variables or a
.env
file.touch .env
Add the following to the
.env
file:DB_HOST=localhost DB_PORT=3306 DB_USERNAME=root DB_PASSWORD=yourpassword DB_NAME=music
Ensure you update the values with your actual database credentials.
-
Run the Application
streamlit run app.py
Replace
your_app.py
with the actual name of your Python script.
-
Connect to the Database
- Open the application in your browser (usually at
http://localhost:8501
). - In the sidebar, enter your MySQL database credentials:
- Host
- Port
- Username
- Password
- Database Name
- Click the Connect button. A success message will appear upon a successful connection.
- Open the application in your browser (usually at
-
Interact via Chat
- Use the chat input at the bottom of the page to enter your natural language queries.
- Example Queries:
- "How many albums are in the database?"
- "List all customers from Brazil."
- "Summarize the contents of the uploaded PDF."
- The application will display both your query and the assistant's response.
To set up the necessary database schema and populate it with sample data, execute the provided SQL scripts in MySQL environment.
Use any public MySQL environemnt like MySQL Workbench to run .sql file
Ensure you replace yourusername
and yourpassword
with your actual MySQL credentials.
Contributions are welcome! If you'd like to enhance this project, please follow these steps:
-
Fork the Repository
-
Create a New Branch
git checkout -b feature/YourFeature
-
Commit Your Changes
git commit -m "Add your feature"
-
Push to the Branch
git push origin feature/YourFeature
-
Open a Pull Request
This project is licensed under the MIT License.
If you have any questions or suggestions, feel free to reach out:
- Hamid Jamali
- Email: [email protected]
- GitHub: hamidtech