Retrieval-Augmented Generation with Qdrant and Ollama
Go 1.26 range-over-int `for i := range b.N` assigns i but it was never used, causing build failure with -tags rag. Co-Authored-By: Virgil <virgil@lethean.io> |
||
|---|---|---|
| .forgejo/workflows | ||
| cmd/rag | ||
| docs | ||
| tools/rag | ||
| .editorconfig | ||
| .golangci.yml | ||
| benchmark_gpu_test.go | ||
| benchmark_test.go | ||
| chunk.go | ||
| chunk_test.go | ||
| CLAUDE.md | ||
| collections.go | ||
| collections_test.go | ||
| CONTRIBUTING.md | ||
| embedder.go | ||
| go.mod | ||
| go.sum | ||
| helpers.go | ||
| helpers_test.go | ||
| ingest.go | ||
| ingest_test.go | ||
| integration_test.go | ||
| keyword.go | ||
| keyword_test.go | ||
| mock_test.go | ||
| ollama.go | ||
| ollama_integration_test.go | ||
| ollama_test.go | ||
| qdrant.go | ||
| qdrant_integration_test.go | ||
| qdrant_test.go | ||
| query.go | ||
| query_test.go | ||
| README.md | ||
| Taskfile.yml | ||
| vectorstore.go | ||
go-rag
Retrieval-Augmented Generation library for Go. Provides document chunking with three-level Markdown splitting and configurable overlap, embedding generation via Ollama, vector storage and cosine-similarity search via Qdrant (gRPC), keyword boosting post-filter, and result formatting in plain text, XML (for LLM prompt injection), or JSON. Designed around Embedder and VectorStore interfaces that decouple business logic from service implementations and enable mock-based testing.
Module: forge.lthn.ai/core/go-rag
Licence: EUPL-1.2
Language: Go 1.25
Quick Start
import "forge.lthn.ai/core/go-rag"
// Ingest a directory of Markdown files
err := rag.IngestDirectory(ctx, "/path/to/docs", "my-collection", false)
// Query for relevant context (suitable for LLM prompt injection)
context, err := rag.QueryDocsContext(ctx, "how does rate limiting work?", "my-collection", 5)
// Interface-accepting variants for long-lived processes
results, err := rag.QueryWith(ctx, store, embedder, "question", "collection", 5)
Documentation
- Architecture — interfaces, chunking strategy, ingestion pipeline, query pipeline, keyword boosting
- Development Guide — prerequisites, build, test tags, live vs mock tests
- Project History — completed phases and known limitations
Build & Test
go test ./... # unit + mock tests (no external services)
go test -tags rag ./... # full suite with live Qdrant + Ollama
go test -race ./...
go build ./...
Licence
European Union Public Licence 1.2 — see LICENCE for details.