Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

style: apply black formatting

Chesarse1e5fcb03ecc
diff --git a/litellm/litellm_core_utils/prompt_templates/factory.py b/litellm/litellm_core_utils/prompt_templates/factory.py
index dc1b6a9a53d..decf5080a88 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 b5f72f0f318..fe7c62c3842 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 1dccdbdfa8c..e281b172685 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 83e1d6c386c..87c502032cc 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 d95c38f345e..2889825e6e1 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