test_convert_to_openai_messages_multimodal() — langchain Function Reference
Architecture documentation for the test_convert_to_openai_messages_multimodal() function in test_utils.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 81ea0d99_d21c_2aca_c62f_39c3129da255["test_convert_to_openai_messages_multimodal()"] ea3f8d89_f44b_6738_3cb9_a740a73cfca4["test_utils.py"] 81ea0d99_d21c_2aca_c62f_39c3129da255 -->|defined in| ea3f8d89_f44b_6738_3cb9_a740a73cfca4 style 81ea0d99_d21c_2aca_c62f_39c3129da255 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/tests/unit_tests/messages/test_utils.py lines 1359–1468
def test_convert_to_openai_messages_multimodal() -> None:
"""v0 and v1 content to OpenAI messages conversion."""
messages = [
HumanMessage(
content=[
# Prior v0 blocks
{"type": "text", "text": "Text message"},
{
"type": "image",
"url": "https://example.com/test.png",
},
{
"type": "image",
"source_type": "base64",
"data": "<base64 string>",
"mime_type": "image/png",
},
{
"type": "file",
"source_type": "base64",
"data": "<base64 string>",
"mime_type": "application/pdf",
"filename": "test.pdf",
},
{
# OpenAI Chat Completions file format
"type": "file",
"file": {
"filename": "draconomicon.pdf",
"file_data": "data:application/pdf;base64,<base64 string>",
},
},
{
"type": "file",
"source_type": "id",
"id": "file-abc123",
},
{
"type": "audio",
"source_type": "base64",
"data": "<base64 string>",
"mime_type": "audio/wav",
},
{
"type": "input_audio",
"input_audio": {
"data": "<base64 string>",
"format": "wav",
},
},
# v1 Additions
{
"type": "image",
"source_type": "url", # backward compatibility v0 block field
"url": "https://example.com/test.png",
},
{
"type": "image",
"base64": "<base64 string>",
"mime_type": "image/png",
},
{
"type": "file",
"base64": "<base64 string>",
"mime_type": "application/pdf",
"filename": "test.pdf", # backward compatibility v0 block field
},
{
"type": "file",
"file_id": "file-abc123",
},
{
"type": "audio",
"base64": "<base64 string>",
"mime_type": "audio/wav",
},
]
)
]
result = convert_to_openai_messages(messages, text_format="block")
assert len(result) == 1
Domain
Subdomains
Source
Frequently Asked Questions
What does test_convert_to_openai_messages_multimodal() do?
test_convert_to_openai_messages_multimodal() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/messages/test_utils.py.
Where is test_convert_to_openai_messages_multimodal() defined?
test_convert_to_openai_messages_multimodal() is defined in libs/core/tests/unit_tests/messages/test_utils.py at line 1359.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free