Skip to content

Commit

Permalink
Fix mypy 3
Browse files Browse the repository at this point in the history
  • Loading branch information
TaoChenOSU committed Dec 18, 2024
1 parent dfaba4e commit 0ec7c81
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,19 @@ def _format_assistant_message(message: ChatMessageContent) -> dict[str, Any]:
f"Unsupported item type in Assistant message while formatting chat history for Anthropic: {type(item)}"
)

formatted_message: dict[str, str | list] = {"role": "assistant", "content": []}
formatted_message: dict[str, Any] = {"role": "assistant", "content": []}

if message.content:
# Only include the text content if it is not empty.
# Otherwise, the Anthropic client will throw an error.
formatted_message["content"].append({
formatted_message["content"].append({ # type: ignore
"type": "text",
"text": message.content,
})
if tool_calls:
# Only include the tool calls if there are any.
# Otherwise, the Anthropic client will throw an error.
formatted_message["content"].extend(tool_calls)
formatted_message["content"].extend(tool_calls) # type: ignore

return formatted_message

Expand Down

0 comments on commit 0ec7c81

Please sign in to comment.