Skip to content

mongodb-developer/atlas-search-playground-chatbot-starter

Repository files navigation

atlas-search-playground-chatbot-starter

This Node.js project contains scripts you can run or refer to as starter code for your chatbot application.

Prerequisites

Note: You may use alternate embeddings and LLM service providers given that you can implement them yourself in this starter code.

Procedure

1. Clone the repo

Create a copy of the repository on your machine.

2. Set up the environment

a. Install dependencies.

Run the following npm command

npm install

b. Update the values in the .env file.

Fill in the API keys for Voyage AI and Anthropic.

Your connection string should use the following format:

mongodb+srv://<db_username>:<db_password>@<clusterName>.<hostname>.mongodb.net

3. Create the database and collection and populate it with the data from your PDF

a. Copy your PDF into the directory.

b. Open ingest-data.js and replace values for PDF_FILE, CHUNK_SIZE, CHUNK_OVERLAP as required.

c. Run the following command.

node --env-file=.env ingest-data.js

4. Create the vector index

Run the following command to create the vector index in Atlas.

node --env-file=.env build-vector-index.js

5. Ask a question, retrieve vector search results, and get a response from the chatbot

a. Open generate-response.js and replace values for QUESTION, NUM_CANDIDATES, EXACT, LIMIT as required.

b. Run the following command.

node --env-file=.env generate-response.js

c. Repeat the current step if you want to ask a new question or change search query parameters.

d. Repeat step 3 if you want to change the data or data settings for the chatbot to answer from.

e. Uncomment line 17 to display the documents retrieved from running vector search.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published