Policy#
- class scikitplot.agent.Policy(allow_effects=frozenset({ToolEffect.READ}), granted_scopes=frozenset({}), allow_tools=None, deny_tools=frozenset({}), approval_effects=frozenset({ToolEffect.EXTERNAL, ToolEffect.WRITE}), approval_tools=frozenset({}))[source]#
What an agent may do: least privilege unless stated otherwise.
- Parameters:
- allow_effectsiterable of ToolEffect or str, default=(“read”,)
Kinds of effect the agent may cause.
- granted_scopesiterable of str, default=()
Scopes the agent holds; a tool runs only if it needs no other.
- allow_toolsiterable of str or None, default=None
If set, only these tools may run.
Noneallows any registered tool the other rules allow.- deny_toolsiterable of str, default=()
Tools that never run, whatever else allows them.
- approval_effectsiterable of ToolEffect or str, default=(“write”, “external”)
Kinds of effect that need a person’s approval before each call.
- approval_toolsiterable of str, default=()
Tools that need approval before each call, whatever their effect.
- Raises:
- TypeError, ValueError
If a field is not an iterable of the right kind.
- Parameters:
Examples
>>> from scikitplot.agent import Policy >>> Policy().allows_effect("write") False >>> Policy(allow_effects=["read", "write"]).needs_approval_for("write") True
- allow_effects: frozenset[ToolEffect] = frozenset({ToolEffect.READ})#
- allows_effect(effect)[source]#
Whether the policy allows
effect.- Parameters:
effect (ToolEffect | str)
- Return type:
- approval_effects: frozenset[ToolEffect] = frozenset({ToolEffect.EXTERNAL, ToolEffect.WRITE})#
- needs_approval_for(effect)[source]#
Whether a call with
effectneeds approval.- Parameters:
effect (ToolEffect | str)
- Return type: