langchain_core.utils.function_calling
.convert_to_openai_tool¶
- langchain_core.utils.function_calling.convert_to_openai_tool(tool: Union[Dict[str, Any], Type[BaseModel], Callable, BaseTool]) Dict[str, Any] [source]¶
Convert a raw function/class to an OpenAI tool.
- Parameters
tool – Either a dictionary, a pydantic.BaseModel class, Python function, or BaseTool. If a dictionary is passed in, it is assumed to already be a valid OpenAI tool or OpenAI function.
- Returns
- A dict version of the passed in tool which is compatible with the
OpenAI tool-calling API.