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

import datetime as dt
import typing

from ..core.datetime_utils import serialize_datetime
from ..core.pydantic_utilities import pydantic_v1
from .finish_reason_enum import FinishReasonEnum
from .normalized_log_probs import NormalizedLogProbs
from .vellum_variable_type import VellumVariableType


class EnrichedNormalizedCompletion(pydantic_v1.BaseModel):
    id: str = pydantic_v1.Field()
    """
    The Vellum-generated ID of the completion.
    """

    external_id: typing.Optional[str] = pydantic_v1.Field(default=None)
    """
    The external ID that was originally provided along with the generation request, which uniquely identifies this generation in an external system.
    """

    text: str = pydantic_v1.Field()
    """
    The text generated by the LLM.
    """

    finish_reason: typing.Optional[FinishReasonEnum] = pydantic_v1.Field(default=None)
    """
    The reason the generation finished.
    
    - `LENGTH` - LENGTH
    - `STOP` - STOP
    - `UNKNOWN` - UNKNOWN
    """

    logprobs: typing.Optional[NormalizedLogProbs] = pydantic_v1.Field(default=None)
    """
    The logprobs of the completion. Only present if specified in the original request options.
    """

    model_version_id: str = pydantic_v1.Field()
    """
    The ID of the model version used to generate this completion.
    """

    prompt_version_id: str
    type: typing.Optional[VellumVariableType] = None
    deployment_release_tag: str
    model_name: str

    def json(self, **kwargs: typing.Any) -> str:
        kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
        return super().json(**kwargs_with_defaults)

    def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
        kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
        return super().dict(**kwargs_with_defaults)

    class Config:
        frozen = True
        smart_union = True
        extra = pydantic_v1.Extra.allow
        json_encoders = {dt.datetime: serialize_datetime}
