oai
oai.client_utils
Utilities for client classes
validate_parameter
Validates a given config parameter, checking its type, values, and setting defaults
Arguments:
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 beNone
.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 beNone
if not applicable.allowed_values
Optional[List[Any]] - A list of acceptable values for the parameter. Can beNone
if no specific values are required.
Returns:
Any
- The validated parameter value or the default value if validation fails.
Raises:
-
TypeError
- Ifallowed_values
is provided but is not a list.Example Usage:
should_hide_tools
Determines if tools should be hidden. This function is used to hide tools when they have been run, minimising the chance of the LLM choosing them when they shouldn’t.
Arguments:
messages
List[Dict[str, Any]] - List of messagestools
List[Dict[str, Any]] - List of toolshide_tools_param
str - “hide_tools” parameter value. Can be “if_all_run” (hide tools if all tools have been run), “if_any_run” (hide tools if any of the tools have been run), “never” (never hide tools). Default is “never”.
Returns:
-
bool
- Indicates whether the tools should be excluded from the response create requestExample Usage: