From 9bc5aaee647518cefb113338337663e58d411211 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Fri, 21 Mar 2025 21:28:11 -0700 Subject: [PATCH] fix ModelParamHelper --- .../litellm_core_utils/model_param_helper.py | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/litellm/litellm_core_utils/model_param_helper.py b/litellm/litellm_core_utils/model_param_helper.py index 5316ab5d84..d792ede282 100644 --- a/litellm/litellm_core_utils/model_param_helper.py +++ b/litellm/litellm_core_utils/model_param_helper.py @@ -84,8 +84,10 @@ class ModelParamHelper: This follows the OpenAI API Spec """ all_chat_completion_kwargs = set( - CompletionCreateParamsNonStreaming.__annotations__.keys() - ).union(set(CompletionCreateParamsStreaming.__annotations__.keys())) + getattr(CompletionCreateParamsNonStreaming, "__annotations__", {}).keys() + ).union( + set(getattr(CompletionCreateParamsStreaming, "__annotations__", {}).keys()) + ) return all_chat_completion_kwargs @staticmethod @@ -96,8 +98,16 @@ class ModelParamHelper: This follows the OpenAI API Spec """ all_text_completion_kwargs = set( - TextCompletionCreateParamsNonStreaming.__annotations__.keys() - ).union(set(TextCompletionCreateParamsStreaming.__annotations__.keys())) + getattr( + TextCompletionCreateParamsNonStreaming, "__annotations__", {} + ).keys() + ).union( + set( + getattr( + TextCompletionCreateParamsStreaming, "__annotations__", {} + ).keys() + ) + ) return all_text_completion_kwargs @staticmethod @@ -114,7 +124,7 @@ class ModelParamHelper: This follows the OpenAI API Spec """ - return set(EmbeddingCreateParams.__annotations__.keys()) + return set(getattr(EmbeddingCreateParams, "__annotations__", {}).keys()) @staticmethod def _get_litellm_supported_transcription_kwargs() -> Set[str]: @@ -128,10 +138,10 @@ class ModelParamHelper: TranscriptionCreateParamsNonStreaming, TranscriptionCreateParamsStreaming, ) + non_streaming_kwargs = set(getattr(TranscriptionCreateParamsNonStreaming, "__annotations__", {}).keys()) + streaming_kwargs = set(getattr(TranscriptionCreateParamsStreaming, "__annotations__", {}).keys()) - all_transcription_kwargs = set( - TranscriptionCreateParamsNonStreaming.__annotations__.keys() - ).union(set(TranscriptionCreateParamsStreaming.__annotations__.keys())) + all_transcription_kwargs = non_streaming_kwargs.union(streaming_kwargs) return all_transcription_kwargs except Exception as e: verbose_logger.warning("Error getting transcription kwargs %s", str(e))