tooluniverse.base_tool moduleΒΆ
- tooluniverse.base_tool.extract_function_call_json(lst, return_message=False, verbose=True, format='llama')[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.
- 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_text(encoding=None, errors=None)[source][source]ΒΆ
Open the file in text mode, read 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.
- 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.
- unlink(missing_ok=False)[source][source]ΒΆ
Remove this file or link. If the path is a directory, use rmdir() instead.
- 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.
- symlink_to(target, target_is_directory=False)[source][source]ΒΆ
Make this path a symlink pointing to the target path. Note the order of arguments (link, target) is the reverse of os.symlink.
- hardlink_to(target)[source][source]ΒΆ
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.
- link_to(target)[source][source]ΒΆ
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.
- 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
- 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:
Installed packages: Uses importlib.resources for proper package resource access
Development mode: Falls back to file-based path resolution
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