Model wrapper that returns outputs formatted to match the given schema.
with_structured_output(
self,
schema: dict | type[BaseModel] | None = None,
*,
method: Literal['function_calling', 'json_mode', 'json_schema'] = 'function_calling',
include_raw: bool = False,
**kwargs: Any = {}
) -> Runnable[LanguageModelInput, dict | BaseModel]| Name | Type | Description |
|---|---|---|
schema | dict | type[BaseModel] | None | Default: NoneThe output schema. Can be passed in as:
Pydantic class is currently supported. |
method | Literal['function_calling', 'json_mode', 'json_schema'] | Default: 'function_calling'The method for steering model generation, one of:
|
include_raw | bool | Default: FalseIf If an error occurs during model output parsing it will be raised. If If an error occurs during output parsing it will be caught and returned as well. The final output is always a |
kwargs | Any | Default: {}Additional parameters to pass to the underlying LLM's
|