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

import datetime as dt
import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from .filter_extraction import FilterExtraction


class RewrittenQuerySpan(UniversalBaseModel):
    """
    Provides detailed information about a rewritten query generated for a specific corpus
    when intelligent query rewriting is enabled.
    """

    type: typing.Literal["rewritten_query"] = "rewritten_query"
    corpus_key: typing.Optional[str] = pydantic.Field(default=None)
    """
    The corpus key that the query was made on.
    """

    latency_millis: typing.Optional[int] = pydantic.Field(default=None)
    """
    Time taken in milliseconds.
    """

    started_at: typing.Optional[dt.datetime] = pydantic.Field(default=None)
    """
    When the span started.
    """

    warnings: typing.Optional[typing.Optional[typing.Any]] = None
    filter_extraction: typing.Optional[FilterExtraction] = None

    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
