From 52b1ca292cd911d7a43f1bee26ea1e573662c96b Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Mon, 29 Jul 2024 09:01:09 -0700 Subject: [PATCH] fix(utils.py): check if tools is iterable before indexing into it Fixes https://github.com/BerriAI/litellm/issues/4933 --- litellm/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/litellm/utils.py b/litellm/utils.py index ec1370c307..411d2509d5 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -2772,7 +2772,9 @@ def get_optional_params( message=f"Function calling is not supported by {custom_llm_provider}.", ) - if "tools" in non_default_params: + if "tools" in non_default_params and isinstance( + non_default_params, list + ): # fixes https://github.com/BerriAI/litellm/issues/4933 tools = non_default_params["tools"] for ( tool