autogen.oai.client_utils.validate_parameter
validate_parameter
Validates a given config parameter, checking its type, values, and setting defaults
Parameters:
params (Dict[str, Any]): Dictionary containing parameters to validate.
param_name (str): The name of the parameter to validate.
allowed_types (Tuple): Tuple of acceptable types for the parameter.
allow_None (bool): Whether the parameter can be None
.
default_value (Any): The default value to use if the parameter is invalid or missing.
numerical_bound (Optional[Tuple[Optional[float], Optional[float]]]):
A tuple specifying the lower and upper bounds for numerical parameters.
Each bound can be None
if not applicable.
allowed_values (Optional[List[Any]]): A list of acceptable values for the parameter.
Can be None
if no specific values are required.
Returns:
Any: The validated parameter value or the default value if validation fails.
Raises:
TypeError: If allowed_values
is provided but is not a list.
Example Usage:
Name | Description |
---|---|
params | Type: dict[str, typing.Any] |
param_name | Type: str |
allowed_types | Type: tuple[typing.Any, …] |
allow_None | Type: bool |
default_value | Type: Any |
numerical_bound | Type: tuple[float | None, float | None] | None |
allowed_values | Type: list[typing.Any]Â |Â None |
Type | Description |
---|---|
Any | Any: The validated parameter value or the default value if validation fails. |