test__construct_responses_api_input_ai_message_with_tool_calls_and_content() — langchain Function Reference
Architecture documentation for the test__construct_responses_api_input_ai_message_with_tool_calls_and_content() function in test_base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 374381c2_a40a_3f68_616f_b8c8d443969a["test__construct_responses_api_input_ai_message_with_tool_calls_and_content()"] 48232d20_f8c1_b597_14fa_7dc407e9bfe5["test_base.py"] 374381c2_a40a_3f68_616f_b8c8d443969a -->|defined in| 48232d20_f8c1_b597_14fa_7dc407e9bfe5 style 374381c2_a40a_3f68_616f_b8c8d443969a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/openai/tests/unit_tests/chat_models/test_base.py lines 2248–2317
def test__construct_responses_api_input_ai_message_with_tool_calls_and_content() -> (
None
):
"""Test that AI messages with both tool calls and content are properly converted."""
tool_calls = [
{
"id": "call_123",
"name": "get_weather",
"args": {"location": "San Francisco"},
"type": "tool_call",
}
]
# Content blocks
ai_message = AIMessage(
content=[
{"type": "text", "text": "I'll check the weather for you."},
{
"type": "function_call",
"name": "get_weather",
"arguments": '{"location": "San Francisco"}',
"call_id": "call_123",
"id": "fc_456",
},
],
tool_calls=tool_calls,
)
result = _construct_responses_api_input([ai_message])
assert len(result) == 2
assert result[0]["role"] == "assistant"
assert result[0]["content"] == [
{
"type": "output_text",
"text": "I'll check the weather for you.",
"annotations": [],
}
]
assert result[1]["type"] == "function_call"
assert result[1]["name"] == "get_weather"
assert result[1]["arguments"] == '{"location": "San Francisco"}'
assert result[1]["call_id"] == "call_123"
assert result[1]["id"] == "fc_456"
# String content
ai_message = AIMessage(
content="I'll check the weather for you.", tool_calls=tool_calls
)
result = _construct_responses_api_input([ai_message])
assert len(result) == 2
assert result[0]["role"] == "assistant"
assert result[0]["content"] == [
{
"type": "output_text",
"text": "I'll check the weather for you.",
"annotations": [],
}
]
assert result[1]["type"] == "function_call"
assert result[1]["name"] == "get_weather"
assert result[1]["arguments"] == '{"location": "San Francisco"}'
assert result[1]["call_id"] == "call_123"
assert "id" not in result[1]
Domain
Subdomains
Source
Frequently Asked Questions
What does test__construct_responses_api_input_ai_message_with_tool_calls_and_content() do?
test__construct_responses_api_input_ai_message_with_tool_calls_and_content() is a function in the langchain codebase, defined in libs/partners/openai/tests/unit_tests/chat_models/test_base.py.
Where is test__construct_responses_api_input_ai_message_with_tool_calls_and_content() defined?
test__construct_responses_api_input_ai_message_with_tool_calls_and_content() is defined in libs/partners/openai/tests/unit_tests/chat_models/test_base.py at line 2248.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free