Home / Function/ translate_content_chunk() — langchain Function Reference

translate_content_chunk() — langchain Function Reference

Architecture documentation for the translate_content_chunk() function in openai.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  108d3f87_48ae_3513_b686_eca17b966d18["translate_content_chunk()"]
  3f58992c_878c_57d1_7412_5e64743aa7ba["openai.py"]
  108d3f87_48ae_3513_b686_eca17b966d18 -->|defined in| 3f58992c_878c_57d1_7412_5e64743aa7ba
  5ae47888_fb2c_d35d_36a3_9d490f02a790["_convert_to_v1_from_chat_completions_chunk()"]
  108d3f87_48ae_3513_b686_eca17b966d18 -->|calls| 5ae47888_fb2c_d35d_36a3_9d490f02a790
  6dd0c2f6_197f_5200_610f_82ef7e9b8132["_convert_from_v03_ai_message()"]
  108d3f87_48ae_3513_b686_eca17b966d18 -->|calls| 6dd0c2f6_197f_5200_610f_82ef7e9b8132
  24124a46_40a1_1ce3_a730_b36c3f9a0520["_convert_to_v1_from_responses()"]
  108d3f87_48ae_3513_b686_eca17b966d18 -->|calls| 24124a46_40a1_1ce3_a730_b36c3f9a0520
  style 108d3f87_48ae_3513_b686_eca17b966d18 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/messages/block_translators/openai.py lines 1008–1020

def translate_content_chunk(message: AIMessageChunk) -> list[types.ContentBlock]:
    """Derive standard content blocks from a message chunk with OpenAI content.

    Args:
        message: The message chunk to translate.

    Returns:
        The derived content blocks.
    """
    if isinstance(message.content, str):
        return _convert_to_v1_from_chat_completions_chunk(message)
    message = _convert_from_v03_ai_message(message)  # type: ignore[assignment]
    return _convert_to_v1_from_responses(message)

Domain

Subdomains

Frequently Asked Questions

What does translate_content_chunk() do?
translate_content_chunk() is a function in the langchain codebase, defined in libs/core/langchain_core/messages/block_translators/openai.py.
Where is translate_content_chunk() defined?
translate_content_chunk() is defined in libs/core/langchain_core/messages/block_translators/openai.py at line 1008.
What does translate_content_chunk() call?
translate_content_chunk() calls 3 function(s): _convert_from_v03_ai_message, _convert_to_v1_from_chat_completions_chunk, _convert_to_v1_from_responses.

Analyze Your Own Codebase

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

Try Supermodel Free