go-rag/vectorstore.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

24 lines
1 KiB
Go

package rag
import "context"
// VectorStore defines the interface for vector storage and search.
// QdrantClient satisfies this interface.
type VectorStore interface {
// CreateCollection creates a new vector collection with the given
// name and vector dimensionality.
CreateCollection(ctx context.Context, name string, vectorSize uint64) error
// CollectionExists checks whether a collection with the given name exists.
CollectionExists(ctx context.Context, name string) (bool, error)
// DeleteCollection deletes the collection with the given name.
DeleteCollection(ctx context.Context, name string) error
// UpsertPoints inserts or updates points in the named collection.
UpsertPoints(ctx context.Context, collection string, points []Point) error
// Search performs a vector similarity search, returning up to limit results.
// An optional filter map restricts results by payload field values.
Search(ctx context.Context, collection string, vector []float32, limit uint64, filter map[string]string) ([]SearchResult, error)
}