diff --git a/ollama/_client.py b/ollama/_client.py index de26805..4b913d7 100644 --- a/ollama/_client.py +++ b/ollama/_client.py @@ -987,6 +987,14 @@ def _parse_host(host: Optional[str]) -> str: 'http://example.com:11434' >>> _parse_host('example.com:56789/') 'http://example.com:56789' + >>> _parse_host('example.com/path') + 'http://example.com:11434/path' + >>> _parse_host('example.com:56789/path') + 'http://example.com:56789/path' + >>> _parse_host('https://example.com:56789/path') + 'https://example.com:56789/path' + >>> _parse_host('example.com:56789/path/') + 'http://example.com:56789/path' """ host, port = host or '', 11434 @@ -1002,4 +1010,7 @@ def _parse_host(host: Optional[str]) -> str: host = split.hostname or '127.0.0.1' port = split.port or port + if path := split.path.strip('/'): + return f'{scheme}://{host}:{port}/{path}' + return f'{scheme}://{host}:{port}'