Skip to content

Commit

Permalink
Merge pull request #833 from PrefectHQ/hotfix/await-should-retry
Browse files Browse the repository at this point in the history
await should_fallback
  • Loading branch information
zzstoatzz authored Feb 6, 2024
2 parents e712231 + 96eb6da commit 8ee6b7c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/marvin/client/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
TranscriptRequest,
VisionRequest,
)
from marvin.utilities.asyncio import run_sync
from marvin.utilities.logging import get_logger
from marvin.utilities.openai import get_openai_client

Expand Down Expand Up @@ -182,7 +183,7 @@ def generate_chat(
try:
response: "ChatCompletion" = create(**request.model_dump(exclude_none=True))
except NotFoundError as e:
if should_fallback(e, request):
if run_sync(should_fallback(e, request)):
response = create(
**request.model_dump(exclude_none=True)
| dict(model=FALLBACK_CHAT_COMPLETIONS_MODEL)
Expand Down Expand Up @@ -283,7 +284,7 @@ async def generate_chat(
**request.model_dump(exclude_none=True)
)
except NotFoundError as e:
if should_fallback(e, request):
if await should_fallback(e, request):
response = await create(
**request.model_dump(exclude_none=True)
| dict(model=FALLBACK_CHAT_COMPLETIONS_MODEL)
Expand Down

0 comments on commit 8ee6b7c

Please sign in to comment.