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

from ..core.pydantic_utilities import UniversalBaseModel
import typing
from .span_public_type import SpanPublicType
import datetime as dt
from .json_node_public import JsonNodePublic
from .error_info_public import ErrorInfoPublic
from .feedback_score_public import FeedbackScorePublic
from .comment_public import CommentPublic
import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2


class SpanPublic(UniversalBaseModel):
    id: typing.Optional[str] = None
    project_id: typing.Optional[str] = None
    trace_id: str
    parent_span_id: typing.Optional[str] = None
    name: str
    type: SpanPublicType
    start_time: dt.datetime
    end_time: typing.Optional[dt.datetime] = None
    input: typing.Optional[JsonNodePublic] = None
    output: typing.Optional[JsonNodePublic] = None
    metadata: typing.Optional[JsonNodePublic] = None
    model: typing.Optional[str] = None
    provider: typing.Optional[str] = None
    tags: typing.Optional[typing.List[str]] = None
    usage: typing.Optional[typing.Dict[str, int]] = None
    error_info: typing.Optional[ErrorInfoPublic] = None
    created_at: typing.Optional[dt.datetime] = None
    last_updated_at: typing.Optional[dt.datetime] = None
    created_by: typing.Optional[str] = None
    last_updated_by: typing.Optional[str] = None
    feedback_scores: typing.Optional[typing.List[FeedbackScorePublic]] = None
    comments: typing.Optional[typing.List[CommentPublic]] = None
    total_estimated_cost: typing.Optional[float] = None
    total_estimated_cost_version: typing.Optional[str] = None
    duration: typing.Optional[float] = pydantic.Field(default=None)
    """
    Duration in milliseconds as a decimal number to support sub-millisecond precision
    """

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(
            extra="allow", frozen=True
        )  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
