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

import enum
import typing

T_Result = typing.TypeVar("T_Result")


class ChatStreamEndEventFinishReason(str, enum.Enum):
    """
    - `COMPLETE` - the model sent back a finished reply
    - `ERROR_LIMIT` - the reply was cut off because the model reached the maximum number of tokens for its context length
    - `MAX_TOKENS` - the reply was cut off because the model reached the maximum number of tokens specified by the max_tokens parameter
    - `ERROR` - something went wrong when generating the reply
    - `ERROR_TOXIC` - the model generated a reply that was deemed toxic
    """

    COMPLETE = "COMPLETE"
    ERROR_LIMIT = "ERROR_LIMIT"
    MAX_TOKENS = "MAX_TOKENS"
    ERROR = "ERROR"
    ERROR_TOXIC = "ERROR_TOXIC"

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