Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,15 @@ def __init__(
)
self.middleware = list(self.chat_middleware)

@override
def service_url(self) -> str:
"""Get the URL of the Ollama service.

Returns:
The Ollama server URL, used for the ``server.address`` telemetry attribute.
"""
return self.host

@override
def _inner_get_response(
self,
Expand Down
6 changes: 6 additions & 0 deletions python/packages/ollama/tests/test_ollama_chat_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@ def test_init_client(ollama_unit_test_env: dict[str, str]) -> None:
assert isinstance(ollama_chat_client, BaseChatClient)


def test_service_url(ollama_unit_test_env: dict[str, str]) -> None:
ollama_chat_client = OllamaChatClient(host="http://ollama.example:9999")

assert ollama_chat_client.service_url().rstrip("/") == "http://ollama.example:9999"


@pytest.mark.parametrize("exclude_list", [["OLLAMA_MODEL"]], indirect=True)
def test_with_invalid_settings(ollama_unit_test_env: dict[str, str]) -> None:
with pytest.raises(SettingNotFoundError, match="Required setting 'model'"):
Expand Down
Loading