test__format_messages_with_tool_calls() — langchain Function Reference
Architecture documentation for the test__format_messages_with_tool_calls() function in test_chat_models.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD caf73c73_7793_c348_561c_9c429ec2a8f8["test__format_messages_with_tool_calls()"] 18428dc5_a41b_90c6_88ad_615296ee3311["test_chat_models.py"] caf73c73_7793_c348_561c_9c429ec2a8f8 -->|defined in| 18428dc5_a41b_90c6_88ad_615296ee3311 style caf73c73_7793_c348_561c_9c429ec2a8f8 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/anthropic/tests/unit_tests/test_chat_models.py lines 530–670
def test__format_messages_with_tool_calls() -> None:
system = SystemMessage("fuzz") # type: ignore[misc]
human = HumanMessage("foo") # type: ignore[misc]
ai = AIMessage(
"", # with empty string
tool_calls=[{"name": "bar", "id": "1", "args": {"baz": "buzz"}}],
)
ai2 = AIMessage(
[], # with empty list
tool_calls=[{"name": "bar", "id": "2", "args": {"baz": "buzz"}}],
)
tool = ToolMessage(
"blurb",
tool_call_id="1",
)
tool_image_url = ToolMessage(
[{"type": "image_url", "image_url": {"url": "data:image/jpeg;base64,...."}}],
tool_call_id="2",
)
tool_image = ToolMessage(
[
{
"type": "image",
"source": {
"data": "....",
"type": "base64",
"media_type": "image/jpeg",
},
},
],
tool_call_id="3",
)
messages = [system, human, ai, tool, ai2, tool_image_url, tool_image]
expected = (
"fuzz",
[
{"role": "user", "content": "foo"},
{
"role": "assistant",
"content": [
{
"type": "tool_use",
"name": "bar",
"id": "1",
"input": {"baz": "buzz"},
},
],
},
{
"role": "user",
"content": [
{
"type": "tool_result",
"content": "blurb",
"tool_use_id": "1",
"is_error": False,
},
],
},
{
"role": "assistant",
"content": [
{
"type": "tool_use",
"name": "bar",
"id": "2",
"input": {"baz": "buzz"},
},
],
},
{
"role": "user",
"content": [
{
"type": "tool_result",
"content": [
{
"type": "image",
"source": {
"data": "....",
"type": "base64",
Domain
Subdomains
Source
Frequently Asked Questions
What does test__format_messages_with_tool_calls() do?
test__format_messages_with_tool_calls() is a function in the langchain codebase, defined in libs/partners/anthropic/tests/unit_tests/test_chat_models.py.
Where is test__format_messages_with_tool_calls() defined?
test__format_messages_with_tool_calls() is defined in libs/partners/anthropic/tests/unit_tests/test_chat_models.py at line 530.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free