tooluniverse.base_tool moduleΒΆ

tooluniverse.base_tool.extract_function_call_json(lst, return_message=False, verbose=True, format='llama')[source][source]ΒΆ
tooluniverse.base_tool.evaluate_function_call(tool_definition, function_call)[source][source]ΒΆ
class tooluniverse.base_tool.Path(*args, **kwargs)[source][source]ΒΆ

Bases: PurePath

PurePath subclass that can make system calls.

Path represents a filesystem path but unlike PurePath, also offers methods to do system calls on path objects. Depending on your system, instantiating a Path will return either a PosixPath or a WindowsPath object. You can also instantiate a PosixPath or WindowsPath directly, but cannot instantiate a WindowsPath on a POSIX system or vice versa.

classmethod cwd()[source][source]ΒΆ

Return a new path pointing to the current working directory (as returned by os.getcwd()).

classmethod home()[source][source]ΒΆ

Return a new path pointing to the user’s home directory (as returned by os.path.expanduser(β€˜~’)).

samefile(other_path)[source][source]ΒΆ

Return whether other_path is the same or not as this file (as returned by os.path.samefile()).

iterdir()[source][source]ΒΆ

Iterate over the files in this directory. Does not yield any result for the special paths β€˜.’ and β€˜..’.

glob(pattern)[source][source]ΒΆ

Iterate over this subtree and yield all existing files (of any kind, including directories) matching the given relative pattern.

rglob(pattern)[source][source]ΒΆ

Recursively yield all existing files (of any kind, including directories) matching the given relative pattern, anywhere in this subtree.

absolute()[source][source]ΒΆ

Return an absolute version of this path. This function works even if the path doesn’t point to anything.

No normalization is done, i.e. all β€˜.’ and β€˜..’ will be kept along. Use resolve() to get the canonical path to a file.

resolve(strict=False)[source][source]ΒΆ

Make the path absolute, resolving all symlinks on the way and also normalizing it (for example turning slashes into backslashes under Windows).

stat(*, follow_symlinks=True)[source][source]ΒΆ

Return the result of the stat() system call on this path, like os.stat() does.

owner()[source][source]ΒΆ

Return the login name of the file owner.

group()[source][source]ΒΆ

Return the group name of the file gid.

open(mode='r', buffering=-1, encoding=None, errors=None, newline=None)[source][source]ΒΆ

Open the file pointed by this path and return a file object, as the built-in open() function does.

read_bytes()[source][source]ΒΆ

Open the file in bytes mode, read it, and close the file.

read_text(encoding=None, errors=None)[source][source]ΒΆ

Open the file in text mode, read it, and close the file.

write_bytes(data)[source][source]ΒΆ

Open the file in bytes mode, write to it, and close the file.

write_text(data, encoding=None, errors=None, newline=None)[source][source]ΒΆ

Open the file in text mode, write to it, and close the file.

Return the path to which the symbolic link points.

touch(mode=438, exist_ok=True)[source][source]ΒΆ

Create this file with the given access mode, if it doesn’t exist.

mkdir(mode=511, parents=False, exist_ok=False)[source][source]ΒΆ

Create a new directory at this given path.

chmod(mode, *, follow_symlinks=True)[source][source]ΒΆ

Change the permissions of the path, like os.chmod().

lchmod(mode)[source][source]ΒΆ

Like chmod(), except if the path points to a symlink, the symlink’s permissions are changed, rather than its target’s.

Remove this file or link. If the path is a directory, use rmdir() instead.

rmdir()[source][source]ΒΆ

Remove this directory. The directory must be empty.

lstat()[source][source]ΒΆ

Like stat(), except if the path points to a symlink, the symlink’s status information is returned, rather than its target’s.

rename(target)[source][source]ΒΆ

Rename this path to the target path.

The target path may be absolute or relative. Relative paths are interpreted relative to the current working directory, not the directory of the Path object.

Returns the new Path instance pointing to the target path.

replace(target)[source][source]ΒΆ

Rename this path to the target path, overwriting if that path exists.

The target path may be absolute or relative. Relative paths are interpreted relative to the current working directory, not the directory of the Path object.

Returns the new Path instance pointing to the target path.

Make this path a symlink pointing to the target path. Note the order of arguments (link, target) is the reverse of os.symlink.

Make this path a hard link pointing to the same file as target.

Note the order of arguments (self, target) is the reverse of os.link’s.

Make the target path a hard link pointing to this path.

Note this function does not make this path a hard link to target, despite the implication of the function and argument names. The order of arguments (target, link) is the reverse of Path.symlink_to, but matches that of os.link.

Deprecated since Python 3.10 and scheduled for removal in Python 3.12. Use hardlink_to() instead.

exists()[source][source]ΒΆ

Whether this path exists.

is_dir()[source][source]ΒΆ

Whether this path is a directory.

is_file()[source][source]ΒΆ

Whether this path is a regular file (also True for symlinks pointing to regular files).

is_mount()[source][source]ΒΆ

Check if this path is a POSIX mount point

Whether this path is a symbolic link.

is_block_device()[source][source]ΒΆ

Whether this path is a block device.

is_char_device()[source][source]ΒΆ

Whether this path is a character device.

is_fifo()[source][source]ΒΆ

Whether this path is a FIFO.

is_socket()[source][source]ΒΆ

Whether this path is a socket.

expanduser()[source][source]ΒΆ

Return a new path with expanded ~ and ~user constructs (as returned by os.path.expanduser)

tooluniverse.base_tool.no_type_check(arg)[source][source]ΒΆ

Decorator to indicate that annotations are not type hints.

The argument must be a class or function; if it is a class, it applies recursively to all methods and classes defined in that class (but not to methods defined in its superclasses or subclasses).

This mutates the function(s) or class(es) in place.

exception tooluniverse.base_tool.ToolExecutionError[source][source]ΒΆ

Bases: Exception

Base exception for tool execution errors.

exception tooluniverse.base_tool.ValidationError[source][source]ΒΆ

Bases: Exception

Exception raised when input validation fails.

exception tooluniverse.base_tool.AuthenticationError[source][source]ΒΆ

Bases: Exception

Exception raised when authentication fails.

exception tooluniverse.base_tool.RateLimitError[source][source]ΒΆ

Bases: Exception

Exception raised when API rate limit is exceeded.

class tooluniverse.base_tool.BaseTool(tool_config)[source][source]ΒΆ

Bases: object

__init__(tool_config)[source][source]ΒΆ
classmethod get_default_config_file()[source][source]ΒΆ

Get the path to the default configuration file for this tool type.

This method uses a robust path resolution strategy that works across different installation scenarios:

  1. Installed packages: Uses importlib.resources for proper package resource access

  2. Development mode: Falls back to file-based path resolution

  3. Legacy Python: Handles importlib.resources and importlib_resources

Override this method in subclasses to specify a custom defaults file.

Returns:

Path or resource object pointing to the defaults file

classmethod load_defaults_from_file()[source][source]ΒΆ

Load defaults from the configuration file

run(arguments=None)[source][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.

check_function_call(function_call_json)[source][source]ΒΆ
get_required_parameters()[source][source]ΒΆ

Retrieve required parameters from the endpoint definition. Returns: list: List of required parameters for the given endpoint.