test_function_calls_with_tool_calls() — langchain Function Reference
Architecture documentation for the test_function_calls_with_tool_calls() function in test_base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD c1582e92_9e79_daaa_c07a_276edd5625e1["test_function_calls_with_tool_calls()"] 48232d20_f8c1_b597_14fa_7dc407e9bfe5["test_base.py"] c1582e92_9e79_daaa_c07a_276edd5625e1 -->|defined in| 48232d20_f8c1_b597_14fa_7dc407e9bfe5 style c1582e92_9e79_daaa_c07a_276edd5625e1 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/openai/tests/unit_tests/chat_models/test_base.py lines 722–763
def test_function_calls_with_tool_calls(mock_client: MagicMock) -> None:
# Test that we ignore function calls if tool_calls are present
llm = ChatOpenAI(model="gpt-4.1-mini")
tool_call_message = AIMessage(
content="",
additional_kwargs={
"function_call": {
"name": "get_weather",
"arguments": '{"location": "Boston"}',
}
},
tool_calls=[
{
"name": "get_weather",
"args": {"location": "Boston"},
"id": "abc123",
"type": "tool_call",
}
],
)
messages = [
HumanMessage("What's the weather in Boston?"),
tool_call_message,
ToolMessage(content="It's sunny.", name="get_weather", tool_call_id="abc123"),
]
with patch.object(llm, "client", mock_client):
_ = llm.invoke(messages)
_, call_kwargs = mock_client.with_raw_response.create.call_args
call_messages = call_kwargs["messages"]
tool_call_message_payload = call_messages[1]
assert "tool_calls" in tool_call_message_payload
assert "function_call" not in tool_call_message_payload
# Test we don't ignore function calls if tool_calls are not present
cast(AIMessage, messages[1]).tool_calls = []
with patch.object(llm, "client", mock_client):
_ = llm.invoke(messages)
_, call_kwargs = mock_client.with_raw_response.create.call_args
call_messages = call_kwargs["messages"]
tool_call_message_payload = call_messages[1]
assert "function_call" in tool_call_message_payload
assert "tool_calls" not in tool_call_message_payload
Domain
Subdomains
Source
Frequently Asked Questions
What does test_function_calls_with_tool_calls() do?
test_function_calls_with_tool_calls() is a function in the langchain codebase, defined in libs/partners/openai/tests/unit_tests/chat_models/test_base.py.
Where is test_function_calls_with_tool_calls() defined?
test_function_calls_with_tool_calls() is defined in libs/partners/openai/tests/unit_tests/chat_models/test_base.py at line 722.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free