nat.plugins.agno.tool_wrapper#
Attributes#
Functions#
|
Process the result from a function to ensure it's in the expected format. |
|
Execute an Agno tool with the given parameters. |
|
Wraps a NAT Function to be usable as an Agno tool. |
Module Contents#
- logger#
- _tool_call_counters#
- _MAX_EMPTY_CALLS = 1#
- _tool_initialization_done#
- async process_result(result: Any, name: str) str#
Process the result from a function to ensure it’s in the expected format. This function guarantees that the output will be a properly formatted string, suitable for consumption by language models like OpenAI’s API.
Parameters#
- resultAny
The result to process
- namestr
The name of the tool (for logging)
Returns#
str: The processed result as a properly formatted string
- execute_agno_tool(
- name: str,
- coroutine_fn: collections.abc.Callable[Ellipsis, collections.abc.Awaitable[Any]],
- required_fields: list[str],
- loop: asyncio.AbstractEventLoop,
- **kwargs: Any,
Execute an Agno tool with the given parameters.
Parameters#
- namestr
The name of the tool
- coroutine_fnCallable
The async function to invoke
- required_fieldslist[str]
List of required fields for validation
- loopasyncio.AbstractEventLoop
The event loop to use for async execution
- kwargsAny
The arguments to pass to the function
Returns#
The result of the function execution as a string
- agno_tool_wrapper(
- name: str,
- fn: nat.builder.function.Function,
- builder: nat.builder.builder.Builder,
Wraps a NAT Function to be usable as an Agno tool.
This wrapper handles the conversion of async NAT functions to the format expected by Agno tools. It properly handles input schema, descriptions, and async invocation.
Parameters#
- namestr
The name of the tool
- fnFunction
The NAT Function to wrap
- builderBuilder
The builder instance
Returns#
A callable that can be used as an Agno tool