Documentation
¶
Overview ¶
Package mock provides in-memory, network-free test doubles for the stores.Embedder and stores.VectorStore interfaces.
Both doubles record call counts so tests can assert negative facts such as "the RAG stage never ran retrieval when NeedsRetrieval was false". Both are safe for concurrent use.
Index ¶
Constants ¶
const DefaultDim = 64
DefaultDim is the vector dimensionality used by Embedder when none is given.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Embedder ¶
type Embedder struct {
// Dim is the vector dimensionality. Zero means DefaultDim.
Dim int
// Err, if set, is returned from every Embed call (fail-open testing).
Err error
// EmbedFunc, if set, overrides the default hashing behaviour entirely.
EmbedFunc func(ctx context.Context, text string) ([]float32, error)
// contains filtered or unexported fields
}
Embedder is a deterministic, offline stores.Embedder. It hashes the input text into a fixed-dimension unit vector: the same text always yields the same vector, and similar texts (sharing words) yield vectors with higher cosine similarity. It performs no I/O.
func NewEmbedder ¶
NewEmbedder returns an Embedder with the given dimensionality. dim <= 0 uses DefaultDim.
func NewFailingEmbedder ¶
NewFailingEmbedder returns an Embedder whose Embed always fails with err.
type Store ¶
type Store struct {
// Err, if set, is returned from every Search call (fail-open testing).
Err error
// SearchFunc, if set, overrides the default scan entirely.
SearchFunc func(ctx context.Context, vec []float32, topK int) ([]pipeline.Chunk, error)
// contains filtered or unexported fields
}
Store is an in-memory stores.VectorStore doing a linear-scan cosine similarity search. It is safe for concurrent use.
func NewFailingStore ¶
NewFailingStore returns a Store whose Search always fails with err.
func (*Store) Add ¶
Add indexes a chunk under the vector produced by embedding its content with Vector at dimensionality dim. It is the convenient way to seed a Store that will be queried through this package's Embedder.
func (*Store) AddDocuments ¶
AddDocuments indexes pre-vectorized documents.