Skip to main content
Version: 1.0

aixplain.modules.agent.evolve_param

__author__

Copyright 2024 The aiXplain SDK authors

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Author: aiXplain Team Date: December 2024 Description: EvolveParam Base Model Class for Agent and TeamAgent evolve functionality

EvolveParam Objects

@dataclass
class EvolveParam()

[view_source]

Base model for evolve parameters used in Agent and TeamAgent evolution.

Attributes:

  • to_evolve bool - Whether to enable evolution. Defaults to False.
  • evolve_type Optional[EvolveType] - Type of evolve.
  • max_successful_generations int - Maximum number of successful generations.
  • max_failed_generation_retries int - Maximum number of failed generation retries.
  • max_iterations int - Maximum number of iterations.
  • max_non_improving_generations Optional[int] - Maximum number of non-improving generations.
  • llm Optional[Dict[str, Any]] - LLM configuration with all parameters.
  • additional_params Optional[Dict[str, Any]] - Additional parameters.

__post_init__

def __post_init__()

[view_source]

Validate parameters after initialization.

validate

def validate() -> None

[view_source]

Validate evolve parameters.

Raises:

  • ValueError - If any parameter is invalid.

from_dict

@classmethod
def from_dict(cls, data: Union[Dict[str, Any], None]) -> "EvolveParam"

[view_source]

Create EvolveParam instance from dictionary.

Arguments:

  • data Union[Dict[str, Any], None] - Dictionary containing evolve parameters.

Returns:

  • EvolveParam - Instance with parameters set from dictionary.

Raises:

  • ValueError - If data format is invalid.

to_dict

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

[view_source]

Convert EvolveParam instance to dictionary for API calls.

Returns:

Dict[str, Any]: Dictionary representation with API-compatible keys.

merge

def merge(other: Union[Dict[str, Any], "EvolveParam"]) -> "EvolveParam"

[view_source]

Merge this EvolveParam with another set of parameters.

Arguments:

  • other Union[Dict[str, Any], EvolveParam] - Other parameters to merge.

Returns:

  • EvolveParam - New instance with merged parameters.

validate_evolve_param

def validate_evolve_param(
evolve_param: Union[Dict[str, Any], EvolveParam, None]) -> EvolveParam

[view_source]

Utility function to validate and convert evolve parameters.

Arguments:

  • evolve_param Union[Dict[str, Any], EvolveParam, None] - Input evolve parameters.

Returns:

  • EvolveParam - Validated EvolveParam instance.

Raises:

  • ValueError - If parameters are invalid.