mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-14 23:21:35 +00:00
refactor(token-counter): avoid redundant empty-text guards
This commit is contained in:
parent
ec3368bcd5
commit
af81c16019
1 changed files with 2 additions and 6 deletions
|
|
@ -892,13 +892,9 @@ 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 = str(c.get("thinking", ""))
|
||||
if thinking_text:
|
||||
num_tokens += count_function(thinking_text)
|
||||
num_tokens += count_function(str(c.get("thinking", "")))
|
||||
elif c["type"] == "reasoning":
|
||||
num_tokens += sum(
|
||||
count_function(text) for summary in c.get("summary", ()) if (text := summary.get("text"))
|
||||
)
|
||||
num_tokens += sum(count_function(summary.get("text", "")) for summary in c.get("summary", ()))
|
||||
elif c["type"] == "tool_reference":
|
||||
# Anthropic tool-search reference block: a lightweight pointer to
|
||||
# a deferred tool, e.g. {"type": "tool_reference", "tool_name": ...}.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue