mirror of
https://github.com/ollama/ollama-python.git
synced 2026-05-01 11:48:17 +08: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 <mxyng@pm.me> --------- Co-authored-by: Ben Plunkert <ben@plunkert.com> Co-authored-by: Michael Yang <mxyng@pm.me>
This commit is contained in:
parent
8b694bb0f4
commit
dfdeb7cef3
@ -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}'
|
||||
|
||||
Loading…
Reference in New Issue
Block a user