This repo serves to help you get started with the EmbedJS library (@llm-tools/embedjs
) for implementing RAG in your own Node.js applications.
In particular, this example shows how to use multiple web URLs as the context for the RAG model.
The script follows this flow, which you can see in main()
:
- Initializes the RAG model (
getRagApplication()
) - Loads the content of multiple URLs (
loadResources()
) - Takes a prompt from the command line (
getPrompt()
) - Prompts the RAG model with the prompt and the loaded resources (
promptRag()
) - Prints the response from the RAG model (
printRagOutput()
)
- Node.js 20+
- npm 10+
- An OpenAI API key
Install the repo and its dependencies like this:
git clone REPO_URL
cd REPO_NAME
npm install
Create a new file called .env
:
touch .env
In your new .env
file, add a variable for your OpenAI API key and add your key:
OPENAI_API_KEY=your_key_here
You can run the script with or without prompt as a command line argument:
npm start # No prompt (the script has a default)
npm start "What exercise meetups are happening in Berlin?"
The output will print in your terminal.