Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions litellm/litellm_core_utils/token_counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ def _count_content_list(
if isinstance(c, str):
num_tokens += count_function(c)
elif c["type"] == "text":
num_tokens += count_function(c.get("text", ""))
num_tokens += count_function(str(c.get("text", "")))
elif c["type"] == "image_url":
image_url = c.get("image_url")
num_tokens += _count_image_tokens(
Expand All @@ -722,7 +722,7 @@ def _count_content_list(
elif c["type"] == "thinking":
# Claude extended thinking content block
# Count the thinking text and skip signature (opaque signature blob)
thinking_text = c.get("thinking", "")
thinking_text = str(c.get("thinking", ""))
if thinking_text:
num_tokens += count_function(thinking_text)
else:
Expand Down
4 changes: 2 additions & 2 deletions litellm/proxy/guardrails/guardrail_hooks/pangea/pangea.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# litellm/proxy/guardrails/guardrail_hooks/pangea.py
import os
from typing import TYPE_CHECKING, Any, Optional, Type
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Type, cast

from fastapi import HTTPException

Expand Down Expand Up @@ -253,7 +253,7 @@ async def _async_post_call_success_hook(
if not isinstance(response, ModelResponse):
return
else:
input_messages = data.get("messages")
input_messages = cast(List[Dict[Any, Any]], data.get("messages"))

if choices := response.get("choices"):
if isinstance(choices, list):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def response_api_handler(
custom_llm_provider=custom_llm_provider,
litellm_metadata=kwargs.get("litellm_metadata", {}),
)
raise ValueError(f"Unexpected response type: {type(litellm_completion_response)}")

async def async_response_api_handler(
self,
Expand Down Expand Up @@ -140,3 +141,4 @@ async def async_response_api_handler(
),
litellm_metadata=kwargs.get("litellm_metadata", {}),
)
raise ValueError(f"Unexpected response type: {type(litellm_completion_response)}")
Loading