tooluniverse.extended_hooks moduleΒΆ
Extended Hook Types for ToolUniverse
This module demonstrates how to extend the hook system with additional hook types beyond summarization. It shows the pattern for creating new hook types while maintaining compatibility with the existing system.
- class tooluniverse.extended_hooks.FilteringHook[source]ΒΆ
Bases:
OutputHookHook for filtering sensitive or unwanted content from tool outputs.
This hook can be used to: - Remove sensitive information (emails, phones, SSNs) - Filter inappropriate content - Sanitize data before display
- Parameters:
config (
Dict[str, Any]) β Hook configuration containing filter settingstooluniverse β Optional ToolUniverse instance (not used for filtering)
- __init__(config, tooluniverse=None)[source]ΒΆ
Initialize the filtering hook with configuration.
- Parameters:
config (
Dict[str, Any]) β Hook configurationtooluniverse β ToolUniverse instance (optional, not used)
- process(result, tool_name, arguments, context)[source]ΒΆ
Apply filtering to the tool output.
- Parameters:
result (
Any) β The tool output to filtertool_name (
str) β Name of the tool that produced the outputarguments (
Dict[str, Any]) β Arguments passed to the toolcontext (
Dict[str, Any]) β Additional context information
- Returns
Any: The filtered output, or original output if filtering fails
- class tooluniverse.extended_hooks.FormattingHook[source]ΒΆ
Bases:
OutputHookHook for formatting and beautifying tool outputs.
This hook can be used to: - Pretty-print JSON/XML outputs - Format text with proper indentation - Standardize output formats
- Parameters:
config (
Dict[str, Any]) β Hook configuration containing formatting settingstooluniverse β Optional ToolUniverse instance (not used for formatting)
- __init__(config, tooluniverse=None)[source]ΒΆ
Initialize the formatting hook with configuration.
- Parameters:
config (
Dict[str, Any]) β Hook configurationtooluniverse β ToolUniverse instance (optional, not used)
- process(result, tool_name, arguments, context)[source]ΒΆ
Apply formatting to the tool output.
- Parameters:
result (
Any) β The tool output to formattool_name (
str) β Name of the tool that produced the outputarguments (
Dict[str, Any]) β Arguments passed to the toolcontext (
Dict[str, Any]) β Additional context information
- Returns
Any: The formatted output, or original output if formatting fails
- class tooluniverse.extended_hooks.ValidationHook[source]ΒΆ
Bases:
OutputHookHook for validating tool outputs against schemas or rules.
This hook can be used to: - Validate JSON against schemas - Check required fields - Ensure data quality
- Parameters:
config (
Dict[str, Any]) β Hook configuration containing validation settingstooluniverse β Optional ToolUniverse instance (not used for validation)
- __init__(config, tooluniverse=None)[source]ΒΆ
Initialize the validation hook with configuration.
- Parameters:
config (
Dict[str, Any]) β Hook configurationtooluniverse β ToolUniverse instance (optional, not used)
- process(result, tool_name, arguments, context)[source]ΒΆ
Apply validation to the tool output.
- Parameters:
result (
Any) β The tool output to validatetool_name (
str) β Name of the tool that produced the outputarguments (
Dict[str, Any]) β Arguments passed to the toolcontext (
Dict[str, Any]) β Additional context information
- Returns
Any: The validated output, or original output if validation fails
- class tooluniverse.extended_hooks.LoggingHook[source]ΒΆ
Bases:
OutputHookHook for logging tool outputs and execution details.
This hook can be used to: - Log all tool outputs - Track execution metrics - Audit tool usage
- Parameters:
config (
Dict[str, Any]) β Hook configuration containing logging settingstooluniverse β Optional ToolUniverse instance (not used for logging)
- __init__(config, tooluniverse=None)[source]ΒΆ
Initialize the logging hook with configuration.
- Parameters:
config (
Dict[str, Any]) β Hook configurationtooluniverse β ToolUniverse instance (optional, not used)
- process(result, tool_name, arguments, context)[source]ΒΆ
Log the tool output and execution details.
- Parameters:
result (
Any) β The tool output to logtool_name (
str) β Name of the tool that produced the outputarguments (
Dict[str, Any]) β Arguments passed to the toolcontext (
Dict[str, Any]) β Additional context information
- Returns
Any: The original output (logging doesnβt modify the output)