embeddings
embeddings
¶
Dense embedding clients for the IngestionPipeline.
A thin HTTP wrapper around a local Ollama <https://ollama.com>_ daemon
running an embedding model (default nomic-embed-text, 768-dim). Embeddings
are serialised as float32 bytes for storage in the embedding BLOB
column of knowledge_chunks.
The client degrades gracefully when the daemon is unreachable: embed
returns None and is_available() reports False instead of raising,
so ingestion never fails because a sidecar service is down.
Classes¶
OllamaEmbedder
¶
OllamaEmbedder(*, model: str = DEFAULT_EMBED_MODEL, host: Optional[str] = None, timeout: float = 30.0)
Embed text via a local Ollama daemon.
| PARAMETER | DESCRIPTION |
|---|---|
model
|
Ollama model tag (e.g.
TYPE:
|
host
|
Base URL for the Ollama HTTP API. When
TYPE:
|
timeout
|
Per-request timeout in seconds.
TYPE:
|
Source code in src/openjarvis/connectors/embeddings.py
Attributes¶
model_version
property
¶
Stable identifier persisted alongside each embedding row.
dim
property
¶
Embedding dimensionality, learned after the first successful call.
Functions¶
is_available
¶
Return True iff the daemon answers and the model is installed.
Source code in src/openjarvis/connectors/embeddings.py
embed
¶
Embed a single string. Returns float32 bytes or None on failure.
Source code in src/openjarvis/connectors/embeddings.py
embed_batch
¶
Embed a list of strings sequentially.
Ollama's HTTP API serves one prompt per call; on the same host the round-trip overhead is negligible relative to model inference.
Source code in src/openjarvis/connectors/embeddings.py
Functions¶
default_embedder
¶
default_embedder() -> Optional[OllamaEmbedder]
Return an OllamaEmbedder if the daemon and default model are up.
Ingestion call sites use this so chunks get embedded whenever an embedder
is actually reachable, and fall back to lexical-only rows (None)
otherwise. Query-side hybrid search does the same probe, so the two ends
stay in step: if this returns None at ingest, _vector_recall finds
no rows to score either way.
Source code in src/openjarvis/connectors/embeddings.py
decode_embedding
¶
Reconstruct a 1-D vector from a BLOB written by OllamaEmbedder.embed.
Returns None when the input is missing or zero-length so callers can
treat absent embeddings uniformly. dtype defaults to np.float32
(resolved lazily; passing np.float32 as a default arg would import
numpy at module load).