Tools¶
BaseTool¶
nirvana.executors.tools.BaseTool(**kwargs)
¶
Bases: ABC
Source code in nirvana/executors/tools.py
FunctionCallTool¶
nirvana.executors.tools.FunctionCallTool(name: str | None = None, func: Callable | None = None, coroutine: Callable[..., Awaitable[Any]] | None = None, **kwargs)
¶
Bases: BaseTool
Source code in nirvana/executors/tools.py
Attributes¶
description = 'This is a tool that evaluates python code. It can be used to perform calculations.'
class-attribute
instance-attribute
¶
name = name
instance-attribute
¶
func = func
instance-attribute
¶
coroutine = coroutine
instance-attribute
¶
Functions¶
__repr__() -> str
¶
__str__() -> str
¶
from_function(func: Callable | None = None, coroutine: Callable[..., Awaitable[Any]] | None = None, name: str | None = None)
classmethod
¶
Source code in nirvana/executors/tools.py
PythonInterpreterTool¶
nirvana.executors.tools.PythonInterpreterTool(authorized_imports: list[str] | None = None, max_print_outputs_length: int = 50000, **kwargs)
¶
Bases: BaseTool
Source code in nirvana/executors/tools.py
Attributes¶
name = 'python_interpreter'
class-attribute
instance-attribute
¶
description = 'Python Interpreter that runs code in a sandboxed environment'
class-attribute
instance-attribute
¶
authorized_imports = authorized_imports or []
instance-attribute
¶
max_print_outputs_length = max_print_outputs_length
instance-attribute
¶
Functions¶
execute(code: str, variables: dict[str, Any] | None = None) -> str
¶
Execute Python code in a sandboxed environment.
- Captures anything printed via
print. - If the final statement is an expression and evaluates to a non-None value, that value is printed (like a REPL).
- Returns the full captured stdout as a string (possibly truncated).