tooluniverse.agentic_tool moduleΒΆ

class tooluniverse.agentic_tool.AgenticTool[source]ΒΆ

Bases: BaseTool

Generic wrapper around LLM prompting supporting JSON-defined configs with prompts and input arguments.

STREAM_FLAG_KEY = '_tooluniverse_stream'ΒΆ
static has_any_api_keys()[source]ΒΆ

Check if any API keys are available across all supported API types.

Returns:

True if at least one API type has all required keys, False otherwise

Return type:

bool

__init__(tool_config)[source]ΒΆ
name: strΒΆ
_prompt_template: strΒΆ
_input_arguments: List[str]ΒΆ
_required_arguments: List[str]ΒΆ
_argument_defaults: Dict[str, str]ΒΆ
_api_type: strΒΆ
_model_id: strΒΆ
_temperature: float | NoneΒΆ
_max_new_tokens: int | NoneΒΆ
_return_json: boolΒΆ
_max_retries: intΒΆ
_retry_delay: intΒΆ
return_metadata: boolΒΆ
_validate_api_key: boolΒΆ
_fallback_api_type: str | NoneΒΆ
_fallback_model_id: str | NoneΒΆ
_use_global_fallback: boolΒΆ
_global_fallback_chain: List[Dict[str, str]]ΒΆ
_gemini_model_id: strΒΆ
_get_global_fallback_chain()[source]ΒΆ

Get the global fallback chain from environment or use default.

_try_initialize_api()[source]ΒΆ

Try to initialize the primary API, fallback to secondary if configured.

_try_api(api_type, model_id, server_url=None)[source]ΒΆ

Try to initialize a specific API and model.

_validate_model_config()[source]ΒΆ
run(arguments, stream_callback=None)[source]ΒΆ

Execute the tool.

The default BaseTool implementation accepts an optional arguments mapping to align with most concrete tool implementations which expect a dictionary of inputs.

Parameters:
  • arguments (dict, optional) – Tool-specific arguments

  • stream_callback (callable, optional) – Callback for streaming responses

  • use_cache (bool, optional) – Whether result caching is enabled

  • validate (bool, optional) – Whether parameter validation was performed

Note

These additional parameters (stream_callback, use_cache, validate) are passed from run_one_function() to provide context about the execution. Tools can use these for optimization or special handling.

For backward compatibility, tools that don’t accept these parameters will still work - they will only receive the arguments parameter.

static _iter_chunks(text, size=800)[source]ΒΆ
_emit_stream_chunk(chunk, stream_callback)[source]ΒΆ
_validate_arguments(arguments)[source]ΒΆ
_format_prompt(arguments)[source]ΒΆ
get_prompt_preview(arguments)[source]ΒΆ
get_model_info()[source]ΒΆ
is_available()[source]ΒΆ

Check if the tool is available for use.

get_availability_status()[source]ΒΆ

Get detailed availability status of the tool.

retry_initialization()[source]ΒΆ

Attempt to reinitialize the tool (useful if API keys were updated).

get_prompt_template()[source]ΒΆ
get_input_arguments()[source]ΒΆ
validate_configuration()[source]ΒΆ
estimate_token_usage(arguments)[source]ΒΆ
_cached_version_hash: str | NoneΒΆ