Skip to content

Commit be0c050

Browse files
ctfliblimepjones9
andauthored
Allow api_base/api_key in embedding config (#2269)
Currently, to have embedding and completion hit two distinct API base URLs, you have to define the embedding base in the environment variable and set the completion base in the toml config. This patch obviates the need to use the environment at all and allows setting api_base and api_key in the config for embedding, as well. Co-authored-by: Clay Fouts <[email protected]>
1 parent 82c35f9 commit be0c050

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

py/core/base/providers/embedding.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ class EmbeddingConfig(ProviderConfig):
2929
max_retries: int = 3
3030
initial_backoff: float = 1
3131
max_backoff: float = 64.0
32+
api_base: Optional[str] = None
33+
api_key: Optional[str] = None
3234
quantization_settings: VectorQuantizationSettings = (
3335
VectorQuantizationSettings()
3436
)

py/core/providers/embeddings/litellm.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ def _get_embedding_kwargs(self, **kwargs):
6969
"model": self.base_model,
7070
"dimensions": self.base_dimension,
7171
}
72+
if self.config.api_base:
73+
embedding_kwargs["api_base"] = self.config.api_base
74+
if self.config.api_key:
75+
embedding_kwargs["api_key"] = self.config.api_key
7276
embedding_kwargs.update(kwargs)
7377
return embedding_kwargs
7478

0 commit comments

Comments
 (0)