test__convert_dict_to_message_tool_call() — langchain Function Reference
Architecture documentation for the test__convert_dict_to_message_tool_call() function in test_chat_models.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 46a83929_9aec_1cf3_a4c9_4354ba64b86f["test__convert_dict_to_message_tool_call()"] aaa4b344_20ed_7fa3_4067_f8f05affc01f["test_chat_models.py"] 46a83929_9aec_1cf3_a4c9_4354ba64b86f -->|defined in| aaa4b344_20ed_7fa3_4067_f8f05affc01f style 46a83929_9aec_1cf3_a4c9_4354ba64b86f fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/mistralai/tests/unit_tests/test_chat_models.py lines 170–238
def test__convert_dict_to_message_tool_call() -> None:
raw_tool_call = {
"id": "ssAbar4Dr",
"function": {
"arguments": '{"name": "Sally", "hair_color": "green"}',
"name": "GenerateUsername",
},
}
message = {"role": "assistant", "content": "", "tool_calls": [raw_tool_call]}
result = _convert_mistral_chat_message_to_message(message)
expected_output = AIMessage(
content="",
additional_kwargs={"tool_calls": [raw_tool_call]},
tool_calls=[
ToolCall(
name="GenerateUsername",
args={"name": "Sally", "hair_color": "green"},
id="ssAbar4Dr",
type="tool_call",
)
],
response_metadata={"model_provider": "mistralai"},
)
assert result == expected_output
assert _convert_message_to_mistral_chat_message(expected_output) == message
# Test malformed tool call
raw_tool_calls = [
{
"id": "pL5rEGzxe",
"function": {
"arguments": '{"name": "Sally", "hair_color": "green"}',
"name": "GenerateUsername",
},
},
{
"id": "ssAbar4Dr",
"function": {
"arguments": "oops",
"name": "GenerateUsername",
},
},
]
message = {"role": "assistant", "content": "", "tool_calls": raw_tool_calls}
result = _convert_mistral_chat_message_to_message(message)
expected_output = AIMessage(
content="",
additional_kwargs={"tool_calls": raw_tool_calls},
invalid_tool_calls=[
InvalidToolCall(
name="GenerateUsername",
args="oops",
error="Function GenerateUsername arguments:\n\noops\n\nare not valid JSON. Received JSONDecodeError Expecting value: line 1 column 1 (char 0)\nFor troubleshooting, visit: https://docs.langchain.com/oss/python/langchain/errors/OUTPUT_PARSING_FAILURE ", # noqa: E501
id="ssAbar4Dr",
type="invalid_tool_call",
),
],
tool_calls=[
ToolCall(
name="GenerateUsername",
args={"name": "Sally", "hair_color": "green"},
id="pL5rEGzxe",
type="tool_call",
),
],
response_metadata={"model_provider": "mistralai"},
)
assert result == expected_output
assert _convert_message_to_mistral_chat_message(expected_output) == message
Domain
Subdomains
Source
Frequently Asked Questions
What does test__convert_dict_to_message_tool_call() do?
test__convert_dict_to_message_tool_call() is a function in the langchain codebase, defined in libs/partners/mistralai/tests/unit_tests/test_chat_models.py.
Where is test__convert_dict_to_message_tool_call() defined?
test__convert_dict_to_message_tool_call() is defined in libs/partners/mistralai/tests/unit_tests/test_chat_models.py at line 170.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free