Skip to content

Commit

Permalink
retry groq requests
Browse files Browse the repository at this point in the history
  • Loading branch information
devxpy committed Jul 9, 2024
1 parent cf81dce commit b78304e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 20 deletions.
13 changes: 2 additions & 11 deletions daras_ai_v2/language_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
from daras_ai.image_input import gs_url_to_uri, bytes_to_cv2_img, cv2_img_to_bytes
from daras_ai_v2.asr import get_google_auth_session
from daras_ai_v2.exceptions import raise_for_status, UserError
from functions.recipe_functions import LLMTools
from daras_ai_v2.gpu_server import call_celery_task
from daras_ai_v2.text_splitter import (
default_length_function,
default_separators,
)
from functions.recipe_functions import LLMTools

DEFAULT_SYSTEM_MSG = "You are an intelligent AI assistant. Follow the instructions as closely as possible."

Expand Down Expand Up @@ -985,16 +985,7 @@ def get_openai_client(model: str):
return client


def groq_should_retry(e: Exception) -> bool:
return isinstance(e, requests.HTTPError) and e.response.status_code in [
429,
502,
503,
504,
]


@aifail.retry_if(groq_should_retry)
@aifail.retry_if(aifail.http_should_retry)
def _run_groq_chat(
*,
model: str,
Expand Down
20 changes: 12 additions & 8 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ ua-parser = "^0.18.0"
user-agents = "^2.2.0"
openpyxl = "^3.1.2"
loguru = "^0.7.2"
aifail = "0.2.0"
aifail = {git = "https://github.com/GooeyAI/aifail/", rev = "0.3.0"}
pytest-playwright = "^0.4.3"
emoji = "^2.10.1"
pyvespa = "^0.39.0"
Expand Down

0 comments on commit b78304e

Please sign in to comment.