npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@badriana/ai-core

v0.2.1

Published

AI Engineering Framework — a Prisma-style client for document ingestion, parsing, chunking, embedding, vector query, RAG context building, vision/OCR, and chat completion & streaming across OpenAI-compatible providers

Readme

@badriana/ai-core

npm version license bundle size typescript

Universal AI Engineering Framework & Prisma-style Client untuk Seluruh Node.js (Express.js, NestJS, Fastify, Hono, Next.js).
Solusi All-in-One untuk Ingesti Dokumen RAG (PDF/TXT/MD), Vision OCR, Batch Vector Embedding, RRF Query Search, serta Chat Completion & Streaming across OpenRouter, OpenAI, dan Gemini.


💡 Apa Itu @badriana/ai-core?

@badriana/ai-core dirancang untuk menyederhanakan pengembangan aplikasi berbasis AI dan RAG (Retrieval-Augmented Generation). Dengan antarmuka yang bersih ala Prisma Client (createAI()), Anda tidak perlu lagi menulis kode berulang (boilerplate) untuk HTTP requests, parsing PDF, ekstraksi gambar, chunking teks, pencarian vektor, atau penanganan token usage.


🛠️ Fitur Utama Framework

  1. Client Unified createAI(): Satu antarmuka terpusat untuk mengelola ai.chat, ai.embedding, ai.image, ai.audio, ai.context, dan ai.document.
  2. Ingesti Dokumen Multimodal (createDocument): Mendukung file PDF, Markdown, TXT, dan Base64. Mengekstrak teks, tabel, rumus, dan gambar via Vision OCR secara otomatis.
  3. Indikator Progres Real-Time (onProgress): Mengirimkan persentase progres (0%100%) dan status tahapan (parsing, chunking, processing_images, embedding, completed) untuk Progress Bar UI.
  4. Chat Completion & Streaming (ai.chat.generate & ai.chat.stream): Mendukung generasi jawaban tunggal maupun streaming, lengkap dengan konteks RAG, sitasi otomatis (citations), dan respons mentah provider (raw payload).
  5. Batch Vector Embedding (ai.embedding.create): Generasi vektor otomatis dengan deteksi dimensi, batasan batching, serta metrik biaya/token usage.
  6. Query & Reranker Engine (createQuery): Mesin kueri pencarian vektor semantik dengan pembangun konteks otomatis.

📦 Instalasi

npm install @badriana/ai-core

🚀 Quick Start (Contoh Penggunaan Singkat)

1. Inisialisasi AI Client

import { createAI } from '@badriana/ai-core';

const ai = createAI({
  provider: 'openrouter',
  apiKey: process.env.OPENROUTER_API_KEY,
  chatModel: 'google/gemma-2-9b-it:free',
  embeddingModel: 'openai/text-embedding-3-small',
});

2. Tanya Jawab AI (ai.chat.generate)

const result = await ai.chat.generate({
  question: 'Jelaskan apa itu Kurikulum Merdeka secara singkat!',
  system: 'Kamu adalah Guru AI yang ramah dan profesional.',
});

console.log(result.text);       // Jawaban teks AI
console.log(result.usage);      // { inputTokens: 45, outputTokens: 120, totalTokens: 165 }
console.log(result.raw);        // Raw JSON response dari OpenRouter/OpenAI

3. Ingesti Dokumen RAG & Progress Bar (createDocument)

import { createDocument } from '@badriana/ai-core';

const docResult = await createDocument({
  source: pdfBuffer,
  filename: 'Modul_Fisika.pdf',
  // 1. Embedder callback
  embedder: async (texts) => {
    const res = await ai.embedding.create({ input: texts });
    return "embeddings" in res ? res.embeddings : [res.embedding];
  },
  // 2. Real-time Progress callback (0% - 100%)
  onProgress: (progress) => {
    console.log(`[${progress.stage.toUpperCase()}] ${progress.percentage}% - ${progress.message}`);
  },
});

console.log(docResult.chunks); // Array Knowledge Chunks (Text, Image, Table)
console.log(docResult.stats);  // Metrik waktu & statistik dokumen

🎓 Tutorial Lengkap & Arsitektur Framework

Ingin membangun aplikasi AI RAG & Multimodal dari nol menggunakan @badriana/ai-core pada framework favorit Anda?
Kami telah menyediakan panduan tutorial langkah demi langkah dari nol tanpa ada yang terlewat:

👉 Baca Tutorial Next.js Lengkap (TUTORIAL.md)

📚 Contoh Arsitektur Backend Framework (Router ➔ Controller ➔ Service ➔ Repository):

  1. 🚀 Express.js: express.example.md
  2. 🦁 NestJS: nestjs.example.md
  3. ⚛️ Next.js App Router: nextjs.example.md
  4. ⚡ Fastify: fastify.example.md
  5. 🌿 Koa.js: koa.example.md

🎨 Contoh Integrasi Frontend React/Next.js UI:


📄 Lisensi

MIT © badriana