Skip to main content

Module embedder

Module embedder 

Source
Expand description

Pluggable text → vector embedding.

The Agent Memory SDK is bring-your-own-vector: it never generates embeddings. This crate mirrors the repo’s established pattern (the Python SDK’s Embedder protocol, the tauri-rag demo’s fastembed backend): an Embedder trait with a default on-device model and a deterministic, network-free fallback for tests and air-gapped reproducibility.

Structs§

HashEmbedder
Deterministic, network-free embedder (token-hashing into L2-normalized buckets). Not semantically strong — its purpose is reproducible tests and offline behavior, exactly like the fake_embed used in the repo’s agent_memory examples. Swap in a real model (e.g. fastembed, all-MiniLM-L6-v2, 384-dim) for production recall quality.
OllamaEmbedder
Embeds text through a local Ollama /api/embeddings endpoint — real semantic recall while the model stays on the user’s own machine.
OpenAiEmbedder
Embeds through any OpenAI-compatible /v1/embeddings endpoint — oMLX, llama.cpp’s server, LM Studio, vLLM, or a hosted provider.

Enums§

EmbedError
Failure produced by an Embedder backend (e.g. a network-backed embedder that cannot reach its model). The in-memory HashEmbedder never fails.
EmbedderSelection
What a caller must do about a named embedding backend.

Constants§

DEFAULT_OLLAMA_MODEL
Default Ollama embedding model (384-dim; ollama pull all-minilm).
DEFAULT_OLLAMA_URL
Default Ollama base URL.
HASH_EMBEDDER_NOTICE
Transport-neutral part of the startup notice adapters emit for hash. The library itself never writes to stderr; each owning binary or language binding adds the configuration syntax its caller can actually use.

Traits§

Embedder
Turns text into a fixed-dimension embedding vector.

Functions§

select_embedder
Resolve an embedding backend name to what the caller must do about it.

Type Aliases§

DynEmbedder
A boxed, object-safe embedder. Lets a non-generic MemoryService<DynEmbedder> be stored behind a concrete type — the MCP server and the language bindings both need this, since handler/pyclass types can’t carry a generic E.