Skip to main content

Module embedding

Module embedding 

Source

Structs§

CloudEmbedder
Cloud-managed embedder. POSTs { texts: [..] } to the cloud API’s /api/embeddings endpoint, authenticating with the user’s existing CLI session token (same cloud-auth.db row that powers cloud::client::CloudClient).
EmbeddedText
OpenAICompatEmbedder
OpenAI-compatible embedding provider.
Sha1Embedder
Hash-based fallback embedder (the original SHA1 implementation).

Enums§

ActiveEmbedderKind
Lightweight tag for the active embedder, returned by probe_active_embedder so callers can render the right hint copy without re-implementing the priority chain.

Constants§

CLOUD_MANAGED_SENTINEL
Sentinel stored in context_engine.embedding_provider_url when the user explicitly picked the cloud-managed embedding source. The get_embedder chain treats this as “use CloudEmbedder if logged in, otherwise local lexical hash” — it must never be sent as a real URL to OpenAICompatEmbedder.
DEFAULT_OPENAI_EMBEDDING_DIM
Default dimensionality for OpenAI text-embedding-3-small.
EMBEDDING_BATCH_SIZE
EMBEDDING_DIM

Traits§

Embedder
Abstract embedding provider.

Functions§

active_embedding_profile
cosine_similarity
True cosine similarity in [-1, 1], normalizing both inputs.
embed_text
Synchronous SHA1 embedding — retained as the explicit local lexical embedder for offline users who have not configured cloud/BYOK semantic embeddings.
embed_text_async
Async embedding helper that tries the configured embedder first and keeps retrieval usable if the provider is unavailable.
embed_text_async_with_timeout
Async embedding helper for latency-sensitive paths.
embed_texts_async_with_timeout
get_embedder
Resolve the configured embedder from settings.
load_embedding_key
Decrypt an embedding provider API key from the opaque storage identifier produced by store_embedding_key.
probe_active_embedder
Inspect the currently-resolved embedder and report its kind. Mirrors the priority chain in get_embedder (explicit BYOK → cloud → SHA1) without allocating the actual embedder. BYOK is checked first so a BYOK user never triggers a cloud-auth.db decrypt just to report status.
probe_active_embedder_sync
Sync sibling of probe_active_embedder for non-async render paths (the TUI status bar). Runs the authoritative async probe on a short-lived scratch runtime on its own thread, so it returns the EXACT same answer as the runtime resolver — real token load (DIFFLORE_TOKEN env + decrypted cloud-auth.db row) and BYOK key validation — with no separate sync detection logic that could drift. The caller caches the result, so this only spawns on a cache miss.
store_embedding_key
Encrypt an embedding provider API key and return the opaque storage identifier that should be persisted in settings (embedding_provider_key).