RAG PipelineAI Workflow
Plug-and-play Retrieval-Augmented Generation: embed text chunks in-memory, search by semantic similarity, and generate a context-aware response with an LLM.
Prerequisites
Environment variables
OPENAI_KEYInstall
npx radzor@latest recipe add rag-pipelineAI Prompt
“Run `npx radzor@latest add embeddings-store llm-completion` to install 2 Radzor components. Then read components/radzor/embeddings-store/radzor.manifest.json, components/radzor/llm-completion/radzor.manifest.json and each component's llm/integration.md. Wire them together to plug-and-play Retrieval-Augmented Generation: embed text chunks in-memory, search by semantic similarity, and generate a context-aware response with an LLM. Use the manifest's inputs (check envVar for required environment variables), outputs (check fields for object shapes), composability (check mapField for field extraction), and actions — don't invent custom interfaces.”
Paste this into Claude Code, Cursor, Windsurf, or any AI coding agent.
Pipeline
EmbeddingsStore
Embeds and indexes text chunks
LLMCompletion
Generates a context-aware answer
Scaffolded Code
// npx radzor@latest add embeddings-store llm-completion
import { EmbeddingsStore } from "./components/radzor/embeddings-store"
import { LLMCompletion } from "./components/radzor/llm-completion"
const store = new EmbeddingsStore({
provider: "openai",
apiKey: process.env.OPENAI_KEY!,
model: "text-embedding-3-small",
})
const llm = new LLMCompletion({
provider: "openai",
apiKey: process.env.OPENAI_KEY!,
model: "gpt-4o",
maxTokens: 1024,
})
// --- 1. Ingestion: split your docs into chunks and add them ---
const chunks = [
"Radzor components are installed with npx radzor@latest add.",
"Each component has a radzor.manifest.json describing its API.",
"Components can be wired together using their inputs and outputs.",
]
for (const [i, text] of chunks.entries()) {
await store.add(`chunk-${i}`, text)
}
// --- 2. Query: search for relevant chunks, then ask the LLM ---
const userQuery = "How do I install a component?"
const results = await store.search(userQuery, 3)
const context = results.map((r) => r.text).join("\n")
const { content } = await llm.complete(
`Answer based on the following context only.\n\nContext:\n${context}\n\nQuestion: ${userQuery}`
)
console.log(content)Components used
LLM tip
Pass all 2 radzor.manifest.json files to your agent at once. It will read the outputs of each step and match them against the inputs of the next — wiring the full pipeline without any extra instructions.