2.0.3 • Published 3 months ago

@upstash/rag-chat v2.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

Upstash RAG Chat SDK · license npm (scoped) npm weekly download

The @upstash/rag-chat package makes it easy to develop powerful retrieval-augmented generation (RAG) chat applications with minimal setup and configuration.

Features:

  • Next.js compatibility with streaming support
  • Ingest entire websites, PDFs and more out of the box
  • Built-in Vector store for your knowledge base
  • (Optional) built-in Redis compatibility for fast chat history management
  • (Optional) built-in rate limiting
  • (Optional) disableRag option to use it as LLM + chat history
  • (Optional) Analytics via Helicone, Langsmith and Cloudflare AI Gateway

Getting started

Installation

Install the package using your preferred package manager:

pnpm add @upstash/rag-chat

bun add @upstash/rag-chat

npm i @upstash/rag-chat

Quick start

  1. Set up your environment variables:
UPSTASH_VECTOR_REST_URL="XXXXX"
UPSTASH_VECTOR_REST_TOKEN="XXXXX"


# if you use OpenAI compatible models
OPENAI_API_KEY="XXXXX"

# or if you use Upstash hosted models
QSTASH_TOKEN="XXXXX"

# Optional: For Redis-based chat history (default is in-memory)
UPSTASH_REDIS_REST_URL="XXXXX"
UPSTASH_REDIS_REST_TOKEN="XXXXX"
  1. Initialize and use RAGChat:
import { RAGChat } from "@upstash/rag-chat";

const ragChat = new RAGChat();

const response = await ragChat.chat("Tell me about machine learning");
console.log(response);

Basic Usage

import { RAGChat, openai } from "@upstash/rag-chat";

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?");

console.log(response.output);

Docs

Checkout the documentation for integrations and advanced options.

2.0.3

7 months ago

2.0.2

8 months ago

2.0.1-canary-2

8 months ago

2.0.1

8 months ago

2.0.1-canary

8 months ago

2.0.0

9 months ago

1.7.0-canary

9 months ago

1.6.5-canary-3

9 months ago

1.6.5-canary-2

9 months ago

1.6.5-canary-5

9 months ago

1.6.5-canary-4

9 months ago

1.6.5-canary-6

9 months ago

1.6.4

9 months ago

1.6.1

9 months ago

1.6.0

10 months ago

1.4.0

10 months ago

1.6.2-canary

9 months ago

1.6.5-canary

9 months ago

1.6.3-canary

9 months ago

1.5.0

10 months ago

1.6.1-canary

9 months ago

1.5.0-canary

10 months ago

1.3.2

10 months ago

1.3.1

10 months ago

1.2.1

11 months ago

1.3.0

10 months ago

1.0.7

11 months ago

1.1.1

11 months ago

1.1.0

11 months ago

1.0.6

11 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.5-canary

11 months ago

1.0.4-canary-2

11 months ago

1.0.4-canary-3

11 months ago

1.0.4-canary

11 months ago

1.0.4-canary-1

11 months ago

1.0.3

11 months ago

1.0.2

12 months ago

1.0.1

12 months ago

1.0.0

12 months ago

0.0.40-alpha

12 months ago

0.0.38-alpha

12 months ago

0.0.39-alpha

12 months ago

0.0.36-alpha

12 months ago

0.0.4-3.alpha

12 months ago

0.0.37-alpha

12 months ago

0.0.5-1.alpha

12 months ago

0.0.41-alpha

12 months ago

0.0.5-0.alpha

12 months ago

0.0.4-2.alpha

12 months ago

0.0.35-alpha

1 year ago

0.0.30-alpha

1 year ago

0.0.32-alpha

1 year ago

0.0.28-alpha

1 year ago

0.0.27-alpha

1 year ago

0.0.33-alpha

1 year ago

0.0.25-alpha

1 year ago

0.0.29-alpha

1 year ago

0.0.31-alpha

1 year ago

0.0.26-alpha

1 year ago

0.0.24-alpha

1 year ago

0.0.34-alpha

1 year ago

0.0.23-alpha

1 year ago

0.0.22-alpha

1 year ago

0.0.21-alpha

1 year ago

0.0.15-alpha

1 year ago

0.0.19-alpha

1 year ago

0.0.20-alpha

1 year ago

0.0.18-alpha

1 year ago

0.0.17-alpha

1 year ago

0.0.16-alpha

1 year ago

0.0.11-alpha

1 year ago

0.0.9-alpha

1 year ago

0.0.14-alpha

1 year ago

0.0.5-alpha

1 year ago

0.0.12-alpha

1 year ago

0.0.13-alpha

1 year ago

0.0.6-alpha

1 year ago

0.0.7-alpha

1 year ago

0.0.8-alpha

1 year ago

0.0.4-alpha

1 year ago

0.0.3-alpha

1 year ago

0.0.2-alpha

1 year ago

0.0.1-alpha

1 year ago