Skip to content

init_model

Initialization configuration module.

Initializers provide a mechanism to run code at specific points in the EleanorAI lifecycle.

Classes

InitCondition

Bases: Enum

Attributes

BACKEND_INIT_READY class-attribute instance-attribute
BACKEND_INIT_READY = 'BACKEND_INIT_READY'
TEXTPROC_CLI_READY class-attribute instance-attribute
TEXTPROC_CLI_READY = 'TEXTPROC_CLI_READY'

InitializationError

Bases: Exception

Initialization error.

Raised when there is a problem executing an initialization function.

InitializerModel

Bases: BaseModel

Dynamic initialization settings for the EleanorAI Framework.

Attributes

conditions class-attribute instance-attribute
conditions: List[InitCondition] = Field(
    default_factory=list,
    title="Conditions",
    description="A list of conditions that drive when initialization should be run",
)
initializer class-attribute instance-attribute
initializer: IoCFactoryModel = Field(
    ...,
    title="Initializer",
    description="Initializer code to run when an initialization condition condition is met",
)
max_trigger_count class-attribute instance-attribute
max_trigger_count: int = Field(
    default=1,
    title="Max Trigger Count",
    description="Maximum number of times the initializer can be triggered, usually set to 1",
)
model_config class-attribute instance-attribute
model_config = ConfigDict(
    populate_by_name=True,
    use_enum_values=False,
    extra="forbid",
    strict=False,
)
name class-attribute instance-attribute
name: str = Field(
    ...,
    title="Name",
    description="Name of the initializer.",
)
trigger_count class-attribute instance-attribute
trigger_count: int = Field(
    default=0,
    title="Trigger Count",
    description="Number of times the initializer has run (volatile)",
)

Functions

attempt_run
attempt_run(condition: InitCondition) -> None

Determines if the initializer can run based on the condition.

Warning

This method relies on very specific behavior of IocFactoryModel. When initializer.class_name is a function, IocFactoryModel.ioc() will execute the function and return the result, often this will be a None. If initializer.class_name is a class it will return an instance of the class. Both methods are valid however the behavior is not obvious.

Parameters:

Returns:

  • None

    None

validate_conditions classmethod
validate_conditions(value) -> List[InitCondition]
validate_trigger_count classmethod
validate_trigger_count(value)