mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-12 23:01:41 +00:00
fix: coerce server_tool_use dict to ServerToolUse in stream_chunk_builder
When streaming Anthropic responses with web_search_options, stream_chunk_builder reconstructs usage.server_tool_use as a dict rather than a ServerToolUse pydantic object. This causes AttributeError when completion_cost() accesses .web_search_requests on the dict. Apply the same dict-to-object coercion pattern already used for prompt_tokens_details. Fixes #26153
This commit is contained in:
parent
26fcbc93e5
commit
c7522a29d1
1 changed files with 4 additions and 1 deletions
|
|
@ -587,7 +587,10 @@ class ChunkProcessor:
|
|||
hasattr(usage_chunk, "server_tool_use")
|
||||
and usage_chunk.server_tool_use is not None
|
||||
):
|
||||
server_tool_use = usage_chunk.server_tool_use
|
||||
_stu = usage_chunk.server_tool_use
|
||||
server_tool_use = (
|
||||
ServerToolUse(**_stu) if isinstance(_stu, dict) else _stu
|
||||
)
|
||||
if (
|
||||
usage_chunk_dict["prompt_tokens_details"] is not None
|
||||
and getattr(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue