@abhinav1201/rag-ai-accelerator
v0.1.2
Published
A plug-and-play AI accelerator for RAG chat experiences — generic vector DB + LLM provider, embeddable or standalone.
Maintainers
Readme
@abhinav1201/rag-ai-accelerator
A plug-and-play AI accelerator for RAG chat experiences that can be embedded into Next.js apps or used as a standalone demo app. Bring your own vector database, LLM, embeddings, and UI branding.
✨ Features
| Category | Options |
|---|---|
| Vector DBs | Pinecone, pgVector (PostgreSQL), MongoDB Atlas, ChromaDB, Qdrant, universal REST adapters |
| LLM Providers | OpenAI, Anthropic Claude, Google Gemini, Ollama, LiteLLM, universal REST adapters |
| Document Ingestion | Universal support for PDF, DOCX, CSV, JSON, MD, TXT |
| UI | Full-page ChatWindow + floating ChatWidget, fully branded & responsive |
| RAG | Configurable chunk size/overlap, top-K retrieval, score threshold, namespaced multi-tenancy |
🚀 How it Works
The AI Accelerator acts as a universal bridge between your data and your users. It normalizes different AI providers and Vector databases into a single interface.
- Ingest: Upload or send documents to the
/api/uploadendpoint. They are automatically parsed, chunked, and embedded. - Retrieve: When a user asks a question, the system converts it to a vector and searches your configured database.
- Generate: The retrieved context is combined with the user query and sent to your configured LLM (OpenAI, Claude, etc.) to generate a grounded response.
📦 How to Install
To integrate the AI Accelerator into your existing Next.js project, simply run:
npm install @abhinav1201/rag-ai-acceleratorAlternatively, if you want to run the standalone demo application:
git clone https://github.com/abhinav1201/ai-accelerator
cd ai-accelerator
npm install
cp .env.example .env.local
# Fill in your API keys in .env.local
npm run devNPM Package Usage
1. Embed the ChatWidget
Wrap your application in the ConfigProvider and add the ChatWidget.
import { ConfigProvider, ChatWidget } from '@abhinav1201/rag-ai-accelerator';
export default function Layout({ children }) {
return (
<ConfigProvider
config={{
projectId: 'my-project',
ui: {
title: 'Support Bot',
primaryColor: '#6366f1',
accentColor: '#8b5cf6',
welcomeMessage: 'Hi! How can I help you today?',
},
}}
>
{children}
<ChatWidget position="bottom-right" />
</ConfigProvider>
);
}2. Mount the API routes
Create standard Next.js route handlers and plug in the library's factories.
// src/app/api/chat/route.ts
import { createChatHandler, getRagConfig } from '@abhinav1201/rag-ai-accelerator/server';
export const POST = createChatHandler(getRagConfig());
// src/app/api/upload/route.ts (Handles PDF, DOCX, etc.)
import { createUploadHandler, getRagConfig } from '@abhinav1201/rag-ai-accelerator/server';
export const POST = createUploadHandler(getRagConfig());3. Use RAGPipeline programmatically
import { RAGPipeline } from '@abhinav1201/rag-ai-accelerator/server';
const pipeline = new RAGPipeline(config);
await pipeline.ingest([{ docId: 'readme', content: 'Your document text here' }]);
const { reply, sources } = await pipeline.ask('What is the refund policy?');Configuration Reference
The library is entirely dynamic. You can switch between providers simply by updating your environment variables.
| Variable | Description |
|---|---|
| RAG_PROJECT_ID | Project namespace for data isolation |
| VECTOR_DB_PROVIDER | pinecone, pgvector, mongodb, or universal_rest |
| VECTOR_UNIVERSAL_PROFILE | pinecone-rest, mongodb-atlas, chromadb, qdrant |
| LLM_PROVIDER | openai, anthropic, ollama, or universal_rest |
| LLM_UNIVERSAL_PROFILE | openai-compatible, litellm, anthropic-claude, google-gemini |
| EMBEDDING_PROVIDER | openai, ollama, or rest |
Architecture
User Query
|
v
[embed query] <-- EmbeddingProvider (OpenAI / Ollama / Custom)
|
v
[vector search] <-- IVectorDB (Pinecone / pgVector / MongoDB / Chroma / REST)
|
v
[build context]
|
v
[LLM chat] <-- ILLMProvider (OpenAI / Anthropic / Gemini / LiteLLM)
|
v
ChatResponse { reply, sources[] }License
MIT - GSPANN Technologies
