Use a tool calling strategy for model responses.
ToolStrategy(
self,
schema: type[SchemaT] | UnionType | dict[str, Any],
*,
tool_message_content: str | None = None,
handle_errors: bool | str | type[Exception] | tuple[type[Exception], ...] | Callable[[Exception], str] = True
)Schema for the tool calls.
Schema specs for the tool calls.
The content of the tool message to be returned when the model calls an artificial structured output tool.
Error handling strategy for structured output via ToolStrategy.
True: Catch all errors with default error templatestr: Catch all errors with this custom messagetype[Exception]: Only catch this exception type with default messagetuple[type[Exception], ...]: Only catch these exception types with default
messageCallable[[Exception], str]: Custom function that returns error messageFalse: No retry, let exceptions propagate