mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 11:14:04 +00:00
fix(utils.py): don't run post-call rules on a coroutine function
This commit is contained in:
parent
d08da5b05a
commit
9b7383ac67
2 changed files with 28 additions and 5 deletions
|
@ -2465,6 +2465,14 @@ def client(original_function):
|
|||
)
|
||||
raise e
|
||||
|
||||
def check_coroutine(value) -> bool:
|
||||
if inspect.iscoroutine(value):
|
||||
return True
|
||||
elif inspect.iscoroutinefunction(value):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def post_call_processing(original_response, model):
|
||||
try:
|
||||
if original_response is None:
|
||||
|
@ -2475,11 +2483,15 @@ def client(original_function):
|
|||
call_type == CallTypes.completion.value
|
||||
or call_type == CallTypes.acompletion.value
|
||||
):
|
||||
model_response = original_response["choices"][0]["message"][
|
||||
"content"
|
||||
]
|
||||
### POST-CALL RULES ###
|
||||
rules_obj.post_call_rules(input=model_response, model=model)
|
||||
is_coroutine = check_coroutine(original_function)
|
||||
if is_coroutine == True:
|
||||
pass
|
||||
else:
|
||||
model_response = original_response["choices"][0]["message"][
|
||||
"content"
|
||||
]
|
||||
### POST-CALL RULES ###
|
||||
rules_obj.post_call_rules(input=model_response, model=model)
|
||||
except Exception as e:
|
||||
raise e
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue