Skip to main content

Code

db.py

Usage

1

Set up your virtual environment

2

Set your API key

3

Install dependencies

4

Set up PostgreSQL

Make sure you have a PostgreSQL database running. You can adjust the db_url in the code to match your database configuration.
5

Run Agent

Save the code above as db.py, then run:
PostgreSQL storage maintains conversation state across multiple interactions. The example creates an IBM WatsonX agent with a PostgreSQL storage backend and sends multiple messages, preserving the conversation history between them.