Helicone
Helicone is a powerful observability platform that provides valuable insights into your LLM usage. Check out Helicone - Pricing for more information about their product and pricing.
To enable Helicone observability in RAGChat, you simply need to pass your Helicone API key when initializing your model. Here’s how to do it for both custom models and OpenAI:
Install RAG Chat SDK
Initialize the project and install the required packages:
npm init es6
npm install dotenv
npm install @upstash/rag-chat
Setup Upstash Redis
Create a Redis database using Upstash Console or Upstash CLI and copy the UPSTASH_REDIS_REST_URL
and UPSTASH_REDIS_REST_TOKEN
into your .env
file.
UPSTASH_REDIS_REST_URL=<YOUR_URL>
UPSTASH_REDIS_REST_TOKEN=<YOUR_TOKEN>
Setup Upstash Vector
Create a Vector index using Upstash Console or Upstash CLI and copy the UPSTASH_VECTOR_REST_URL
and UPSTASH_VECTOR_REST_TOKEN
into your .env
file.
UPSTASH_VECTOR_REST_URL=<YOUR_URL>
UPSTASH_VECTOR_REST_TOKEN=<YOUR_TOKEN>
Setup QStash LLM
Navigate to QStash Console and copy the QSTASH_TOKEN
into your .env
file.
QSTASH_TOKEN=<YOUR_TOKEN>
Setup Helicone
Create a Helicone account and get an API key from Helicone -> Settings -> API Keys. Set your Helicone API key as an environment variable:
HELICONE_API_KEY=<YOUR_API_KEY>
Setup the Project
Initialize RAGChat with Helicone analytics:
import { RAGChat, upstash } from "@upstash/rag-chat";
import "dotenv/config";
const ragChat = new RAGChat({
model: upstash("meta-llama/Meta-Llama-3-8B-Instruct", {
apiKey: process.env.QSTASH_TOKEN,
analytics: { name: "helicone", token: process.env.HELICONE_API_KEY! },
}),
});
Add context to the RAG Chat:
await ragChat.context.add("The speed of light is approximately 299,792,458 meters per second.");
Chat with the RAG Chat:
const response = await ragChat.chat("What is the speed of light?");
console.log(response);
Run
Run the project:
npx tsx index.ts
Go to the Helicone Dashboard to view your analytics.
Was this page helpful?