From 1ce302055a8df6b60597ac94efa00a96068c5520 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Thu, 6 Mar 2025 07:19:18 -0800 Subject: [PATCH] fix litellm_params accessor --- litellm/litellm_core_utils/streaming_handler.py | 14 ++++++++------ litellm/proxy/proxy_config.yaml | 4 +--- litellm/types/router.py | 5 +++++ litellm/types/utils.py | 1 + 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/litellm/litellm_core_utils/streaming_handler.py b/litellm/litellm_core_utils/streaming_handler.py index 580a522be18..a02e5d2c9c4 100644 --- a/litellm/litellm_core_utils/streaming_handler.py +++ b/litellm/litellm_core_utils/streaming_handler.py @@ -15,6 +15,7 @@ from litellm import verbose_logger from litellm.litellm_core_utils.redact_messages import LiteLLMLoggingObject from litellm.litellm_core_utils.thread_pool_executor import executor from litellm.types.llms.openai import ChatCompletionChunk +from litellm.types.router import GenericLiteLLMParams from litellm.types.utils import Delta from litellm.types.utils import GenericStreamingChunk as GChunk from litellm.types.utils import ( @@ -71,6 +72,12 @@ class CustomStreamWrapper: self.sent_first_chunk = False self.sent_last_chunk = False + litellm_params: GenericLiteLLMParams = self.logging_obj.model_call_details.get( + "litellm_params", {} + ) + self.merge_reasoning_content_in_choices = ( + litellm_params.merge_reasoning_content_in_choices + ) self.sent_first_thinking_block = False self.sent_last_thinking_block = False self.thinking_content = "" @@ -92,12 +99,7 @@ class CustomStreamWrapper: self.holding_chunk = "" self.complete_response = "" self.response_uptil_now = "" - _model_info = ( - self.logging_obj.model_call_details.get("litellm_params", {}).get( - "model_info", {} - ) - or {} - ) + _model_info: Dict = litellm_params.model_info or {} _api_base = get_api_base( model=model or "", diff --git a/litellm/proxy/proxy_config.yaml b/litellm/proxy/proxy_config.yaml index 35bb99a3698..1821e1dc233 100644 --- a/litellm/proxy/proxy_config.yaml +++ b/litellm/proxy/proxy_config.yaml @@ -4,11 +4,9 @@ model_list: model: bedrock/us.anthropic.claude-3-7-sonnet-20250219-v1:0 thinking: {"type": "enabled", "budget_tokens": 1024} max_tokens: 1080 + merge_reasoning_content_in_choices: true general_settings: store_model_in_db: true store_prompts_in_spend_logs: true - -litellm_settings: - merge_reasoning_content_in_choices: true diff --git a/litellm/types/router.py b/litellm/types/router.py index e2c92783dab..9a5fb168dac 100644 --- a/litellm/types/router.py +++ b/litellm/types/router.py @@ -192,6 +192,8 @@ class GenericLiteLLMParams(BaseModel): budget_duration: Optional[str] = None use_in_pass_through: Optional[bool] = False model_config = ConfigDict(extra="allow", arbitrary_types_allowed=True) + merge_reasoning_content_in_choices: Optional[bool] = False + model_info: Optional[Dict] = None def __init__( self, @@ -231,6 +233,9 @@ class GenericLiteLLMParams(BaseModel): budget_duration: Optional[str] = None, # Pass through params use_in_pass_through: Optional[bool] = False, + # This will merge the reasoning content in the choices + merge_reasoning_content_in_choices: Optional[bool] = False, + model_info: Optional[Dict] = None, **params, ): args = locals() diff --git a/litellm/types/utils.py b/litellm/types/utils.py index c2c0a4c8bf0..4dad7dddc6f 100644 --- a/litellm/types/utils.py +++ b/litellm/types/utils.py @@ -1803,6 +1803,7 @@ all_litellm_params = [ "max_budget", "budget_duration", "use_in_pass_through", + "merge_reasoning_content_in_choices", ] + list(StandardCallbackDynamicParams.__annotations__.keys())