Decision#

class scikitplot.agent.Decision(kind, action=None, answer=None, rationale='', usage=None)[source]#

What the planner decided: call a tool, or finish with an answer.

Build one with act or finish.

Parameters:
kind{“act”, “finish”}

Call a tool, or finish with an answer.

actionAction or None, default=None

The call, for an act decision.

answerobject, default=None

The answer, a JSON value, for a finish decision.

rationalestr, default=””

Why, in the planner’s words; recorded, never acted on.

usageUsage or None, default=None

What the decision cost. Required when the run has a token limit.

Parameters:

Examples

>>> from scikitplot.agent import Decision
>>> Decision.act("search", {"query": "spans"}).kind
'act'
>>> Decision.finish("42", rationale="found it").kind
'finish'
classmethod act(tool, arguments=None, *, rationale='', usage=None)[source]#

Decide to call tool with arguments.

Parameters:
Return type:

Decision

action: Action | None = None#
answer: Any = None#
classmethod finish(answer, *, rationale='', usage=None)[source]#

Decide to finish with answer (a JSON value).

Parameters:
Return type:

Decision

classmethod from_dict(data)[source]#

Rebuild a decision written by to_dict.

Parameters:

data (Mapping[str, Any])

Return type:

Decision

kind: str[source]#
rationale: str = ''#
to_dict()[source]#

Return a JSON-compatible mapping.

Return type:

dict[str, Any]

usage: Usage | None = None#