From dc9dcfefacd3ea9d9aae9f90a80731da6f7dc2a5 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Mon, 22 Jul 2024 18:10:33 -0700 Subject: [PATCH] fix(openai.py): check if error body is a dictionary before indexing in --- litellm/llms/openai.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/litellm/llms/openai.py b/litellm/llms/openai.py index d1e0d14ba9..25e2e518c5 100644 --- a/litellm/llms/openai.py +++ b/litellm/llms/openai.py @@ -968,7 +968,7 @@ class OpenAIChatCompletion(BaseLLM): except openai.UnprocessableEntityError as e: ## check if body contains unprocessable params - related issue https://github.com/BerriAI/litellm/issues/4800 if litellm.drop_params is True or drop_params is True: - if e.body is not None and e.body.get("detail"): # type: ignore + if e.body is not None and isinstance(e.body, dict) and e.body.get("detail"): # type: ignore detail = e.body.get("detail") # type: ignore invalid_params: List[str] = [] if ( @@ -1100,7 +1100,7 @@ class OpenAIChatCompletion(BaseLLM): except openai.UnprocessableEntityError as e: ## check if body contains unprocessable params - related issue https://github.com/BerriAI/litellm/issues/4800 if litellm.drop_params is True or drop_params is True: - if e.body is not None and e.body.get("detail"): # type: ignore + if e.body is not None and isinstance(e.body, dict) and e.body.get("detail"): # type: ignore detail = e.body.get("detail") # type: ignore invalid_params: List[str] = [] if ( @@ -1231,7 +1231,7 @@ class OpenAIChatCompletion(BaseLLM): except openai.UnprocessableEntityError as e: ## check if body contains unprocessable params - related issue https://github.com/BerriAI/litellm/issues/4800 if litellm.drop_params is True or drop_params is True: - if e.body is not None and e.body.get("detail"): # type: ignore + if e.body is not None and isinstance(e.body, dict) and e.body.get("detail"): # type: ignore detail = e.body.get("detail") # type: ignore invalid_params: List[str] = [] if (