Home / Function/ register_translator() — langchain Function Reference

register_translator() — langchain Function Reference

Architecture documentation for the register_translator() function in __init__.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  276777d3_5bba_817b_eba3_759dd1de7578["register_translator()"]
  c42572b6_95e3_adf4_9d97_d08f819b3c4c["__init__.py"]
  276777d3_5bba_817b_eba3_759dd1de7578 -->|defined in| c42572b6_95e3_adf4_9d97_d08f819b3c4c
  style 276777d3_5bba_817b_eba3_759dd1de7578 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/messages/block_translators/__init__.py lines 39–54

def register_translator(
    provider: str,
    translate_content: Callable[[AIMessage], list[types.ContentBlock]],
    translate_content_chunk: Callable[[AIMessageChunk], list[types.ContentBlock]],
) -> None:
    """Register content translators for a provider in `PROVIDER_TRANSLATORS`.

    Args:
        provider: The model provider name (e.g. `'openai'`, `'anthropic'`).
        translate_content: Function to translate `AIMessage` content.
        translate_content_chunk: Function to translate `AIMessageChunk` content.
    """
    PROVIDER_TRANSLATORS[provider] = {
        "translate_content": translate_content,
        "translate_content_chunk": translate_content_chunk,
    }

Subdomains

Frequently Asked Questions

What does register_translator() do?
register_translator() is a function in the langchain codebase, defined in libs/core/langchain_core/messages/block_translators/__init__.py.
Where is register_translator() defined?
register_translator() is defined in libs/core/langchain_core/messages/block_translators/__init__.py at line 39.

Analyze Your Own Codebase

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

Try Supermodel Free