# This file was auto-generated by Fern from our API Definition.

import enum
import typing

T_Result = typing.TypeVar("T_Result")


class FinishReason(str, enum.Enum):
    COMPLETE = "COMPLETE"
    ERROR = "ERROR"
    ERROR_TOXIC = "ERROR_TOXIC"
    ERROR_LIMIT = "ERROR_LIMIT"
    USER_CANCEL = "USER_CANCEL"
    MAX_TOKENS = "MAX_TOKENS"

    def visit(
        self,
        complete: typing.Callable[[], T_Result],
        error: typing.Callable[[], T_Result],
        error_toxic: typing.Callable[[], T_Result],
        error_limit: typing.Callable[[], T_Result],
        user_cancel: typing.Callable[[], T_Result],
        max_tokens: typing.Callable[[], T_Result],
    ) -> T_Result:
        if self is FinishReason.COMPLETE:
            return complete()
        if self is FinishReason.ERROR:
            return error()
        if self is FinishReason.ERROR_TOXIC:
            return error_toxic()
        if self is FinishReason.ERROR_LIMIT:
            return error_limit()
        if self is FinishReason.USER_CANCEL:
            return user_cancel()
        if self is FinishReason.MAX_TOKENS:
            return max_tokens()
