go-rag/embedder.go
Claude a49761b1ba
feat: extract Embedder and VectorStore interfaces, add mock-based tests
Phase 2 test infrastructure: extract interfaces to decouple business
logic from external services, enabling fast CI tests without live
Qdrant or Ollama.

- Add Embedder interface (embedder.go) satisfied by OllamaClient
- Add VectorStore interface (vectorstore.go) satisfied by QdrantClient
- Update Ingest, IngestFile, Query to accept interfaces
- Add QueryWith, QueryContextWith, IngestDirWith, IngestFileWith helpers
- Add mockEmbedder and mockVectorStore in mock_test.go
- Add 69 new mock-based tests (ingest: 23, query: 12, helpers: 16)
- Coverage: 38.8% -> 69.0% (135 leaf-level tests total)

Co-Authored-By: Charon <developers@lethean.io>
2026-02-20 00:15:54 +00:00

17 lines
556 B
Go

package rag
import "context"
// Embedder defines the interface for generating text embeddings.
// OllamaClient satisfies this interface.
type Embedder interface {
// Embed generates an embedding vector for the given text.
Embed(ctx context.Context, text string) ([]float32, error)
// EmbedBatch generates embedding vectors for multiple texts.
EmbedBatch(ctx context.Context, texts []string) ([][]float32, error)
// EmbedDimension returns the dimensionality of the embedding vectors
// produced by the configured model.
EmbedDimension() uint64
}