Skip to content

loader

diapason.tools.templates.loader

Template loader — dynamically construct BaseTool from TOML definitions.

ToolTemplate

Bases: BaseTool

A tool dynamically constructed from a TOML template definition.

discover_templates(directory=None)

Discover all TOML templates in a directory.

load_template(path)

Load a single tool template from a TOML file.

safe_eval_expr(expr, names)

Safely evaluate a template python-action expression.

Parses expr and interprets it against the allowlist in :func:_eval_node. No eval/exec is used, and the only callables reachable are :data:_SAFE_EVAL_FUNCS plus the supplied names (the tool parameters). Raises ValueError / SyntaxError on anything unsafe.