This project is a Flask web application that uses pgvector for vector storage and retrieval, along with langchain for language model interactions.
- Docker
- Python 3.8+
- pip
- ollama
-
Pull the Docker image for PostgreSQL with pgvector:
docker pull ankane/pgvector
-
Run the Docker container:
docker run --name pgvector -e POSTGRES_USER=mirror -e POSTGRES_PASSWORD=mysecretpassword -e POSTGRES_DB=mirror -d -p 6024:5432 pgvector/pgvector:pg16
Replace
mysecretpasswordwith a secure password of your choice.
-
Create a virtual environment:
python3 -m venv venv
-
Activate the virtual environment:
source venv/bin/activate -
Install the required packages:
pip install -r requirements.txt
-
Set the
DATABASE_URLenvironment variable with your database connection string. For example:export DATABASE_URL="postgresql://mirror:mysecretpassword@localhost:6024/mirror"
-
Navigate to the
frontenddirectory:cd frontend -
Install the frontend dependencies:
npm install
-
Build the UI:
npm run build
-
Start the Flask application:
python app.py
-
Access the application at
http://localhost:5000.
-
Install the necessary models
ollama pull phi3:mini ollama pull mistral
To run the API in development mode, set the FLASK_DEBUG environment variable to True:
export FLASK_DEBUG=TrueThen start the Flask application as usual:
python app.pyPOST /generate: Generate a response using the LLM based on the provided prompt. The response includes the generated text and an optional array of sources.GET /system_prompt: Retrieve the current system prompt.PUT /system_prompt: Update the system prompt.POST /embed: Embed a title and description and save it to the database.POST /rag: Retrieve and generate an answer for a given question using RAG. The response includes the generated answer and an array of sources.
To build the Docker image for the application, run the following command in the root directory of the project:
docker build -t n3rdgir1/elysian-mirror:latest .To publish the Docker image to GitHub's registry, follow these steps:
-
Authenticate with GitHub's Docker registry:
echo $GITHUB_TOKEN | docker login ghcr.io -u n3rdgir1 --password-stdin
-
Tag the Docker image:
docker tag n3rdgir1/elysian-mirror:latest ghcr.io/n3rdgir1/elysian-mirror:latest
-
Push the Docker image to GitHub's registry:
docker push ghcr.io/n3rdgir1/elysian-mirror:latest
To run the Docker container, use the following command:
docker-compose up -dThis will start the containers and expose the application on port 5012.