This Node.js project contains scripts you can run or refer to as starter code for your chatbot application.
- A terminal and code editor to run your Node.js project.
- npm and Node.js installed. https://docs.npmjs.com/downloading-and-installing-node-js-and-npm
- Log in or create a free Atlas account. https://account.mongodb.com/account/register?tck=docs_atlas
- If you don't have an Atlas cluster, create a free M0 cluster. https://cloud.mongodb.com/go?l=https%3A%2F%2Fcloud.mongodb.com%2Fv2%2F%3Cproject%3E%23clusters%2Fedit%3Ffrom%3DctaClusterHeader
- Get your MongoDB Atlas connection string by clicking the “Connect” button on your cluster in the Atlas UI. https://www.mongodb.com/docs/manual/reference/connection-string/#find-your-mongodb-atlas-connection-string
- A Voyage AI API key. https://docs.voyageai.com/docs/api-key-and-installation
- An Anthropic API key. https://docs.anthropic.com/en/api/admin-api/apikeys/get-api-key
Note: You may use alternate embeddings and LLM service providers given that you can implement them yourself in this starter code.
Create a copy of the repository on your machine.
Run the following npm command
npm install
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
node --env-file=.env ingest-data.js
Run the following command to create the vector index in Atlas.
node --env-file=.env build-vector-index.js
a. Open generate-response.js
and replace values for QUESTION
, NUM_CANDIDATES
, EXACT
, LIMIT
as required.
node --env-file=.env generate-response.js