Git Product home page Git Product logo

rag-streamlit-chatbot's Introduction

RAG Streamlit Chatbot

This repository serves as an example for creating a streamlit application. The goal is to be able to quickly spin up a RAG chatbot (with a streamlit interface) that can answer questions about your own data.

Prerequisites

To use the code in this repo, there are two things you need: data (duh) and a OpenAI API key.

First, provide the key in a file you call config.ini in this format:

[credentials]
api_key = <your_OpenAI_API_key>

Then, you must prepare your data. Using Langchain, a locally stored vector database will be created from the data. See src/create_vdb.py for implementation. So in essence:

  1. Create a csv file where each row are text chunks, and contains the text in a column named "text".
  2. Name the file <your_data>.csv and save it in the data folder.
  3. Set KNOWLEDGE_BASE = "your_data" in create_vdb.py and in app.py

Currently, there is an example for "hjertemedisin" (heart medicine) data, and you can see how the data is stored as a csv in data/hjertemedisin.csv

Setup

Before starting, make sure you have Python 3.x installed on your system.

Step 1: Clone the Repository

Clone this repository to your local machine using Git:

git clone https://github.com/martinstiles/RAG-Streamlit-Chatbot
cd RAG-Streamlit-Chatbot

Step 2: Activate Python Venv (optional)

Initialize the python environment by running the following command inside the project folder.

python -m venv venv

Activate the venv by running the following on Windows:

venv\Scripts\activate

or on Mac / Linux:

source venv/bin/activate

Step 3: Install requirements

All required python packages are found in requirements.txt and can be installed by running:

pip install -r requirements.txt

Create Vector Database

If you have followed the setup procedure, create a vector database by running src/create_vdb.py.

Run the project

If you have created a vector database, the project can be run with the following command:

streamlit run src/app.py

Create and run Docker Container

If you want, you can run the applicaiton in a Docker container. First, make sure you have Docker installed by running:

docker --version

To create a Docker image for the streamlit application on your local machine and run the following command:

docker build -t llm_demo .

Once the image has been created, you can run a container locally by running:

docker run -p 8501:8501 llm_demo

Security Concerns

In general, you should never feed sensitive data into a public API. If you are trying to chat with your own private data and use a LLM API to accomplish it (like in this repo): make sure the data are non-sensitive.

rag-streamlit-chatbot's People

Contributors

martinstiles avatar

Watchers

Kostas Georgiou avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.