Skip to main content

Code

cookbook/90_models/ibm/watsonx/knowledge.py

Usage

1

Set up your virtual environment

2

Set your API keys

3

Install dependencies

4

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.
5

Run Agent

6

For subsequent runs

After the first run, comment out the knowledge.insert(...) line to avoid reloading the PDF.
The example loads a PDF from a URL, processes it into a vector database (PostgreSQL with pgvector), and creates an IBM WatsonX agent that can query this knowledge base.