RAG Q&A endpoint
Build a minimal retrieval-augmented Q&A flow with @pondoknusa/rag and @pondoknusa/vector.
Scaffold
bash
pondoknusa new knowledge-base --ai
npm install
pondoknusa vector:installThe --ai flag adds vector config, embed jobs, models, and example routes.
Ingest documents
Prefer inline content on HTTP endpoints. For filesystem ingest from trusted jobs/CLI, pass rootDir so paths cannot escape the ingest root:
typescript
import { ingestDocument, ingestFile } from '@pondoknusa/rag';
import { Document } from './models/Document.js';
await ingestDocument(Document, {
source: 'handbook',
content: '# Handbook\n...',
});
await ingestFile(Document, 'handbook.pdf', {
source: 'handbook',
rootDir: 'storage/documents',
chunkSize: 800,
});Embed chunks:
bash
pondoknusa vector:embedAsk endpoint
typescript
import { Route } from '@pondoknusa/core';
import { Response } from '@pondoknusa/http';
import { retrieveAndAnswer } from '@pondoknusa/rag';
Route.post('/api/ask', async (request) => {
const { question } = await request.json();
const answer = await retrieveAndAnswer(question, { topK: 5 });
return Response.json(answer);
});Use your preferred LLM SDK in the app layer — Pondoknusa handles storage, retrieval, and prompt templates.
Example app
See examples/rag for ingest → embed → ask → stream with GraphQL read API.