An application to demonstrate how to create a Retrieval-Augmented Generation (RAG) system using EDB's aidb extension v4.1.1 and PostgreSQL v16+. The chat console below showcases the features of a RAG system designed to answer questions specifically about EDB Bloggers. The biographies have been collected from EDB’s website. The system can seamlessly work with HTML files stored in a volume, such as object storage, with aidb managing the content from these sources using a preparer. Once a new file is added to the volume, aidb automates the process by integrating the new information into the pipeline, enabling the RAG to provide up-to-date answers. If no relevant data is available, the system will respond with: "I'm sorry, I couldn't find any information about this person."
- Python 3
- PostgreSQL v16+
- aidb v4.1.1
- pgfs v2.0.1+
- Clone the repository:
git clone git@github.com:EnterpriseDB/rag-demo-v4.1.1.git
cd rag-demo-v4.1.1- Set up a virtual environment and install dependencies:
virtualenv env -p `which python`
source env/bin/activate
pip install -r requirements.txt- Configure environment variables by copying and editing the
.envfile:
cp .env-example .envConnect to your PostgreSQL environment using the psql terminal and verify the connection:
psql -U uname -h p-xxx -p port_number -d edb_db
Password for user uname:The application workflow is divided into two phases: Initialization and Chat.
Prepare the database and create the preparer, retriever, and embeddings:
- View available commands:
python app.py --help- Usage:
python app.py [-h] {create-db, import-data-s3, chat}- Example: Import data from an object storage source (e.g., S3 bucket):
python app.py import-data-s3Use the chat functionality to interact with the RAG system:
- View help for the chat application:
streamlit run app_x.py --help- Usage with Hugging Face Generative Models (requires a CUDA environment) or Ollama Models (runs on CPU, ensure the model is pulled and running):
streamlit run app.py chat-h, --help Show this help message and exit{create-db, import-data-s3, chat}
Display available subcommands
create-db Create a database
import-data-s3 Use an object storage (e.g., S3 bucket) as a source for aidb retriever
chat Use the chat featureBy following these steps, you can set up and use the RAG system effectively.
If an update is required from the object storage, simply call the bulk_data_preparation function as shown below:
SELECT aidb.bulk_data_preparation('preparer_retriever_name');