The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
openai[patch]: accommodate change in image generation API (#31522)
ccurme575662d5f15f
diff --git a/libs/partners/openai/langchain_openai/chat_models/base.py b/libs/partners/openai/langchain_openai/chat_models/base.pyindex a3a2c39bbc..a1711cd6d7 100644--- a/libs/partners/openai/langchain_openai/chat_models/base.py+++ b/libs/partners/openai/langchain_openai/chat_models/base.py@@ -3116,14 +3116,24 @@ def _construct_responses_api_payload(if tool["type"] == "function" and "function" in tool:new_tools.append({"type": "function", **tool["function"]})else:+ if tool["type"] == "image_generation":+ # Handle partial images (not yet supported)+ if "partial_images" in tool:+ raise NotImplementedError(+ "Partial image generation is not yet supported "+ "via the LangChain ChatOpenAI client. Please "+ "drop the 'partial_images' key from the image_generation "+ "tool."+ )+ elif payload.get("stream") and "partial_images" not in tool:+ # OpenAI requires this parameter be set; we ignore it during+ # streaming.+ tool["partial_images"] = 1+ else:+ pass+new_tools.append(tool)- if tool["type"] == "image_generation" and "partial_images" in tool:- raise NotImplementedError(- "Partial image generation is not yet supported "- "via the LangChain ChatOpenAI client. Please "- "drop the 'partial_images' key from the image_generation tool."- )payload["tools"] = new_toolsif tool_choice := payload.pop("tool_choice", None):# chat api: {"type": "function", "function": {"name": "..."}}diff --git a/libs/partners/openai/tests/cassettes/test_image_generation_streaming.yaml.gz b/libs/partners/openai/tests/cassettes/test_image_generation_streaming.yaml.gzindex 12e6b02347..eac0a3848a 100644Binary files a/libs/partners/openai/tests/cassettes/test_image_generation_streaming.yaml.gz and b/libs/partners/openai/tests/cassettes/test_image_generation_streaming.yaml.gz differ