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

import datetime as dt
import typing

import pydantic

from ..core.datetime_utils import serialize_datetime
from .finish_reason_enum import FinishReasonEnum
from .normalized_log_probs import NormalizedLogProbs


class EnrichedNormalizedCompletion(pydantic.BaseModel):
    id: str = pydantic.Field(description=("The Vellum-generated ID of the completion.\n"))
    external_id: typing.Optional[str] = pydantic.Field(
        description=(
            "The external ID that was originally provided along with the generation request, which uniquely identifies this generation in an external system.\n"
        )
    )
    text: str = pydantic.Field(description=("The text generated by the LLM.\n"))
    finish_reason: typing.Optional[FinishReasonEnum] = pydantic.Field(
        description=("The reason the generation finished.\n")
    )
    logprobs: typing.Optional[NormalizedLogProbs] = pydantic.Field(
        description=("The logprobs of the completion. Only present if specified in the original request options.\n")
    )
    model_version_id: str = pydantic.Field(
        description=("The ID of the model version used to generate this completion.\n")
    )

    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
        json_encoders = {dt.datetime: serialize_datetime}
