diff --git a/litellm/__init__.py b/litellm/__init__.py index 60b8cf81a04..0d1ce662c3d 100644 --- a/litellm/__init__.py +++ b/litellm/__init__.py @@ -282,6 +282,7 @@ priority_reservation: Optional[Dict[str, float]] = None force_ipv4: bool = ( False # when True, litellm will force ipv4 for all LLM requests. Some users have seen httpx ConnectionError when using ipv6. ) +merge_reasoning_content_in_choices: bool = True module_level_aclient = AsyncHTTPHandler( timeout=request_timeout, client_alias="module level aclient" ) diff --git a/litellm/types/utils.py b/litellm/types/utils.py index 7e6b95ab154..b118b2634f9 100644 --- a/litellm/types/utils.py +++ b/litellm/types/utils.py @@ -21,6 +21,8 @@ from openai.types.moderation_create_response import Moderation, ModerationCreate from pydantic import BaseModel, ConfigDict, Field, PrivateAttr from typing_extensions import Callable, Dict, Required, TypedDict, override +import litellm + from ..litellm_core_utils.core_helpers import map_finish_reason from .guardrails import GuardrailEventHooks from .llms.openai import ( @@ -582,6 +584,14 @@ class Delta(OpenAIObject): super(Delta, self).__init__(**params) add_provider_specific_fields(self, params.get("provider_specific_fields", {})) self.content = content + + if litellm.merge_reasoning_content_in_choices: + self.content = ( + (self.content or "") + f"{reasoning_content}" + if reasoning_content + else self.content + ) + self.role = role # Set default values and correct types self.function_call: Optional[Union[FunctionCall, Any]] = None