Expand description
Tool helpers for ergonomic tool use with the ModelRelay API.
Structs§
- Retry
Options - Options for the
execute_with_retryfunction. - Tool
Args Error - Error returned when tool argument parsing or validation fails. Contains a descriptive message suitable for sending back to the model.
- Tool
Call Accumulator - Accumulates streaming tool call deltas into complete tool calls.
- Tool
Execution Result - Result of executing a tool call.
- Tool
Registry - Registry for mapping tool names to handler functions with automatic dispatch.
- Unknown
Tool Error - Error returned when a tool is not found in the registry.
Traits§
- Proxy
Response Ext - Extension trait for ProxyResponse with tool-related convenience methods.
- Tool
Schema - Trait extension for types that implement
JsonSchemato easily convert to a Tool. - Validate
Args - Trait for types that can validate themselves after parsing.
Functions§
- assistant_
message_ with_ tool_ calls - Creates an assistant message that includes tool calls.
- create_
retry_ messages - Creates tool result messages for retryable errors, suitable for sending back to the model to prompt a retry.
- execute_
with_ retry - Executes tool calls with automatic retry for malformed arguments.
- format_
tool_ error_ for_ model - Formats a tool execution error for sending back to the model.
- function_
tool_ from_ type - Creates a function tool from a type that implements
schemars::JsonSchema. - get_
retryable_ errors - Filters the results to only those with retryable errors.
- has_
retryable_ errors - Returns true if any of the results have a retryable error.
- parse_
and_ validate_ tool_ args - Parses, deserializes, and validates tool call arguments.
- parse_
tool_ args - Parses and deserializes tool call arguments into the specified type.
- respond_
to_ tool_ call - Creates a tool result message from a ToolCall.
- respond_
to_ tool_ call_ json - Creates a tool result message from a ToolCall with JSON serialization.
- sync_
handler - Creates a tool handler from a synchronous function. The function receives parsed JSON arguments and returns a JSON-serializable result.
- tool_
result_ message - Creates a message containing the result of a tool call.
- tool_
result_ message_ json - Creates a tool result message with JSON serialization.
Type Aliases§
- BoxFuture
- A boxed future type for async tool handlers.
- Parse
Result - Result type for try_parse_tool_args.
- Tool
Handler - Handler function type for tool execution. Receives parsed JSON arguments and the original tool call. Returns a JSON-serializable result or an error message.