_convert_chat_completions_blocks_to_responses() — langchain Function Reference
Architecture documentation for the _convert_chat_completions_blocks_to_responses() function in base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 57d40c25_4875_99e8_1bae_5dd1aad3c2b3["_convert_chat_completions_blocks_to_responses()"] 2b046911_ea21_8e2e_ba0d_9d03da8d7bda["base.py"] 57d40c25_4875_99e8_1bae_5dd1aad3c2b3 -->|defined in| 2b046911_ea21_8e2e_ba0d_9d03da8d7bda b1594e89_965d_0f6c_e9b0_511a58b3e737["_ensure_valid_tool_message_content()"] b1594e89_965d_0f6c_e9b0_511a58b3e737 -->|calls| 57d40c25_4875_99e8_1bae_5dd1aad3c2b3 b988bc7d_ceff_06f1_193c_a22abc7a149f["_construct_responses_api_input()"] b988bc7d_ceff_06f1_193c_a22abc7a149f -->|calls| 57d40c25_4875_99e8_1bae_5dd1aad3c2b3 style 57d40c25_4875_99e8_1bae_5dd1aad3c2b3 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/openai/langchain_openai/chat_models/base.py lines 3979–4002
def _convert_chat_completions_blocks_to_responses(
block: dict[str, Any],
) -> dict[str, Any]:
"""Convert chat completions content blocks to Responses API format.
Only handles text, image, file blocks. Others pass through.
"""
if block["type"] == "text":
# chat api: {"type": "text", "text": "..."}
# responses api: {"type": "input_text", "text": "..."}
return {"type": "input_text", "text": block["text"]}
if block["type"] == "image_url":
# chat api: {"type": "image_url", "image_url": {"url": "...", "detail": "..."}} # noqa: E501
# responses api: {"type": "image_url", "image_url": "...", "detail": "...", "file_id": "..."} # noqa: E501
new_block = {
"type": "input_image",
"image_url": block["image_url"]["url"],
}
if block["image_url"].get("detail"):
new_block["detail"] = block["image_url"]["detail"]
return new_block
if block["type"] == "file":
return {"type": "input_file", **block["file"]}
return block
Domain
Subdomains
Source
Frequently Asked Questions
What does _convert_chat_completions_blocks_to_responses() do?
_convert_chat_completions_blocks_to_responses() is a function in the langchain codebase, defined in libs/partners/openai/langchain_openai/chat_models/base.py.
Where is _convert_chat_completions_blocks_to_responses() defined?
_convert_chat_completions_blocks_to_responses() is defined in libs/partners/openai/langchain_openai/chat_models/base.py at line 3979.
What calls _convert_chat_completions_blocks_to_responses()?
_convert_chat_completions_blocks_to_responses() is called by 2 function(s): _construct_responses_api_input, _ensure_valid_tool_message_content.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free