Skip to content

Updated README.md on Python requirements #98

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 5 additions & 29 deletions ai-vectors/rag-langchain/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Implementing Retrieval-Augmented Generation with IBM Db2 and LangChain on RHEL 9.4
# Implementing Retrieval-Augmented Generation with IBM Db2, watsonx.ai, LangChain

## Introduction

This README presents step-by-step instructions for implementing a Retrieval-Augmented Generation (RAG) use case using IBM Db2 and LangChain on Red Hat Enterprise Linux (RHEL) 9.4. In a recent Early Access Program (EAP), Db2 introduced a native vector data type and vector similarity search functionality. Leveraging these capabilities, I have implemented a complete RAG pipeline with LangChain and Python in a Jupyter Notebook. Customers with access to this EAP build can try out these features in a non-production setup.
This README presents step-by-step instructions for implementing a Retrieval-Augmented Generation (RAG) use case using IBM Db2, watsonx.ai, and LangChain. The complete is available in the [`rag-basic.ipynb`](rag-basic.ipynb) notebook in the same folder, In March 2025 Early Access Program (EAP) build , Db2 introduced a native vector data type and vector similarity search functionality. Leveraging these capabilities, I have implemented a complete RAG pipeline with LangChain and Python in a Jupyter Notebook. Customers with access to [this](http://ibm.biz/db2_early_access_program) EAP build can try out these features in a non-production setup.

## Understanding Retrieval-Augmented Generation

Expand Down Expand Up @@ -61,9 +61,8 @@ These enhancements allow Db2 to efficiently store and process high-dimensional d

## Implementing the RAG Pipeline

### 1. Setting Up the Environment on RHEL 9.4

To begin, ensure that your system is running RHEL 9.4 and has Python 3.12 installed. Starting from RHEL 9.4, Python 3.12 is available in the default package manager.
### 1. Setting Up the Python Environment
I created this tutorial on RHEL 9.4 using Python 3.12. Below are the steps I followed to set up the Python environment on RHEL 9.4.

**Installing Python 3.12**

Expand Down Expand Up @@ -209,27 +208,4 @@ PWD=your_db2_password
- `UID`: Username for Db2 authentication.
- `PWD`: Password for the Db2 user.

**Loading Variables in Python:**

To utilize these variables in your Python code, ensure you have the `python-dotenv` library installed:

```bash
pip install python-dotenv
```


Then, in your Python script or notebook, load the variables as follows:

```python
import os
from dotenv import load_dotenv

load_dotenv()

watsonx_project = os.getenv('WATSONX_PROJECT')
watsonx_apikey = os.getenv('WATSONX_APIKEY')
db2_database = os.getenv('DATABASE')
db2_hostname = os.getenv('HOSTNAME')
db2_port = os.getenv('PORT')
db2_protocol = os.getenv('PROTOCOL')
db2_uid
Now, open the notebook ['rag-basic.ipynb'](rag-basic.ipynb) and run it.