Skip to content

AzureCosmosDB/langchainjs-cosmosdb-rag-quickstart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LangChain.js + Azure Cosmos DB RAG Quickstart

Get started with Retrieval-Augmented Generation (RAG) and vector search using LangChain.js and Azure Cosmos DB.

What this sample demonstrates

  1. Document ingestion — Load text, split into chunks, and store vector embeddings in Azure Cosmos DB
  2. Semantic similarity search — Find relevant documents using vector similarity
  3. Score-threshold search — Filter results by similarity score
  4. MMR (Maximal Marginal Relevance) — Retrieve diverse, non-redundant results
  5. RAG chain — Answer questions using retrieved context with Azure OpenAI GPT-4.1

Prerequisites

  • Node.js v18 or later
  • An Azure Cosmos DB account with NoSQL API
  • An Azure OpenAI deployment with:
    • A chat model (e.g., gpt-4.1)
    • An embedding model (e.g., text-embedding-3-small)

Getting started

  1. Clone the repo

    git clone https://github.com/AzureCosmosDB/langchainjs-cosmosdb-rag-quickstart.git
    cd langchainjs-cosmosdb-rag-quickstart
  2. Install dependencies

    npm install
  3. Configure environment variables

    cp .env.example .env

    Edit .env and fill in your Azure credentials.

  4. Run the sample

    npm start

Project structure

File Description
get-started.js Main application — ingestion, search, and RAG
sample-data.txt Sample document about Azure Cosmos DB
.env.example Template for required environment variables

Resources

About

Get started with RAG and vector search using LangChain.js and Azure Cosmos DB

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors