Test that model can process Anthropic-style message histories.
These message histories will include AIMessage objects with tool_use
content blocks, e.g.,
AIMessage(
[
{"type": "text", "text": "Hmm let me think about that"},
{
"type": "tool_use",
"input": {"fav_color": "green"},
"id": "foo",
"name": "color_picker",
},
]
)
...as well as HumanMessage objects containing tool_result content blocks:
HumanMessage(
[
{
"type": "tool_result",
"tool_use_id": "foo",
"content": [
{
"type": "text",
"text": "green is a great pick! "
"that's my sister's favorite color",
}
],
"is_error": False,
},
{"type": "text", "text": "what's my sister's favorite color"},
]
)
This test should be skipped if the model does not support messages of this form (or doesn't support tool calling generally). See Configuration below.
To disable this test, set supports_anthropic_inputs to False in your
test class:
class TestMyChatModelIntegration(ChatModelIntegrationTests):
@property
def supports_anthropic_inputs(self) -> bool:
return FalseIf this test fails, check that:
tool_calls attribute on AIMessage objects is correctly handled
and passed to the model in an appropriate format.HumanMessages with "tool_result" content blocks are correctly
handled.Otherwise, if Anthropic tool call and result formats are not supported,
set the supports_anthropic_inputs property to False.
test_anthropic_inputs(
self,
model: BaseChatModel,
) -> None