Home

Awesome

PrivateGPT App

This repository contains a FastAPI backend and Streamlit app for PrivateGPT, an application built by imartinez. The PrivateGPT App provides an interface to privateGPT, with options to embed and retrieve documents using a language model and an embeddings-based retrieval system. All data remains local.

Easiest way to deploy:

Deploy Full App on Railway

Deploy Full App on Railway

Deploy Backend on Railway

Deploy Backend on Railway

Developer plan will be needed to make sure there is enough memory for the app to run.

Requirements

Setup

  1. Create a Python virtual environment using your preferred method.

  2. Copy the environment variables from example.env to a new file named .env. Modify the values in the .env file to match your desired configuration. The variables to set are:

    • PERSIST_DIRECTORY: The directory where the app will persist data.
    • MODEL_TYPE: The type of the language model to use (e.g., "GPT4All", "LlamaCpp").
    • MODEL_PATH: The path to the language model file.
    • EMBEDDINGS_MODEL_NAME: The name of the embeddings model to use.
    • MODEL_N_CTX: The number of contexts to consider during model generation.
    • API_BASE_URL: The base API url for the FastAPI app, usually it's deployed to port:8000.
  3. Install the required dependencies by running the following command:

    pip install -r requirements.txt
    

Usage

Running the FastAPI Backend

To run the FastAPI backend, execute the following command:

gunicorn app:app -k uvicorn.workers.UvicornWorker --timeout 1500

This command starts the backend server and automatically handles the necessary downloads for the language model and the embedding models. The --timeout 500 option ensures that sufficient time is allowed for proper model downloading.

Running the Streamlit App

Please update the API_BASE_URL to appropriate FastAPI url

To run the Streamlit app, use the following command:

streamlit run streamlit_app.py --server.address localhost

This command launches the Streamlit app and connects it to the backend server running at localhost.

Important Considerations

The supported extensions for documents are:

Certainly! Here are examples of how to call the API routes mentioned in the README:

Root Route

Embed Route

Retrieve Route

Please note that the actual URL (http://localhost:8000/) and the request payloads should be adjusted based on your specific setup and requirements.