Skip to content

Exceptions

conatus.actions.exceptions

Exceptions related to Actions.

ActionFunctionNotFoundError

ActionFunctionNotFoundError(class_name: str)

Bases: Exception

Error raised when no action function was found in a class.

PARAMETER DESCRIPTION
class_name

Name of the class where no action function was found.

TYPE: str

Source code in conatus/actions/exceptions.py
def __init__(self, class_name: str) -> None:
    """Initialize the exception.

    Args:
        class_name: Name of the class where no action function was found.
    """
    super().__init__(
        f"No action function found in class {class_name}. \n"
        "Please define an action function, which you can do by defining "
        "a method within the class. \n"
        "If you have multiple methods, you need to use the "
        "`@Action.function` decorator to define the action function."
    )

MultipleActionFunctionsError

MultipleActionFunctionsError(
    class_name: str,
    action_functions: list[Callable[..., ParamType]],
)

Bases: Exception

Error raised when multiple action functions were found in a class.

PARAMETER DESCRIPTION
class_name

Name of the class where multiple action functions were found.

TYPE: str

action_functions

List of action functions found in the class.

TYPE: list[Callable[..., ParamType]]

Source code in conatus/actions/exceptions.py
def __init__(
    self, class_name: str, action_functions: list[Callable[..., ParamType]]
) -> None:
    """Initialize the exception.

    Args:
        class_name: Name of the class where multiple action functions
            were found.
        action_functions: List of action functions found in the class.
    """
    all_functions_as_str = "\n".join(
        [f"{func.__name__}: {func.__doc__}" for func in action_functions]
    )
    super().__init__(
        f"Multiple action functions found in class {class_name}:"
        "\n" + all_functions_as_str + "\n\n"
        "Please define only one action function per class."
    )

ActionFunctionInferenceFoundMultipleFunctionsError

ActionFunctionInferenceFoundMultipleFunctionsError(
    class_name: str,
    all_functions: list[Callable[..., ParamType]],
)

Bases: Exception

Error raised when too many functions are found in an Action class.

PARAMETER DESCRIPTION
class_name

Name of the class where multiple action functions were found.

TYPE: str

all_functions

List of all functions found in the class.

TYPE: list[Callable[..., ParamType]]

Source code in conatus/actions/exceptions.py
def __init__(
    self, class_name: str, all_functions: list[Callable[..., ParamType]]
) -> None:
    """Initialize the exception.

    Args:
        class_name: Name of the class where multiple action functions
            were found.
        all_functions: List of all functions found in the class.
    """
    all_functions_as_str = "\n".join(
        [f"{func.__name__}: {func.__doc__}" for func in all_functions]
    )
    super().__init__(
        f"We tried to infer the action function for the class {class_name} "
        f"but found multiple functions:"
        "\n" + all_functions_as_str + "\n\n"
        "Please use the `@Action.function` decorator to define the action "
        "function."
    )

DocstringParsingError

Bases: Exception

Error raised when parsing a docstring fails.

FunctionExtractionError

Bases: Exception

Error raised when extracting function information fails.

This error is meant to be raised when logical errors are found (e.g. there is a mismatch between what's written in the docstring and what's written in the signature.)

ActionWrongParamsError

Bases: Exception

Error raised when the action is called with wrong parameters.

ActionParamValidationError

Bases: Exception

Error raised when the action is called with wrong parameters.

This errors should be raised when Pydantic rejects the input arguments. For now, the program will crash. Eventually, we'll want to catch it and enable the LLM to try to fix the input arguments.

OpenAIStrictCastError

Bases: Exception

Error raised when the OpenAI schema is not valid for strict mode.

JSONSchemaIncorrectRefsError

Bases: Exception

Error raised when the JSON schema has incorrect $ref values.