The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
langchain-core: Add image_generation tool to list of known openai tools (#31396)
Eugene Yurtseve6633a7efb10
diff --git a/libs/core/langchain_core/utils/function_calling.py b/libs/core/langchain_core/utils/function_calling.pyindex 61b705e4ac..0c3e2b88cd 100644--- a/libs/core/langchain_core/utils/function_calling.py+++ b/libs/core/langchain_core/utils/function_calling.py@@ -506,6 +506,20 @@ def convert_to_openai_function(return oai_function+# List of well known tools supported by OpenAI's chat models or responses API.+# These tools are not expected to be supported by other chat model providers+# that conform to the OpenAI function-calling API.+_WellKnownOpenAITools = (+ "function",+ "file_search",+ "computer_use_preview",+ "code_interpreter",+ "mcp",+ "image_generation",+ "web_search_preview",+)++def convert_to_openai_tool(tool: Union[dict[str, Any], type[BaseModel], Callable, BaseTool],*,@@ -558,15 +572,13 @@ def convert_to_openai_tool(.. versionchanged:: 0.3.61Added support for OpenAI's built-in code interpreter and remote MCP tools.++ .. versionchanged:: 0.3.63++ Added support for OpenAI's image generation built-in tool."""if isinstance(tool, dict):- if tool.get("type") in (- "function",- "file_search",- "computer_use_preview",- "code_interpreter",- "mcp",- ):+ if tool.get("type") in _WellKnownOpenAITools:return tool# As of 03.12.25 can be "web_search_preview" or "web_search_preview_2025_03_11"if (tool.get("type") or "").startswith("web_search_preview"):