diff --git a/python/packages/ollama/agent_framework_ollama/_chat_client.py b/python/packages/ollama/agent_framework_ollama/_chat_client.py index 7b27a4c660f..e4c2da395df 100644 --- a/python/packages/ollama/agent_framework_ollama/_chat_client.py +++ b/python/packages/ollama/agent_framework_ollama/_chat_client.py @@ -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, diff --git a/python/packages/ollama/tests/test_ollama_chat_client.py b/python/packages/ollama/tests/test_ollama_chat_client.py index 8c5e21172f2..84042eecd4f 100644 --- a/python/packages/ollama/tests/test_ollama_chat_client.py +++ b/python/packages/ollama/tests/test_ollama_chat_client.py @@ -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'"):