From 90775910e284b7870d2d7588d0f55b9c27911833 Mon Sep 17 00:00:00 2001 From: kan-bayashi Date: Wed, 14 Feb 2024 17:38:00 +0900 Subject: [PATCH] fix if-else condition when function_call exits but empty --- litellm/llms/vertex_ai.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/litellm/llms/vertex_ai.py b/litellm/llms/vertex_ai.py index f7062fc6a1e..f24b6c35879 100644 --- a/litellm/llms/vertex_ai.py +++ b/litellm/llms/vertex_ai.py @@ -432,14 +432,13 @@ def completion( tools=tools, ) - if tools is not None and hasattr( - response.candidates[0].content.parts[0], "function_call" + if tools is not None and bool( + getattr(response.candidates[0].content.parts[0], "function_call", None) ): function_call = response.candidates[0].content.parts[0].function_call args_dict = {} - if function_call.args is not None: - for k, v in function_call.args.items(): - args_dict[k] = v + for k, v in function_call.args.items(): + args_dict[k] = v args_str = json.dumps(args_dict) message = litellm.Message( content=None,