Home / Function/ _convert_from_v1_to_chat_completions() — langchain Function Reference

_convert_from_v1_to_chat_completions() — langchain Function Reference

Architecture documentation for the _convert_from_v1_to_chat_completions() function in _compat.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  f7e0aa63_13ec_ed44_6e41_8bf9ba654f8d["_convert_from_v1_to_chat_completions()"]
  96a695f6_cd7a_174b_bf5b_d9f9f17f2408["_compat.py"]
  f7e0aa63_13ec_ed44_6e41_8bf9ba654f8d -->|defined in| 96a695f6_cd7a_174b_bf5b_d9f9f17f2408
  style f7e0aa63_13ec_ed44_6e41_8bf9ba654f8d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/fireworks/langchain_fireworks/_compat.py lines 8–26

def _convert_from_v1_to_chat_completions(message: AIMessage) -> AIMessage:
    """Convert a v1 message to the Chat Completions format."""
    if isinstance(message.content, list):
        new_content: list = []
        for block in message.content:
            if isinstance(block, dict):
                block_type = block.get("type")
                if block_type == "text":
                    # Strip annotations
                    new_content.append({"type": "text", "text": block["text"]})
                elif block_type in ("reasoning", "tool_call"):
                    pass
                else:
                    new_content.append(block)
            else:
                new_content.append(block)
        return message.model_copy(update={"content": new_content})

    return message

Domain

Subdomains

Frequently Asked Questions

What does _convert_from_v1_to_chat_completions() do?
_convert_from_v1_to_chat_completions() is a function in the langchain codebase, defined in libs/partners/fireworks/langchain_fireworks/_compat.py.
Where is _convert_from_v1_to_chat_completions() defined?
_convert_from_v1_to_chat_completions() is defined in libs/partners/fireworks/langchain_fireworks/_compat.py at line 8.

Analyze Your Own Codebase

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

Try Supermodel Free