mirror of
https://github.com/ollama/ollama-python.git
synced 2026-10-01 14:47:24 +00:00
Add URL path to client URL in in Client._parse_host() (#170)
* Add URL path to client URL in in Client._parse_host() * add tests for url path * improve URL path handling * restore trailing space * remove extraneous path assignment * Fix url path test Co-authored-by: Michael Yang <[email protected]> --------- Co-authored-by: Ben Plunkert <[email protected]> Co-authored-by: Michael Yang <[email protected]>
This commit is contained in:
co-authored by
Michael Yang
Ben Plunkert
parent
8b694bb0f4
commit
dfdeb7cef3
@@ -987,6 +987,14 @@ def _parse_host(host: Optional[str]) -> str:
|
|||||||
'http://example.com:11434'
|
'http://example.com:11434'
|
||||||
>>> _parse_host('example.com:56789/')
|
>>> _parse_host('example.com:56789/')
|
||||||
'http://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
|
host, port = host or '', 11434
|
||||||
@@ -1002,4 +1010,7 @@ def _parse_host(host: Optional[str]) -> str:
|
|||||||
host = split.hostname or '127.0.0.1'
|
host = split.hostname or '127.0.0.1'
|
||||||
port = split.port or port
|
port = split.port or port
|
||||||
|
|
||||||
|
if path := split.path.strip('/'):
|
||||||
|
return f'{scheme}://{host}:{port}/{path}'
|
||||||
|
|
||||||
return f'{scheme}://{host}:{port}'
|
return f'{scheme}://{host}:{port}'
|
||||||
|
|||||||
Reference in New Issue
Block a user