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]

fix(mypy): cast msg and pending_delta in _promote_message_stop_usage to resolve union-attr and assignment errors

Ishaan Jaffer6bf90fb10a33
diff --git a/litellm/llms/bedrock/messages/invoke_transformations/anthropic_claude3_transformation.py b/litellm/llms/bedrock/messages/invoke_transformations/anthropic_claude3_transformation.py
index 542c43b6594..67b4ad1b23a 100644
--- a/litellm/llms/bedrock/messages/invoke_transformations/anthropic_claude3_transformation.py
+++ b/litellm/llms/bedrock/messages/invoke_transformations/anthropic_claude3_transformation.py
@@ -577,7 +577,7 @@ class AmazonAnthropicClaudeMessagesConfig(
chunk_type = chunk.get("type")
if chunk_type == "message_start":
- msg = chunk.get("message") or {}
+ msg: Dict[str, Any] = cast(Dict[str, Any], chunk.get("message") or {})
u = msg.get("usage")
if isinstance(u, dict):
start_usage_snapshot = dict(u)
@@ -588,7 +588,7 @@ class AmazonAnthropicClaudeMessagesConfig(
continue
if chunk_type == "message_delta":
- pending_delta = chunk
+ pending_delta = cast(Dict[str, Any], chunk)
continue
if chunk_type == "message_stop" and pending_delta is not None: