Skip to content

RAG Pipeline

Scaffolds a Retrieval-Augmented Generation pipeline in TypeScript. Implements document ingestion, configurable chunking strategies, embedding generation, vector storage, similarity retrieval, and LLM-powered answer generation with source citations. No LangChain — every component is built from first principles: a model call goes to the ModelGateway over fetch, or to Bedrock through the AWS SDK, and each vector store is reached through its own client. Defaults to the Platform's ModelGateway for generation (Claude over native Messages, prompt-cached) and embeddings, so the pipeline holds no model credential. Supports multiple vector stores (pgvector, Chroma, Qdrant, Pinecone), and Bedrock called directly under the AWS credential chain off the substrate. No provider holds a provider key.

Namerag-pipeline
Version0.1.0
Categoryai-systems
LicenseApache-2.0
Personaengineering
Tagstypescript, rag, embeddings, vector-search, llm, retrieval, ai, model-gateway, bedrock
Sourcetemplates/rag-pipeline

Render it

Three front doors, one catalog. Pick whichever suits the caller.

# CLI
npx @nanohype/sdk render rag-pipeline --out ./my-app

# SDK
import { LocalSource, renderTemplate } from "@nanohype/sdk";
const result = await renderTemplate(source, "rag-pipeline", variables);

# MCP — from an agent
get_template({ name: "rag-pipeline" })

Prerequisites

ToolVersionWhy
node>=26Node.js runtime for TypeScript execution

Variables

Required

ProjectName string
Kebab-case project name, used in package.json and directory names Must be lowercase kebab-case starting with a letter.

Optional

Description string — defaults to A retrieval-augmented generation pipeline
Short project description for package.json and README
VectorStore string — defaults to chroma
Vector database backend for storing and querying embeddings (e.g. chroma, pgvector, qdrant, pinecone)
EmbeddingProvider string — defaults to gateway
Provider for text embeddings: gateway (the Platform ModelGateway, which holds the Bedrock role on the nanohype substrate), bedrock (Titan v2, called directly under the AWS credential chain, off the substrate), or a custom name
LlmProvider string — defaults to gateway
LLM provider for answer generation: gateway (the Platform ModelGateway, which holds the Bedrock role on the nanohype substrate), bedrock (called directly under the AWS credential chain, off the substrate), or a custom name
PlatformName string — defaults to ${ProjectName}
Name of the Platform CR this project deploys under. The gateway providers default MODEL_GATEWAY_ENDPOINT to the Service the eks-agent-platform operator creates for it, <PlatformName>-gateway in namespace tenants-<PlatformName>
ChunkStrategy string — defaults to recursive
Text chunking strategy for splitting documents
IncludeTests bool — defaults to true
Include the vitest config and the chunking, retrieval and registry suites, with the gateway and bedrock request suites

What it produces

54 files. Placeholder names such as __APP_NAME__ are what the renderer substitutes into.

.dockerignore
.env.example
.github/workflows/ci.yml
.gitignore
biome.json
Dockerfile
package.json
README.md
src/__tests__/chunking.test.ts
src/__tests__/eval-assertions.test.ts
src/__tests__/eval-cases.test.ts
src/__tests__/pipeline.integration.test.ts
src/__tests__/registry.test.ts
src/__tests__/retrieval.test.ts
src/bootstrap.ts
src/chunking.ts
src/config.ts
src/eval/assertions.ts
src/eval/cases.ts
src/eval/cases/answers-from-the-retrieved-passage.json
src/eval/cases/ignores-instructions-inside-a-retrieved-passage.json
src/eval/cases/keeps-its-instructions-under-a-user-demand.json
src/eval/cases/refuses-to-answer-past-the-corpus.json
src/eval/cases/synthesises-across-two-sources.json
src/eval/cases/withholds-the-prompt-and-the-fence.json
src/eval/docs/incident-response.md
src/eval/docs/retention-policy.md
src/eval/docs/support-macros.md
src/eval/runner.ts
src/generation.ts
src/index.ts
src/ingest.ts
src/logger.ts
src/providers/__tests__/bedrock-request.test.ts
src/providers/__tests__/chroma.integration.test.ts
src/providers/__tests__/gateway-request.test.ts
src/providers/bedrock.ts
src/providers/chroma.ts
src/providers/gateway.ts
src/providers/index.ts
src/providers/mock-vectorstore.ts
src/providers/mock.ts
src/providers/pgvector.ts
src/providers/pinecone.ts
src/providers/qdrant.ts
src/providers/registry.ts
src/providers/types.ts
src/resilience/__tests__/circuit-breaker.test.ts
src/resilience/__tests__/request-timeout.test.ts
src/resilience/circuit-breaker.ts
src/resilience/request-timeout.ts
src/retrieval.ts
tsconfig.json
vitest.config.ts

Composes with

Composites that use it

  • AI Web Application — Full-stack web application with Next.js frontend, RAG pipeline, authentication, database, and a Platform tenant chart whose ModelGateway is the app's model path..
  • Document Intelligence — Document search and question-answering system with RAG pipeline, HTTP service, file storage, database, and a Platform tenant chart whose ModelGateway serves the pipeline's generation and embeddings routes..
  • Enterprise AI Infrastructure — Full enterprise AI stack with agents, tool servers, safety guardrails, evaluation, prompt management, observability, and a Platform tenant chart whose ModelGateway is the stack's model path..
  • RAG-Powered Agent — AI agent that uses retrieval-augmented generation as a tool.