fix(utils.py): fix get for dict

This commit is contained in:
Krrish Dholakia 2024-01-31 18:15:47 -08:00
parent a0daac212d
commit 9dc972de70

View file

@ -2189,7 +2189,7 @@ def client(original_function):
# CHECK MAX TOKENS # CHECK MAX TOKENS
if ( if (
kwargs("max_tokens", None) is not None kwargs.get("max_tokens", None) is not None
and model is not None and model is not None
and litellm.drop_params and litellm.drop_params
== True # user is okay with params being modified == True # user is okay with params being modified
@ -2205,9 +2205,12 @@ def client(original_function):
if user_max_tokens > max_output_tokens: if user_max_tokens > max_output_tokens:
user_max_tokens = max_output_tokens user_max_tokens = max_output_tokens
## Scenario 2: User limit + prompt > model limit ## Scenario 2: User limit + prompt > model limit
input_tokens = token_counter( messages = None
model=model, messages=kwargs.get("messages") if len(args) > 1:
) messages = args[1]
elif kwargs.get("messages", None):
messages = kwargs["messages"]
input_tokens = token_counter(model=model, messages=messages)
if input_tokens > max_output_tokens: if input_tokens > max_output_tokens:
pass # allow call to fail normally pass # allow call to fail normally
elif user_max_tokens + input_tokens > max_output_tokens: elif user_max_tokens + input_tokens > max_output_tokens: