convert_to_json_schema#

langchain_core.utils.function_calling.convert_to_json_schema(
schema: dict[str, Any] | type[BaseModel] | Callable | BaseTool,
*,
strict: bool | None = None,
) dict[str, Any][source]#

Convert a schema representation to a JSON schema.

Parameters:
  • schema (Union[dict[str, Any], type[BaseModel], Callable, BaseTool]) – The schema to convert.

  • strict (Optional[bool]) – If True, model output is guaranteed to exactly match the JSON Schema provided in the function definition. If None, strict argument will not be included in function definition.

Raises:

ValueError – If the input is not a valid OpenAI-format tool.

Returns:

A JSON schema representation of the input schema.

Return type:

dict[str, Any]