fix(router.py): support retry and fallbacks for atext_completion

This commit is contained in:
Krrish Dholakia 2023-12-30 11:19:13 +05:30
parent 7ecd7b3e8d
commit 38f55249e1
6 changed files with 290 additions and 69 deletions

View file

@ -212,15 +212,15 @@ async def acompletion(*args, **kwargs):
else:
# Call the synchronous function using run_in_executor
response = await loop.run_in_executor(None, func_with_context)
if kwargs.get("stream", False): # return an async generator
return _async_streaming(
response=response,
model=model,
custom_llm_provider=custom_llm_provider,
args=args,
)
else:
return response
# if kwargs.get("stream", False): # return an async generator
# return _async_streaming(
# response=response,
# model=model,
# custom_llm_provider=custom_llm_provider,
# args=args,
# )
# else:
return response
except Exception as e:
custom_llm_provider = custom_llm_provider or "openai"
raise exception_type(