diff --git a/litellm/litellm_core_utils/prompt_templates/factory.py b/litellm/litellm_core_utils/prompt_templates/factory.py index dc1b6a9a53..decf5080a8 100644 --- a/litellm/litellm_core_utils/prompt_templates/factory.py +++ b/litellm/litellm_core_utils/prompt_templates/factory.py @@ -5044,9 +5044,7 @@ def _bedrock_converse_messages_pt( # noqa: PLR0915 assistant_content = _deduplicate_bedrock_content_blocks( assistant_content, "toolUse" ) - assistant_content = _sort_bedrock_assistant_content_blocks( - assistant_content - ) + assistant_content = _sort_bedrock_assistant_content_blocks(assistant_content) if assistant_content: contents.append( diff --git a/litellm/litellm_core_utils/streaming_chunk_builder_utils.py b/litellm/litellm_core_utils/streaming_chunk_builder_utils.py index b5f72f0f31..fe7c62c384 100644 --- a/litellm/litellm_core_utils/streaming_chunk_builder_utils.py +++ b/litellm/litellm_core_utils/streaming_chunk_builder_utils.py @@ -119,9 +119,7 @@ class ChunkProcessor: model = ChunkProcessor._get_model_from_chunks(chunks, first_chunk_model) system_fingerprint = chunk.get("system_fingerprint", None) - first_chunk_with_choices = next( - (c for c in chunks if c.get("choices")), chunk - ) + first_chunk_with_choices = next((c for c in chunks if c.get("choices")), chunk) role = first_chunk_with_choices["choices"][0]["delta"]["role"] finish_reason = "stop" for chunk in chunks: diff --git a/litellm/litellm_core_utils/streaming_handler.py b/litellm/litellm_core_utils/streaming_handler.py index 1dccdbdfa8..e281b17268 100644 --- a/litellm/litellm_core_utils/streaming_handler.py +++ b/litellm/litellm_core_utils/streaming_handler.py @@ -1872,7 +1872,9 @@ class CustomStreamWrapper: if response.choices: choice = response.choices[0] if isinstance(choice, StreamingChoices): - self.response_uptil_now += choice.delta.get("content", "") or "" + self.response_uptil_now += ( + choice.delta.get("content", "") or "" + ) else: self.response_uptil_now += "" self.rules.post_call_rules( @@ -2053,7 +2055,9 @@ class CustomStreamWrapper: if processed_chunk.choices: choice = processed_chunk.choices[0] if isinstance(choice, StreamingChoices): - self.response_uptil_now += choice.delta.get("content", "") or "" + self.response_uptil_now += ( + choice.delta.get("content", "") or "" + ) else: self.response_uptil_now += "" self.rules.post_call_rules( diff --git a/litellm/llms/openai/responses/transformation.py b/litellm/llms/openai/responses/transformation.py index 83e1d6c386..87c502032c 100644 --- a/litellm/llms/openai/responses/transformation.py +++ b/litellm/llms/openai/responses/transformation.py @@ -95,7 +95,9 @@ class OpenAIResponsesAPIConfig(BaseResponsesAPIConfig): temperature = params.get("temperature") if temperature is not None and temperature != 1: reasoning = params.get("reasoning") or {} - effort = reasoning.get("effort") if isinstance(reasoning, dict) else None + effort = ( + reasoning.get("effort") if isinstance(reasoning, dict) else None + ) supports_none = self._supports_reasoning_effort_none(model=model) if supports_none and (effort == "none" or effort is None): pass # flexible temperature allowed diff --git a/litellm/main.py b/litellm/main.py index d95c38f345..2889825e6e 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -7389,9 +7389,7 @@ def stream_chunk_builder( # noqa: PLR0915 if len(chunks) == 0: return None ## Route to the text completion logic - first_chunk_with_choices = next( - (c for c in chunks if c["choices"]), None - ) + first_chunk_with_choices = next((c for c in chunks if c["choices"]), None) if first_chunk_with_choices is not None and isinstance( first_chunk_with_choices["choices"][0], litellm.utils.TextChoices ): # route to the text completion logic