Skip to main content

Module embedder

Module embedder 

Source
Expand description

Local text embedder — generates vector embeddings for semantic search.

Ported from v2’s local_embedder.py (313 lines). Provides a trait-based embedder abstraction with two implementations:

  • HttpEmbedder: Calls llama-server’s /v1/embeddings endpoint (preferred, no model download needed — uses the already-running llama-server)
  • StubEmbedder: Hash-based pseudo-embeddings for testing/fallback

Future: An ort (ONNX Runtime) embedder can implement the same trait for fully local embeddings without a server dependency.

§Environment Variables

VariableDefaultDescription
WM_EMBEDDER_ENDPOINTllama-server HTTP URL (e.g. http://localhost:8080)
WM_EMBEDDER_MODELlocalModel name for the embeddings API
WM_EMBEDDER_DIM384Expected embedding dimensionality
WM_EMBEDDER_TIMEOUT_MS30000Request timeout in milliseconds

Structs§

EmbedderConfig
Configuration for the HTTP-based embedder.
HttpEmbedder
HTTP-based embedder using llama-server’s /v1/embeddings endpoint.
StubEmbedder
Stub embedder — hash-based pseudo-embeddings for testing/fallback.

Traits§

Embedder
Trait for text embedding providers.

Functions§

create_embedder
Create an embedder from environment configuration, with fallback chain.
is_endpoint_safe
Validate an embedder endpoint URL for SSRF safety.