Skip to content

Commit

Permalink
feat: add client_kwargs Parameter to OllamaEmbedding Class (#18012)
Browse files Browse the repository at this point in the history
  • Loading branch information
ALENJOSESR authored Mar 5, 2025
1 parent e486157 commit cfb76b9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def __init__(
embed_batch_size: int = DEFAULT_EMBED_BATCH_SIZE,
ollama_additional_kwargs: Optional[Dict[str, Any]] = None,
callback_manager: Optional[CallbackManager] = None,
client_kwargs: Optional[Dict[str, Any]] = None,
**kwargs: Any,
) -> None:
super().__init__(
Expand All @@ -45,8 +46,9 @@ def __init__(
**kwargs,
)

self._client = Client(host=self.base_url)
self._async_client = AsyncClient(host=self.base_url)
client_kwargs = client_kwargs or {}
self._client = Client(host=self.base_url, **client_kwargs)
self._async_client = AsyncClient(host=self.base_url, **client_kwargs)

@classmethod
def class_name(cls) -> str:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ exclude = ["**/BUILD"]
license = "MIT"
name = "llama-index-embeddings-ollama"
readme = "README.md"
version = "0.5.0"
version = "0.6.0"

[tool.poetry.dependencies]
python = ">=3.9,<4.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@


def test_embedding_class():
emb = OllamaEmbedding(model_name="")
emb = OllamaEmbedding(
model_name="", client_kwargs={"headers": {"Authorization": "Bearer token"}}
)
assert isinstance(emb, BaseEmbedding)

0 comments on commit cfb76b9

Please sign in to comment.