Home / Function/ _convert_to_v1_from_bedrock_chunk() — langchain Function Reference

_convert_to_v1_from_bedrock_chunk() — langchain Function Reference

Architecture documentation for the _convert_to_v1_from_bedrock_chunk() function in bedrock.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  bd29f58b_2e57_aab4_0d42_f7236d77befc["_convert_to_v1_from_bedrock_chunk()"]
  1a0b0bf5_99ad_e145_2d19_8867a81352ea["bedrock.py"]
  bd29f58b_2e57_aab4_0d42_f7236d77befc -->|defined in| 1a0b0bf5_99ad_e145_2d19_8867a81352ea
  e580c207_537d_4d21_17c0_7bddc427cac2["translate_content_chunk()"]
  e580c207_537d_4d21_17c0_7bddc427cac2 -->|calls| bd29f58b_2e57_aab4_0d42_f7236d77befc
  style bd29f58b_2e57_aab4_0d42_f7236d77befc fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/messages/block_translators/bedrock.py lines 35–64

def _convert_to_v1_from_bedrock_chunk(
    message: AIMessageChunk,
) -> list[types.ContentBlock]:
    """Convert bedrock message chunk content to v1 format."""
    if (
        message.content == ""
        and not message.additional_kwargs
        and not message.tool_calls
    ):
        # Bedrock outputs multiple chunks containing response metadata
        return []

    out = _convert_to_v1_from_anthropic(message)

    if (
        message.tool_call_chunks
        and not message.content
        and message.chunk_position != "last"  # keep tool_calls if aggregated
    ):
        for tool_call_chunk in message.tool_call_chunks:
            tc: types.ToolCallChunk = {
                "type": "tool_call_chunk",
                "id": tool_call_chunk.get("id"),
                "name": tool_call_chunk.get("name"),
                "args": tool_call_chunk.get("args"),
            }
            if (idx := tool_call_chunk.get("index")) is not None:
                tc["index"] = idx
            out.append(tc)
    return out

Domain

Subdomains

Frequently Asked Questions

What does _convert_to_v1_from_bedrock_chunk() do?
_convert_to_v1_from_bedrock_chunk() is a function in the langchain codebase, defined in libs/core/langchain_core/messages/block_translators/bedrock.py.
Where is _convert_to_v1_from_bedrock_chunk() defined?
_convert_to_v1_from_bedrock_chunk() is defined in libs/core/langchain_core/messages/block_translators/bedrock.py at line 35.
What calls _convert_to_v1_from_bedrock_chunk()?
_convert_to_v1_from_bedrock_chunk() is called by 1 function(s): translate_content_chunk.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free