aixplain.v2.actions
Unified Actions / Inputs hierarchy for models and tools.
Object Hierarchy:
Actions — collection of Action objects
Action — metadata + owns its inputs
Inputs — collection of Input objects
Input — individual input with schema + current value
Models have a single implicit "run" action. The model.inputs shorthand
skips the actions layer since there is nothing to disambiguate.
Tools have multiple actions, so the full path is always used.
Input Objects
class Input()
Individual input with schema and current value.
Attributes:
name- The input parameter name.required- Whether this input is required.type- The data type (e.g."text","number","string").value- The current value (mutable).description- Human-readable description.
__init__
def __init__(name: str,
required: bool = False,
type: Optional[str] = None,
value: Any = None,
description: str = "",
*,
_validator: Optional[Callable[[Any], bool]] = None,
_metadata: Optional[Any] = None) -> None
Initialize an Input with schema metadata and an optional validator.
name
@property
def name() -> str
The input parameter name.
required
@property
def required() -> bool
Whether this input is required.
type
@property
def type() -> Optional[str]
The data type string (e.g. "text", "number").
value
@property
def value() -> Any
The current value.
value
@value.setter
def value(val: Any) -> None
Set the value, running the validator if one was provided.
description
@property
def description() -> str
Human-readable description of the input.
reset
def reset(default: Any = None) -> None
Reset the value to the given default (bypasses validation).
__eq__
def __eq__(other: object) -> bool
Compare by value so inputs['temperature'] == 0.7 works.
__hash__
def __hash__() -> int
Return an identity-based hash.
__repr__
def __repr__() -> str
Return a developer-friendly representation.
from_parameter
@classmethod
def from_parameter(cls, param: "Parameter") -> "Input"
Build an Input from a model Parameter.
from_action_input_spec
@classmethod
def from_action_input_spec(cls, spec: "ActionInputSpec") -> "Input"
Build an Input from a tool ActionInputSpec.
Inputs Objects
class Inputs()
Ordered collection of Input objects.
Supports dict-like access (inputs["key"], inputs["key"] = val)
and dot-notation (inputs.key, inputs.key = val).
Iterating, .keys(), .values(), and .items() operate on
raw values so that dict(inputs.items()) gives a plain {name: value}
mapping suitable for API payloads.
__init__
def __init__(inputs: Optional[Dict[str, Input]] = None) -> None
Initialize from an optional ordered dict of Input objects.
__getitem__
def __getitem__(key: str) -> Input
Return the Input for key.
__setitem__
def __setitem__(key: str, value: Any) -> None
Set the value on the Input identified by key.
__contains__
def __contains__(key: object) -> bool
Return whether key is a known input name.
__len__
def __len__() -> int
Return the number of inputs.
__iter__
def __iter__()
Iterate over input names.
__getattr__
def __getattr__(name: str) -> Input
Dot-notation read: inputs.temperature.
__setattr__
def __setattr__(name: str, value: Any) -> None
Dot-notation write: inputs.temperature = 0.7.
keys
def keys() -> List[str]
Return input names.
values
def values() -> List[Any]
Return raw values for all inputs.
items
def items() -> List[tuple[str, Any]]
Return (name, value) pairs.
get
def get(key: str, default: Any = None) -> Optional[Input]
Return the Input for key, or default.
update
def update(**kwargs: Any) -> None
Update multiple input values at once.
reset
def reset(key: Optional[str] = None) -> None
Reset one or all inputs to their default values.
copy
def copy() -> Dict[str, Any]
Return a shallow copy of {name: value}.
validate
def validate(data: Optional[Dict[str, Any]] = None) -> List[str]
Validate data (or current values) against input specs.
Returns a list of error strings (empty means valid).
required
@property
def required() -> List[str]
Names of all required inputs.
__repr__
def __repr__() -> str
Return Inputs({'key': value, ...}).
from_parameters
@classmethod
def from_parameters(cls, params: Optional[list]) -> "Inputs"
Build from a list of model Parameter objects.
from_action_input_specs
@classmethod
def from_action_input_specs(cls, specs: Optional[list]) -> "Inputs"
Build from a list of tool ActionInputSpec objects.
Action Objects
class Action()
Metadata for a single action, owning its Inputs.
For models the single action is always "run".
For tools there may be many (e.g. "search_agents", "search_models").
__init__
def __init__(name: str,
description: Optional[str] = None,
*,
inputs: Optional[Inputs] = None,
_inputs_loader: Optional[Callable[[], Inputs]] = None) -> None
Initialize an Action with name, description and optional lazy inputs.
name
@property
def name() -> str
The canonical action name.
description
@property
def description() -> Optional[str]
Human-readable description of the action.
inputs
@property
def inputs() -> Inputs
The action's Inputs (lazily loaded for tool actions).
__repr__
def __repr__() -> str
Return a multi-line representation showing the action and its inputs.
Actions Objects
class Actions()
Ordered collection of Action objects.
For models this contains a single "run" action.
For tools it lazily discovers actions from the backend.
__init__
def __init__(
actions: Optional[Dict[str, Action]] = None,
*,
_action_factory: Optional[Callable[[str, Optional[str]], Action]] = None,
_actions_lister: Optional[Callable[[], List[tuple[str,
Optional[str]]]]] = None
) -> None
Initialize with either an eager dict or lazy factory/lister callbacks.
__getitem__
def __getitem__(key: str) -> Action
Return the Action for key (case-insensitive).
__getattr__
def __getattr__(name: str) -> Action
Dot-notation read: tool.actions.search (case-insensitive).
Only consulted when normal attribute lookup fails, so it never shadows
the real instance attributes (_actions etc.). Private names are
rejected to avoid recursion during initialization.
__contains__
def __contains__(key: object) -> bool
Return whether key matches an available action name.
__iter__
def __iter__()
Iterate over available action names.
__len__
def __len__() -> int
Return the number of available actions.
__repr__
def __repr__() -> str
Return Actions(['action1', 'action2', ...]).
refresh
def refresh() -> None
Clear caches and force re-fetch on next access.