langchain_core.utils.function_calling
.convert_to_openai_function¶
- langchain_core.utils.function_calling.convert_to_openai_function(function: Union[Dict[str, Any], Type[BaseModel], Callable, BaseTool]) Dict[str, Any] [source]¶
Convert a raw function/class to an OpenAI function.
- Parameters
function (Union[Dict[str, Any], Type[BaseModel], Callable, BaseTool]) – Either a dictionary, a pydantic.BaseModel class, or a Python function. If a dictionary is passed in, it is assumed to already be a valid OpenAI function or a JSON schema with top-level ‘title’ and ‘description’ keys specified.
- Returns
- A dict version of the passed in function which is compatible with the
OpenAI function-calling API.
- Return type
Dict[str, Any]