Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zenrag

A minimal RAG (Retrieval Augmented Generation) library for the Vercel AI SDK. Semantic search over documents with SQLite or in-memory storage.

npm

Features

  • Chunking — Configurable text chunking with overlap
  • Vector stores — SQLite (persistent) or in-memory
  • Embeddings — Uses AI SDK embed / embedMany with any compatible model
  • Retrieval — Semantic search with optional caching
  • AI SDK integrationcreateRetriever and createRagMiddleware for use with generateText / streamText

Installation

bun add zenrag @openrouter/ai-sdk-provider

Usage

import { createOpenRouter } from "@openrouter/ai-sdk-provider";
import { ZenRag } from "zenrag";

const openrouter = createOpenRouter({ apiKey: process.env.OPENROUTER_API_KEY! });
const embeddingModel = openrouter.textEmbeddingModel("openai/text-embedding-3-small");

const rag = new ZenRag({
  embeddingModel,
  filePath: "./knowledge.db",
  topK: 5,
});

await rag.addDocuments([
  "Your document content here...",
  "Another document...",
]);

const docs = await rag.retrieve("search query");

API

  • ZenRag — Main RAG class
  • SqliteStore / MemoryStore — Vector store implementations
  • createRetriever(rag) — Returns a retriever function for AI SDK
  • createRagMiddleware(rag, options) — Middleware for RAG in AI pipelines
  • chunkText, createChunker — Chunking utilities

License

MIT

About

Minimal RAG library for the Vercel AI SDK. Semantic search with SQLite or in-memory storage, chunking, and retriever middleware.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages