Skip to content

rigging.error

We try to avoid creating custom exceptions unless they are necessary.

We use the built-in and pydantic exceptions as much as possible.

CompletionExhaustedMaxRoundsError(max_rounds: int, completion: str) #

Bases: ExhaustedMaxRoundsError

Raised when the maximum number of rounds is exceeded while generating completions.

Source code in .deps/rigging/rigging/error.py
def __init__(self, max_rounds: int, completion: str):
    super().__init__(max_rounds)
    self.completion = completion
    """The completion which was being generated when the exception occured."""

completion = completion instance-attribute #

The completion which was being generated when the exception occured.

ExhaustedMaxRoundsError(max_rounds: int) #

Bases: Exception

Raised when the maximum number of rounds is exceeded while generating.

Source code in .deps/rigging/rigging/error.py
def __init__(self, max_rounds: int):
    super().__init__(f"Exhausted max rounds ({max_rounds}) while generating")
    self.max_rounds = max_rounds
    """The number of rounds which was exceeded."""

max_rounds = max_rounds instance-attribute #

The number of rounds which was exceeded.

InvalidModelSpecifiedError(model: str) #

Bases: Exception

Raised when an invalid identifier is specified when getting a generator.

Source code in .deps/rigging/rigging/error.py
def __init__(self, model: str):
    super().__init__(f"Invalid model specified: {model}")

MessagesExhaustedMaxRoundsError(max_rounds: int, messages: list[Message]) #

Bases: ExhaustedMaxRoundsError

Raised when the maximum number of rounds is exceeded while generating messages.

Source code in .deps/rigging/rigging/error.py
def __init__(self, max_rounds: int, messages: list["Message"]):
    super().__init__(max_rounds)
    self.messages = messages
    """The messages which were being generated when the exception occured."""

messages = messages instance-attribute #

The messages which were being generated when the exception occured.

MissingModelError(content: str) #

Bases: Exception

Raised when a model is missing when parsing a message.

Source code in .deps/rigging/rigging/error.py
def __init__(self, content: str):
    super().__init__(content)

ProcessingError(content: str) #

Bases: Exception

Raised when an error occurs during internal generator processing.

Source code in .deps/rigging/rigging/error.py
def __init__(self, content: str):
    super().__init__(content)

UnknownToolError(tool_name: str) #

Bases: Exception

Raised when the an api tool call is made for an unknown tool.

Source code in .deps/rigging/rigging/error.py
def __init__(self, tool_name: str):
    super().__init__(f"Unknown tool call was requested for '{tool_name}'")
    self.tool_name = tool_name
    """The name of the tool which was unknown."""

tool_name = tool_name instance-attribute #

The name of the tool which was unknown.

raise_as(error_type: type[Exception], message: str) -> t.Callable[[t.Callable[P, R]], t.Callable[P, R]] #

When the wrapped function raises an exception, raise ... from with the new error type.

Source code in .deps/rigging/rigging/error.py
def raise_as(error_type: type[Exception], message: str) -> t.Callable[[t.Callable[P, R]], t.Callable[P, R]]:
    "When the wrapped function raises an exception, `raise ... from` with the new error type."

    def _raise_as(func: t.Callable[P, R]) -> t.Callable[P, R]:
        @functools.wraps(func)
        def wrapper(*args: P.args, **kwargs: P.kwargs) -> R:
            try:
                return func(*args, **kwargs)
            except Exception as e:
                error = error_type(message)
                raise error from e

        if wrapper.__doc__ is None:
            wrapper.__doc__ = ""

        wrapper.__doc__ += f"\n\nRaises:\n    {error_type.__name__}{': ' + message}"

        return wrapper

    return _raise_as