From d758e97b13ad2fdbcb3acf77696056fb2a6d0557 Mon Sep 17 00:00:00 2001 From: subodh-palayekar <110848001+subodh-palayekar@users.noreply.github.com> Date: Sat, 1 Mar 2025 19:02:20 +0530 Subject: [PATCH] Update README.md To run the example provided in the README file, you will need to install both @upstash/rag-chat and @upstash/redis. modified example code wrapped in an async function for easier execution. --- README.md | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 23597e0..2284dd4 100644 --- a/README.md +++ b/README.md @@ -32,11 +32,11 @@ Features: Install the package using your preferred package manager: ```sh -pnpm add @upstash/rag-chat +pnpm add @upstash/rag-chat @upstash/redis -bun add @upstash/rag-chat +bun add @upstash/rag-chat @upstash/redis -npm i @upstash/rag-chat +npm i @upstash/rag-chat @upstash/redis ``` ### Quick Start @@ -66,8 +66,14 @@ import { RAGChat } from "@upstash/rag-chat"; const ragChat = new RAGChat(); -const response = await ragChat.chat("Tell me about machine learning"); -console.log(response); +const main = async ()=>{ + const response = await ragChat.chat("Tell me about machine learning"); + console.log(response); +} + +main() + + ``` ### Basic Usage @@ -79,18 +85,24 @@ export const ragChat = new RAGChat({ model: openai("gpt-4-turbo"), }); -await ragChat.context.add({ - type: "text", - data: "The speed of light is approximately 299,792,458 meters per second.", -}); -await ragChat.context.add({ - type: "pdf", - fileSource: "./data/physics_basics.pdf", -}); -const response = await ragChat.chat("What is the speed of light?"); +const main = async ()=>{ + + await ragChat.context.add({ + type: "text", + data: "The speed of light is approximately 299,792,458 meters per second.", + }); + + await ragChat.context.add({ + type: "pdf", + fileSource: "./data/physics_basics.pdf", + }); + const response = await ragChat.chat("What is the speed of light?"); + + console.log(response.output); +} -console.log(response.output); +main() ``` ## Docs