Skip to content

hamidtech/Ollama-MultiChatbot

Repository files navigation

Ollama-MultiChatbot

Streamlit PythonOllama License GitHub stars

Table of Contents

Introduction

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.

Features

  • 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.

Technologies Used

  • 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.

Installation

Follow these steps to set up and run the application locally.

Prerequisites

  • Python 3.7 or higher installed on your machine.
  • MySQL Server running and accessible.
  • Git installed to clone the repository.

Steps

  1. Clone the Repository

    git clone https://github.com/hamidtech/Ollama-MultiChatbot.git
    cd Ollama-MultiChatbot
  2. 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
  3. 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
  4. 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.

  5. Run the Application

    streamlit run app.py

    Replace your_app.py with the actual name of your Python script.

Usage

  1. 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.
  2. 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.

Database Setup

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.

Contributing

Contributions are welcome! If you'd like to enhance this project, please follow these steps:

  1. Fork the Repository

  2. Create a New Branch

    git checkout -b feature/YourFeature
  3. Commit Your Changes

    git commit -m "Add your feature"
  4. Push to the Branch

    git push origin feature/YourFeature
  5. Open a Pull Request

License

This project is licensed under the MIT License.

Contact

If you have any questions or suggestions, feel free to reach out:

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages