Documentation
¶
Overview ¶
Example: rag_knowledge — Retrieval-Augmented Generation with the Knowledge API.
What you'll learn:
- How to build a RAG pipeline with knowledge.VectorKnowledge
- How the Knowledge / VectorStore / EmbeddingsProvider interfaces fit together
- How to ingest documents, embed them, and run a similarity search
- How retrieved passages ground an LLM answer (optional, needs a provider)
This example is fully OFFLINE by default. It ships a self-contained in-memory VectorStore (cosine similarity) and a deterministic, hashing EmbeddingsProvider, so retrieval runs with NO API key and NO network. If an LLM provider is configured in the environment (OPENAI_API_KEY, etc.) the example additionally feeds the retrieved passages to that model to produce a grounded answer.
Prerequisites:
- Go 1.22+
- (optional) an LLM API key for the grounded-answer step
Run:
go run ./examples/rag_knowledge/ # retrieval only, offline OPENAI_API_KEY=sk-... go run ./examples/rag_knowledge/ # + grounded answer
Click to show internal directories.
Click to hide internal directories.