05 Custom Tool#

Script: example/05_custom_tool.py.

This script implements a deterministic calculator by subclassing FlowToolCall. The model chooses when to call it; the tool itself is local Python code.

python example/05_custom_tool.py

Method/member

Role

name

OpenAI function tool name.

description

Model-visible tool description.

parameters

JSON Schema, generated from a Pydantic model.

__call__(session, arguments)

Runtime execution.

parallel_safe=True

Lets the async runtime group this pure tool separately.

The script avoids eval; it parses arithmetic with ast and a small operator whitelist.

← Runnable Examples