Skip to content

Simple example script of integration of watsonx.ai and Watson Discovery for a RAG use case

Notifications You must be signed in to change notification settings

ibm-build-lab/watsonxai-discovery-rag-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

RAG Integration (Watson Discovery + watsonx.ai)

This script is a simple illustrative example of integrating Watson Discovery and watsonx.ai together.

You will need Python installed locally to run this script: https://www.python.org/downloads

Most recently tested with version 3.12.2

How to use this script

First, you must create a .env file at the project root containing all sensitive data about your instances of Watson Discovery and watsonx.ai.

Here is a table of them:

Name Description
IBM_DISC_API_KEY API key with access to Discovery instance. Can be created here
IBM_DISC_PROJ_ID Project ID of Discovery instance. Available within cloud console.
IBM_DISC_SERVICE_URL Service URL of Discovery instance. Available within cloud console.
IBM_DISC_COLL_ID Collection ID of the collection of documents you wish to query as context within Discovery.
IBM_WX_API_KEY API key with access to watsonx.ai project. Can be created here
IBM_WX_PROJ_ID Project ID of watsonx.ai project. Availabe under "Settings" within project.
IBM_WX_SERVICE_URL Service URL of watsonx.ai project. Tied to locale of projects deployment.

There is a blank version in env_example. Feel free to rename this to .env and fill it with the required values. From the command line you could do:

# this command will create a copy of the file titled .env
cp env_example .env

Then you can fill out the created .env file with your instance values.

Ensure you can see hidden files within your explorer or editor to see the .env file.

Next, install the dependencies required for the script:

# installs dependencies needed for the script to run
python -m pip install -r requirements.txt

Lastly, you can now run the script via:

# runs the actual script
python rag.py

To change the question being asked simply change the QUERY variable located near the top of the script and run once more.

About

Simple example script of integration of watsonx.ai and Watson Discovery for a RAG use case

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages