Skip to content

Acquiring sensor data from WPVH and vectorising real-time data for LLM QA web app.

License

Notifications You must be signed in to change notification settings

Krasnomakov/vHUB_QA_withSensorData

Repository files navigation

WPVH AI Chat Solution 🤖

A retrieval QA solution for the WPVH Eindhoven AI chat, using real-time sensor data. This application is powered by the Mistral LLM model served via Ollama.

Python Docker LangChain Ollama

🎥 Demo

Check out the video demo: Watch Here

✨ Features

  • Real-time Data QA: Chat with an AI that has access to the latest sensor data.
  • Local LLM: Uses a locally hosted Mistral model with Ollama for privacy and control.
  • Extensible: Built with modular components using Flask and LangChain.
  • Vector Storage: Utilizes ChromaDB for efficient similarity searches on sensor data.

🛠️ Tech Stack

  • Backend: Python, Flask
  • LLM & Tooling: Ollama, LangChain, Mistral
  • Database: ChromaDB (for vector storage)
  • Deployment: Docker

🚀 Getting Started

Follow these steps to get the project up and running on your local machine.

Prerequisites

  • Python 3.x
  • Ollama: Install from Ollama.ai.
    • For Windows users: Use the Docker version of Ollama. Tutorial here.

      Note: This project was developed before Ollama had a native Windows client. While a native client is now available, these instructions are based on the Docker setup.

⚙️ Installation & Running

  1. Clone the Repository

    git clone <repository-url>
    cd vHUB_QA_withSensorData

    Replace <repository-url> with the actual URL of this repository.

  2. Install Dependencies

    pip install -r requirements.txt
  3. Set Up Ollama Model (Skip for Windows) Create a system prompt for the LLM model:

    ollama create vhubAgent -f ./modelfile
  4. Run Ollama

    • For Docker: docker exec -it ollama ollama run vhubAgent
    • For Windows (with Docker): docker exec -it ollama ollama run mistral
  5. Enter Credentials Open keys.py and enter your username and password for the vhub delta API.

  6. Start the Servers

    • Data Server: Open a terminal and run:
      python dataServerWithRoomsCSVNew.py
    • Retrieval QA Server: Open a new terminal and run:
      python ollamaWithDataCSV.py

🎉 Your chat application is now live at http://localhost:5003.

⚠️ Important Notes

  • Clear Data: Use the clear data button in the UI to prevent overwhelming the data server. The dataframe will need some time to repopulate with new values.
  • Threading: The application uses a semaphore to limit concurrent threads to 100 for fetching sensor data. This can be adjusted in dataServerWithRoomsCSVNew.py.
  • Sensor Limit: There are 191 sensors in sensors_list.txt. Increasing the thread limit in threading.Semaphore(100) to 191 to fetch all data concurrently may lead to instability, such as saving incorrect values or injecting empty data.

☁️ Deployment

This document contains information about deployment options and requirements.

Local Deployment

Both local deployment options will require Python installed (development done with Python version 3.11). Python modules such as Langchain, Flask and others must be installable.

LLM models can be downloaded from:

Docker (Prioritized Option)

Docker deployment doesn't mean a fully containerised application - Docker is used to run the Ollama LLM server on Windows.

LM Studio (Alternative)

This alternative will require code modification.

Cloud Deployment (Azure)

Azure deployment allows several options. They are available as subscription plans and pay-as-you-go.

Relevant services:

  • App Services: For Python Flask app deployment. (Quickstart: Deploy a Python (Django or Flask) web app to Azure App Service)
  • AI Studio: To connect to an LLM run by Azure. (How to deploy Llama 2 family of large language models with Azure AI Studio)
  • Virtual machine: To deploy the full-stack inside a Linux VM. (Virtual Machines (VMs) for Linux and Windows | Microsoft Azure)

Linux Server

  • Server access
  • Ollama installed (https://ollama.ai/)
  • Python 3.11
  • Permission to install Linux packages and Python modules.

About

Acquiring sensor data from WPVH and vectorising real-time data for LLM QA web app.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published