Skip to content

RAG Application with LangChain, Terraform, AWS Opensearch and AWS Bedrock

Notifications You must be signed in to change notification settings

benitomartin/aws-bedrock-opensearch-langchain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RAG Application with LangChain, AWS Opensearch and AWS Bedrock

cover_gke_medium

This repository contains a full RAG application using Terraform as IaC, LangChain as framework, AWS Bedrock as LLM and Embedding Models, AWS OpenSearch as a vector database, and deployment on AWS OpenSearch endpoint.

Main Steps

  • Data Ingestion: Load data to an Opensearch Index
  • Embedding and Model: Bedrock Titan
  • Vector Store and Endpoint: Opensearch
  • IaC: Terraform
  • data: original pdf document and generated json file with embeddings

Feel free to ⭐ and clone this repo 😉

Tech Stack

Visual Studio Code Python Anaconda Linux Ubuntu Git AWS

Project Structure

The project has been structured with the following files:

  • terraform: IaC
  • tests: unittest and mock tests
  • src: scripts with the app logic
  • requirements.txt: project requirements
  • Makefile: command for testing, linting and formating
  • pyproject.toml: linting/formatting requirements

Project Set Up

The Python version used for this project is Python 3.11.

  1. Clone the repo (or download it as a zip file):

    git clone https://github.com/benitomartin/aws-bedrock-opensearch-langchain.git
  2. Create the virtual environment named main-env using Conda with Python version 3.10:

    conda create -n main-env python=3.11
    conda activate main-env
  3. Install the requirements.txt:

    pip install -r requirements.txt
    
    or
    
    make req
  4. Create infrastructure from the terraform folder. This can take up to 30 minutes

    conda install conda-forge::terraform
    terraform init
    terraform plan
    terraform apply
  5. Generate embeddings from documents:

    python src/generate_embeddings.py
  6. Create Index:

    python src/create_index.py
  7. Ingest documents into index:

    python src/ingest_docs_with_embeddings.py
  8. Test the app to get a reply:

    python src/app.py

The app contains a question. You can change it accordingly to test other scenarios.