teff.rag.embedder¶
teff.rag.embedder
¶
Embedding service using provider APIs.
Classes:
| Name | Description |
|---|---|
Embedder |
Convert text to vector embeddings using a provider API. |
Functions:
| Name | Description |
|---|---|
embedder_from_config |
Build an :class: |
Embedder
dataclass
¶
Convert text to vector embeddings using a provider API.
Attributes:
| Name | Type | Description |
|---|---|---|
provider |
str
|
Provider name ( |
model |
str
|
Embedding model name; defaults to a per-provider model. |
base_url |
str | None
|
Optional custom API base URL. |
api_key_env |
str | None
|
Env var holding the API key; defaults to the per-provider env var. |
Methods:
| Name | Description |
|---|---|
embed |
Embed a single text string. |
embed_many |
Embed multiple texts in a single API call. |
Source code in teff/rag/embedder.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
embed
async
¶
embed(text)
Embed a single text string.
Source code in teff/rag/embedder.py
59 60 61 62 | |
embed_many
async
¶
embed_many(texts)
Embed multiple texts in a single API call.
Source code in teff/rag/embedder.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
embedder_from_config
¶
embedder_from_config(cfg, *, providers=None, default_provider=None)
Build an :class:Embedder from an embedder: config dict.
Explicit provider / model / base_url / api_key_env in
the config win. When a piece is missing, values from the matching
:class:~teff.provider.Provider in providers (a registry) are used.
The embeddings endpoint is OpenAI-compatible (<base>/embeddings), so
an inherited base_url gets a /v1 suffix appended unless it
already has one — e.g. an ollama provider whose base_url points
at its native /api/chat host becomes http://localhost:11434/v1.
api_key_env is inherited from any provider that declares one, so a
custom key env var used for chat also applies to embeddings.
Source code in teff/rag/embedder.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |