-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
generator: Ollama #876
base: main
Are you sure you want to change the base?
generator: Ollama #876
Conversation
The tests are skipped when no Ollama server can be found.
DCO Assistant Lite bot All contributors have signed the DCO ✍️ ✅ |
I have read the DCO Document and I hereby sign the DCO |
recheck |
Thanks for this! Will take a look |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good, this should work for a local service and the change to access instance parameters will enable config
.
Tests need a bit of work to have proper value.
Co-authored-by: Jeffrey Martin <jmartin@Op3n4M3.dev> Signed-off-by: Martin <31307962+martinebl@users.noreply.github.com>
…predicate instead
|
||
@backoff.on_exception( | ||
backoff.fibo, | ||
(TimeoutError, ollama.ResponseError), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing shows TimeoutError
may not be the exception that should be handled here.
This exception here is an OSError not a request timeout.
class TimeoutError(OSError): ...
Example failure:
File "/home/jemartin/miniconda3/envs/garak/lib/python3.12/site-packages/httpx/_transports/default.py", line 69, in map_httpcore_exceptions
yield
File "/home/jemartin/miniconda3/envs/garak/lib/python3.12/site-packages/httpx/_transports/default.py", line 233, in handle_request
resp = self._pool.handle_request(req)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jemartin/miniconda3/envs/garak/lib/python3.12/site-packages/httpcore/_sync/connection_pool.py", line 216, in handle_request
raise exc from None
File "/home/jemartin/miniconda3/envs/garak/lib/python3.12/site-packages/httpcore/_sync/connection_pool.py", line 196, in handle_request
response = connection.handle_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jemartin/miniconda3/envs/garak/lib/python3.12/site-packages/httpcore/_sync/connection.py", line 101, in handle_request
return self._connection.handle_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jemartin/miniconda3/envs/garak/lib/python3.12/site-packages/httpcore/_sync/http11.py", line 143, in handle_request
raise exc
File "/home/jemartin/miniconda3/envs/garak/lib/python3.12/site-packages/httpcore/_sync/http11.py", line 113, in handle_request
) = self._receive_response_headers(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jemartin/miniconda3/envs/garak/lib/python3.12/site-packages/httpcore/_sync/http11.py", line 186, in _receive_response_headers
event = self._receive_event(timeout=timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jemartin/miniconda3/envs/garak/lib/python3.12/site-packages/httpcore/_sync/http11.py", line 224, in _receive_event
data = self._network_stream.read(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jemartin/miniconda3/envs/garak/lib/python3.12/site-packages/httpcore/_backends/sync.py", line 124, in read
with map_exceptions(exc_map):
File "/home/jemartin/miniconda3/envs/garak/lib/python3.12/contextlib.py", line 158, in __exit__
self.gen.throw(value)
File "/home/jemartin/miniconda3/envs/garak/lib/python3.12/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions
raise to_exc(exc) from exc
httpcore.ReadTimeout: timed out
The expected timeout class would be httpx.TimeoutException
which would cover ConnectTimeout
, ReadTimeout
, WriteTimeout
, & PoolTimeout
:
from httpx import TimeoutException
(TimeoutError, ollama.ResponseError), | |
(TimeoutException, ollama.ResponseError), |
This would apply to both implementation of _call_model()
.
Add two Ollama generators, using either the chat or generate functions from the Ollama package.
Add tests, that are skipped when no Ollama server is running.