Skip to main content

ToolkitMessageIntegration

init

Initialize the toolkit message integration. Parameters:
  • message_handler (Optional[Callable]): Custom message handler function. If not provided, uses the built-in send_message_to_user. (default: :obj:None)
  • extract_params_callback (Optional[Callable]): Function to extract parameters from kwargs for the custom message handler. Should return a tuple of arguments to pass to the message handler. If not provided, uses default extraction for built-in handler. (default: :obj:None)

_default_extract_params

Default parameter extraction for built-in message handler.

send_message_to_user

Built-in message handler that sends tidy messages to the user. This one-way tool keeps the user informed about agent progress, decisions, or actions. It does not require a response. Parameters:
  • message_title (str): The title of the message.
  • message_description (str): The short description message.
  • message_attachment (str): The additional attachment of the message, which can be a file path or a URL.
Returns: str: Confirmation that the message was successfully sent.

get_message_tool

Returns: FunctionTool: The message sending tool.

register_toolkits

Add messaging capabilities to all toolkit methods. This method modifies a toolkit so that all its tools can send status messages to users while executing their primary function. The tools will accept optional messaging parameters:
  • message_title: Title of the status message
  • message_description: Description of what the tool is doing
  • message_attachment: Optional file path or URL
Parameters:
  • toolkit: The toolkit to add messaging capabilities to
Returns: The same toolkit instance with messaging capabilities added to all methods.

_create_bound_method_wrapper

Create a wrapper that mimics a bound method for _clone_tools. This wrapper preserves the toolkit instance reference while maintaining the enhanced messaging functionality.

register_functions

Add messaging capabilities to a list of functions or FunctionTools. This method enhances functions so they can send status messages to users while executing. The enhanced functions will accept optional messaging parameters that trigger status updates. Parameters:
  • functions (Union[List[FunctionTool], List[Callable]]): List of FunctionTool objects or callable functions to enhance.
  • function_names (Optional[List[str]]): List of specific function names to modify. If None, messaging is added to all functions.
Returns: List[FunctionTool]: List of enhanced FunctionTool objects

_add_messaging_to_tool

Add messaging parameters to a tool function. This internal method modifies the function signature and docstring to include optional messaging parameters that trigger status updates.

_find_docstring_insert_point

Find where to insert parameters in a docstring.

_get_docstring_indent

Get the proper indentation for docstring parameters.

_get_base_indent

Get the base indentation level of the docstring.

_extract_param_docs_from_handler

Extract parameter documentation from the custom handler’s docstring.