RAG Agent
Code
Usage
Create a virtual environment
Open the Terminal
and create a python virtual environment.
Set your API key
Install libraries
Set up PostgreSQL with pgvector
You need a PostgreSQL database with the pgvector extension installed. Adjust the db_url
in the code to match your database configuration.
Run Agent
For subsequent runs
After the first run, comment out the knowledge_base.load(recreate=True)
line to avoid reloading the PDF.
This example shows how to integrate a knowledge base with IBM WatsonX. It loads a PDF from a URL, processes it into a vector database (PostgreSQL with pgvector in this case), and then creates an agent that can query this knowledge base.
Note: You need to install several packages (pgvector
, pypdf
, etc.) and have a PostgreSQL database with the pgvector extension available.