langchain.chains.openai_functions.base.convert_to_openai_function¶

langchain.chains.openai_functions.base.convert_to_openai_function(function: Union[Dict[str, Any], Type[BaseModel], Callable]) Dict[str, Any][source]¶

Convert a raw function/class to an OpenAI function.

Parameters

function – 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.

Returns

A dict version of the passed in function which is compatible with the

OpenAI function-calling API.