Remove unnecessary typing casts in anthropic (#143447)

This commit is contained in:
Marc Mueller 2025-04-22 14:05:59 +02:00 committed by GitHub
parent ccd1a08aca
commit fa4e0519fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -265,21 +265,21 @@ async def _transform_stream(
if current_block is None: if current_block is None:
raise ValueError("Unexpected stop event without a current block") raise ValueError("Unexpected stop event without a current block")
if current_block["type"] == "tool_use": if current_block["type"] == "tool_use":
tool_block = cast(ToolUseBlockParam, current_block) # tool block
tool_args = json.loads(current_tool_args) if current_tool_args else {} tool_args = json.loads(current_tool_args) if current_tool_args else {}
tool_block["input"] = tool_args current_block["input"] = tool_args
yield { yield {
"tool_calls": [ "tool_calls": [
llm.ToolInput( llm.ToolInput(
id=tool_block["id"], id=current_block["id"],
tool_name=tool_block["name"], tool_name=current_block["name"],
tool_args=tool_args, tool_args=tool_args,
) )
] ]
} }
elif current_block["type"] == "thinking": elif current_block["type"] == "thinking":
thinking_block = cast(ThinkingBlockParam, current_block) # thinking block
LOGGER.debug("Thinking: %s", thinking_block["thinking"]) LOGGER.debug("Thinking: %s", current_block["thinking"])
if current_message is None: if current_message is None:
raise ValueError("Unexpected stop event without a current message") raise ValueError("Unexpected stop event without a current message")