mirror of
https://github.com/zylon-ai/private-gpt.git
synced 2025-12-22 17:05:41 +01:00
feat: add retry connection to ollama
When Ollama is running in the docker-compose, traefik is not ready sometimes to route the request, and it fails ...
This commit is contained in:
parent
42628596b2
commit
d67d0c0f5e
4 changed files with 70 additions and 6 deletions
31
private_gpt/utils/retry.py
Normal file
31
private_gpt/utils/retry.py
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import logging
|
||||
from collections.abc import Callable
|
||||
from typing import Any
|
||||
|
||||
from retry_async import retry as retry_untyped # type: ignore
|
||||
|
||||
retry_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def retry(
|
||||
exceptions: Any = Exception,
|
||||
*,
|
||||
is_async: bool = False,
|
||||
tries: int = -1,
|
||||
delay: float = 0,
|
||||
max_delay: float | None = None,
|
||||
backoff: float = 1,
|
||||
jitter: float | tuple[float, float] = 0,
|
||||
logger: logging.Logger = retry_logger,
|
||||
) -> Callable[..., Any]:
|
||||
wrapped = retry_untyped(
|
||||
exceptions=exceptions,
|
||||
is_async=is_async,
|
||||
tries=tries,
|
||||
delay=delay,
|
||||
max_delay=max_delay,
|
||||
backoff=backoff,
|
||||
jitter=jitter,
|
||||
logger=logger,
|
||||
)
|
||||
return wrapped # type: ignore
|
||||
Loading…
Add table
Add a link
Reference in a new issue