Skip to main content
Version: 1.0

aixplain.base.parameters

Parameter Objects

@dataclass
class Parameter()

[view_source]

A class representing a single parameter with its properties.

Attributes:

  • name str - The name of the parameter.
  • required bool - Whether the parameter is required or optional.
  • value Optional[Any] - The value of the parameter. Defaults to None.

BaseParameters Objects

class BaseParameters()

[view_source]

A base class for managing a collection of parameters.

This class provides functionality to store, access, and manipulate parameters in a structured way. Parameters can be accessed using attribute syntax or dictionary-style access.

Attributes:

  • parameters Dict[str, Parameter] - Dictionary storing Parameter objects.

__init__

def __init__() -> None

[view_source]

Initialize the BaseParameters class.

The initialization creates an empty dictionary to store parameters.

get_parameter

def get_parameter(name: str) -> Optional[Parameter]

[view_source]

Get a parameter by name.

Arguments:

  • name str - Name of the parameter

Returns:

  • Optional[Parameter] - Parameter object if found, None otherwise

to_dict

def to_dict() -> Dict[str, Dict[str, Any]]

[view_source]

Convert parameters back to dictionary format.

Returns:

Dict[str, Dict[str, Any]]: Dictionary representation of parameters

to_list

def to_list() -> List[str]

[view_source]

Convert parameters to a list format.

This method creates a list of dictionaries containing the name and value of each parameter that has a value set.

Returns:

  • List[str] - A list of dictionaries, each containing 'name' and 'value' keys for parameters that have values set.

__str__

def __str__() -> str

[view_source]

Create a pretty string representation of the parameters.

Returns:

  • str - Formatted string showing all parameters

__setattr__

def __setattr__(name: str, value: Any) -> None

[view_source]

Allow setting parameters using attribute syntax.

This special method enables setting parameter values using attribute syntax (e.g., params.text = "Hello"). It only works for parameters that have been previously defined.

Arguments:

  • name str - Name of the parameter to set.
  • value Any - Value to assign to the parameter.

Raises:

  • AttributeError - If attempting to set a parameter that hasn't been defined.

__getattr__

def __getattr__(name: str) -> Any

[view_source]

Allow getting parameter values using attribute syntax.

This special method enables accessing parameter values using attribute syntax (e.g., params.text). It only works for parameters that have been previously defined.

Arguments:

  • name str - Name of the parameter to access.

Returns:

  • Any - The value of the requested parameter.

Raises:

  • AttributeError - If attempting to access a parameter that hasn't been defined.