cape.agent.tools.toolutils: Common functions for CAPE tool usage¶
This module provides a function wrap_cli() that places several
preprocessing, protection, and postprocessing steps around a tool call
eminated by an LLM.
This includes normalizing the arguments, e.g. replacing the string
"true" with the Python value True, removing any keyword
arguments set to None, capturing STDOUT, and more.
- class cape.agent.tools.toolutils.Tee(*streams)¶
Class to simultaneously capture and display STDOUT
- Call:
>>> tee = Tee(*streams)
- Inputs:
- streams:
tuple[io.IOBase] List of streams to capture/display
- streams:
- cape.agent.tools.toolutils.normalize_kwargs(kw: dict) dict¶
Filter keyword args to tool, removing
''andNone
- cape.agent.tools.toolutils.normalize_tool_arg(v)¶
Normalize strings of special values to Pythonic values
E.g.
"null"->None
- cape.agent.tools.toolutils.register_module_tools(params: dict)¶
Register
TOOL_SCHEMASandTOOLSto calling module- Call:
>>> register_module_tools(params)
- Inputs:
- params:
dict Dictionary of parameter definitiosn for use in this tool set
- params:
- cape.agent.tools.toolutils.wrap_cli(func: Callable, *a, **kw) dict¶
Run a CAPE command-line tool through
cape.cfdx.cliThis performs several preprocessing, error handling, and postprocessing steps. The output of this function includes the results of the underlying function and appends the returncode. It also captures STDOUT and appends that to the result