_convert_v0_multimodal_input_to_v1() — langchain Function Reference
Architecture documentation for the _convert_v0_multimodal_input_to_v1() function in langchain_v0.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 71fb136f_796d_6fe7_c8d9_6c4ff1cc0f6c["_convert_v0_multimodal_input_to_v1()"] 6202583c_37a6_480c_818f_b5208f8a139b["langchain_v0.py"] 71fb136f_796d_6fe7_c8d9_6c4ff1cc0f6c -->|defined in| 6202583c_37a6_480c_818f_b5208f8a139b ef7d41a4_bbf4_2735_a620_a13b2b356420["_convert_legacy_v0_content_block_to_v1()"] 71fb136f_796d_6fe7_c8d9_6c4ff1cc0f6c -->|calls| ef7d41a4_bbf4_2735_a620_a13b2b356420 style 71fb136f_796d_6fe7_c8d9_6c4ff1cc0f6c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/messages/block_translators/langchain_v0.py lines 8–43
def _convert_v0_multimodal_input_to_v1(
content: list[types.ContentBlock],
) -> list[types.ContentBlock]:
"""Convert v0 multimodal blocks to v1 format.
During the `content_blocks` parsing process, we wrap blocks not recognized as a v1
block as a `'non_standard'` block with the original block stored in the `value`
field. This function attempts to unpack those blocks and convert any v0 format
blocks to v1 format.
If conversion fails, the block is left as a `'non_standard'` block.
Args:
content: List of content blocks to process.
Returns:
v1 content blocks.
"""
converted_blocks = []
unpacked_blocks: list[dict[str, Any]] = [
cast("dict[str, Any]", block)
if block.get("type") != "non_standard"
else block["value"] # type: ignore[typeddict-item] # this is only non-standard blocks
for block in content
]
for block in unpacked_blocks:
if block.get("type") in {"image", "audio", "file"} and "source_type" in block:
converted_block = _convert_legacy_v0_content_block_to_v1(block)
converted_blocks.append(cast("types.ContentBlock", converted_block))
elif block.get("type") in types.KNOWN_BLOCK_TYPES:
# Guard in case this function is used outside of the .content_blocks flow
converted_blocks.append(cast("types.ContentBlock", block))
else:
converted_blocks.append({"type": "non_standard", "value": block})
return converted_blocks
Domain
Subdomains
Source
Frequently Asked Questions
What does _convert_v0_multimodal_input_to_v1() do?
_convert_v0_multimodal_input_to_v1() is a function in the langchain codebase, defined in libs/core/langchain_core/messages/block_translators/langchain_v0.py.
Where is _convert_v0_multimodal_input_to_v1() defined?
_convert_v0_multimodal_input_to_v1() is defined in libs/core/langchain_core/messages/block_translators/langchain_v0.py at line 8.
What does _convert_v0_multimodal_input_to_v1() call?
_convert_v0_multimodal_input_to_v1() calls 1 function(s): _convert_legacy_v0_content_block_to_v1.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free