-
Notifications
You must be signed in to change notification settings - Fork 789
Description
Before setting OLLAMA_HOST, ollama.generate() was working.
response = ollama.generate(model=model, prompt=prompt, stream=True)
After setting OLLAMA_HOST=0.0.0.0, ollama.generate() did not work at all.
But directly connecting to http://localhost:11434/api/generate without python work well.
How can I fix this?
Traceback (most recent call last):
File "X:\pythonProjects\py312_pytorch_cuda_v2\Lib\site-packages\httpx_transports\default.py", line 101, in map_httpcore_exceptions
yield
File "X:\pythonProjects\py312_pytorch_cuda_v2\Lib\site-packages\httpx_transports\default.py", line 250, in handle_request
resp = self._pool.handle_request(req)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "X:\pythonProjects\py312_pytorch_cuda_v2\Lib\site-packages\httpcore_sync\connection_pool.py", line 256, in handle_request
raise exc from None
File "X:\pythonProjects\py312_pytorch_cuda_v2\Lib\site-packages\httpcore_sync\connection_pool.py", line 236, in handle_request
response = connection.handle_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "X:\pythonProjects\py312_pytorch_cuda_v2\Lib\site-packages\httpcore_sync\connection.py", line 101, in handle_request
raise exc
File "X:\pythonProjects\py312_pytorch_cuda_v2\Lib\site-packages\httpcore_sync\connection.py", line 78, in handle_request
stream = self._connect(request)
^^^^^^^^^^^^^^^^^^^^^^
File "X:\pythonProjects\py312_pytorch_cuda_v2\Lib\site-packages\httpcore_sync\connection.py", line 124, in _connect
stream = self._network_backend.connect_tcp(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "X:\pythonProjects\py312_pytorch_cuda_v2\Lib\site-packages\httpcore_backends\sync.py", line 207, in connect_tcp
with map_exceptions(exc_map):
^^^^^^^^^^^^^^^^^^^^^^^
File "X:\pythonProjects\py312_pytorch_cuda_v2\Lib\contextlib.py", line 158, in exit
self.gen.throw(value)
File "X:\pythonProjects\py312_pytorch_cuda_v2\Lib\site-packages\httpcore_exceptions.py", line 14, in map_exceptions
raise to_exc(exc) from exc
httpcore.ConnectError: [WinError 10049] 內容中所要求的位址不正確。
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "x:\pythonProjects\llmDemo\1_ollama\1_generate\generate_python.py", line 35, in
completion_with_ollama(prompt)
File "x:\pythonProjects\llmDemo\1_ollama\1_generate\generate_python.py", line 18, in completion_with_ollama
for chunk in response:
^^^^^^^^
File "X:\pythonProjects\py312_pytorch_cuda_v2\Lib\site-packages\ollama_client.py", line 163, in inner
with self._client.stream(*args, **kwargs) as r:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "X:\pythonProjects\py312_pytorch_cuda_v2\Lib\contextlib.py", line 137, in enter
return next(self.gen)
^^^^^^^^^^^^^^
File "X:\pythonProjects\py312_pytorch_cuda_v2\Lib\site-packages\httpx_client.py", line 868, in stream
response = self.send(
^^^^^^^^^^
File "X:\pythonProjects\py312_pytorch_cuda_v2\Lib\site-packages\httpx_client.py", line 914, in send
response = self._send_handling_auth(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "X:\pythonProjects\py312_pytorch_cuda_v2\Lib\site-packages\httpx_client.py", line 942, in _send_handling_auth
response = self._send_handling_redirects(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "X:\pythonProjects\py312_pytorch_cuda_v2\Lib\site-packages\httpx_client.py", line 979, in _send_handling_redirects
response = self._send_single_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "X:\pythonProjects\py312_pytorch_cuda_v2\Lib\site-packages\httpx_client.py", line 1014, in _send_single_request
response = transport.handle_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "X:\pythonProjects\py312_pytorch_cuda_v2\Lib\site-packages\httpx_transports\default.py", line 249, in handle_request
with map_httpcore_exceptions():
^^^^^^^^^^^^^^^^^^^^^^^^^
File "X:\pythonProjects\py312_pytorch_cuda_v2\Lib\contextlib.py", line 158, in exit
self.gen.throw(value)
File "X:\pythonProjects\py312_pytorch_cuda_v2\Lib\site-packages\httpx_transports\default.py", line 118, in map_httpcore_exceptions
raise mapped_exc(message) from exc
httpx.ConnectError: [WinError 10049] 內容中所要求的位址不正確。