fix(utils.py): fix cached responses - translate dict to objects

This commit is contained in:
Krrish Dholakia 2023-11-10 10:38:20 -08:00
parent 84460b8222
commit a4c9e6bd46
4 changed files with 108 additions and 21 deletions

View file

@ -144,7 +144,11 @@ async def acompletion(*args, **kwargs):
response = completion(*args, **kwargs)
else:
# Await normally
response = await completion(*args, **kwargs)
init_response = completion(*args, **kwargs)
if isinstance(init_response, dict):
response = init_response
else:
response = await init_response
else:
# Call the synchronous function using run_in_executor
response = await loop.run_in_executor(None, func_with_context)