Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mongodb-developer/google-cloud-rag-langchain

RAG Chat Assistant with MongoDB Atlas, Google Cloud and Langchain
https://github.com/mongodb-developer/google-cloud-rag-langchain

embeddings gemini google google-cloud langchain mongodb-atlas rag

Last synced: 2 months ago
JSON representation

RAG Chat Assistant with MongoDB Atlas, Google Cloud and Langchain

Awesome Lists containing this project

README

        

# RAG Chat Assistant with MongoDB Atlas, Google Cloud and Langchain

This is a demo of a chatbot assistant using retrieval augmented generation (RAG).

## Technologies

The client is built with Angular and Angular Material. The server is built with Express.js and uses MongoDB Atlas for storing the vector data. The embeddings are generated with Google Cloud embeddings model. The conversation model uses Gemini 1.0 Pro model. The app also utilizes Langchain.

## Prerequisites

1. [Node.js](https://nodejs.org/) LTS.

1. Google Cloud account with Vertex AI APIs enabled.

## Setup

Follow the steps below to set up the chat assistant for local development.

### MongoDB Atlas Vector Store Setup

1. Create a [MongoDB Atlas](https://mongodb.com/try?utm_campaign=devrel&utm_source=cross-post&utm_medium=cta&utm_content=google-cloud-rag&utm_term=stanimira.vlaeva) account and deploy a free database. Complete the quickstart guide — create a database user and allowlist your IP address.

1. Clone the repository.

```
git clone https://github.com/mongodb-developer/Google-Cloud-RAG-Langchain.git rag-chatbot
cd rag-chatbot
```

1. Create a `.env` file with the following content:

```
ATLAS_URI=
```

1. Run the embedding script to vectorize the PDF data and store it in MongoDB Atlas.

**rag-chatbot/**
```
npm run embed-documents
```

1. Go back to MongoDB Atlas and verify that the data has been stored in the `context` collection.

1. Switch to the Atlas Search tab and click `Create Search Index`. Select `JSON Editor` in the **Atlas Vector Search** section. This is the last option in the list.

1. From the left sidebar, select the `chat-rag` database and the `context` collection.

1. Add the following JSON schema:

```
{
"fields": [
{
"numDimensions": 768,
"path": "embedding",
"similarity": "euclidean",
"type": "vector"
}
]
}
```

1. Wait for the status to change to `Active`.

### Run the application

1. Start the application with the following command:

**rag-chatbot/**
```
npm start
```

1. Open a browser and navigate to `http://localhost:4200`.

1. Try asking the chatbot questions like "What is the coverage of my insurance policy?" or "What are the specifics of my car insurance?". Use the `RAG` toggle to switch between retrieval augmented generation and retrieval only.

## Contributors ✨

This demo is inspired by the [Chat Application with RAG Feature Toggle and Backend Server](https://github.com/voxic/GCP_RAG_Chatbot/tree/main).






Stanimira Vlaeva



## Disclaimer

Use at your own risk; not a supported MongoDB product