_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 984ea916_03d4_1a30_682b_78ce105dc2cb["_convert_from_v1_to_chat_completions()"] 92333051_7f77_b57b_d874_abb7bac2bbe0["_compat.py"] 984ea916_03d4_1a30_682b_78ce105dc2cb -->|defined in| 92333051_7f77_b57b_d874_abb7bac2bbe0 style 984ea916_03d4_1a30_682b_78ce105dc2cb fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/openai/langchain_openai/chat_models/_compat.py lines 154–172
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
Source
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/openai/langchain_openai/chat_models/_compat.py.
Where is _convert_from_v1_to_chat_completions() defined?
_convert_from_v1_to_chat_completions() is defined in libs/partners/openai/langchain_openai/chat_models/_compat.py at line 154.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free