jeevesagent.memory.embedder¶
Embedders that turn text into vectors.
Two implementations land in this slice:
HashEmbedder— deterministic, zero-dep, SHA256-seeded Gaussian sample. Same text → same vector. Perfect for tests, dev, and for memory backends that only need some vector to enable recall without the cost of a real embedding API.OpenAIEmbedder— wraps OpenAI’stext-embedding-3-{small,large}via the officialopenaiSDK. Lazy SDK import inside__init__so the module loads withoutopenaiinstalled; the import only fires when constructing withoutclient=.
Attributes¶
Classes¶
Embeddings via Cohere's |
|
Deterministic SHA256-seeded unit vectors. |
|
Embeddings via OpenAI's |
|
Embeddings via Voyage AI's |
Module Contents¶
- class jeevesagent.memory.embedder.CohereEmbedder(model: str = 'embed-english-v3.0', *, client: Any | None = None, api_key: str | None = None, input_type: str = 'search_document')[source]¶
Embeddings via Cohere’s
cohereSDK.Models and dimensions:
embed-english-v3.0/embed-multilingual-v3.0-> 1024embed-english-light-v3.0/embed-multilingual-light-v3.0-> 384
input_typeis required by Cohere v3 models:"search_document"(default) — corpus / fact-store entries"search_query"— retrieval queries"classification"/"clustering"for non-retrieval uses
- class jeevesagent.memory.embedder.HashEmbedder(dimensions: int = DEFAULT_HASH_DIMENSIONS)[source]¶
Deterministic SHA256-seeded unit vectors.
Each text gets a fresh
random.Randomseeded by the SHA256 of its UTF-8 bytes, then samplesdimensionsGaussian values and L2-normalises the result. Same text always produces the same vector; different texts produce well-distributed vectors with cosine distances that correlate with literal text equality (not semantic similarity).Use this in tests (fast, no network) and as a default for in-memory backends that need some vector but don’t need real semantic recall.
- class jeevesagent.memory.embedder.OpenAIEmbedder(model: str = 'text-embedding-3-small', *, dimensions: int | None = None, client: Any | None = None, api_key: str | None = None)[source]¶
Embeddings via OpenAI’s
embeddings.createAPI.Dimensions are fixed by the model:
text-embedding-3-small-> 1536text-embedding-3-large-> 3072text-embedding-ada-002-> 1536
Pass
dimensions=only fortext-embedding-3-*models, which support thedimensionsparameter for projection.
- class jeevesagent.memory.embedder.VoyageEmbedder(model: str = 'voyage-3', *, client: Any | None = None, api_key: str | None = None, input_type: str = 'document')[source]¶
Embeddings via Voyage AI’s
voyageaiSDK.Models and dimensions:
voyage-3/voyage-3-large/voyage-code-3-> 1024voyage-3-lite-> 512
input_typecontrols how Voyage encodes the text:"document"(default) — for corpus / fact-store entries"query"— for retrieval queries
Pass an explicit
input_type=if your embedder is dedicated to one role; for the agent loop’s mixed use (we embed both stored triples and recall queries through the same embedder), the"document"default is the safer choice.
- jeevesagent.memory.embedder.DEFAULT_HASH_DIMENSIONS = 384¶