# 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


class QueryHistorySummary(UniversalBaseModel):
    """
    A summary of a previously executed query, including metadata but not full results.
    """

    id: typing.Optional[str] = pydantic.Field(default=None)
    """
    The ID of the query history.
    """

    query: typing.Optional[str] = pydantic.Field(default=None)
    """
    The actual query made.
    """

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

    started_at: typing.Optional[dt.datetime] = pydantic.Field(default=None)
    """
    ISO date time indicating when the query was first received.
    """

    latency_millis: typing.Optional[int] = pydantic.Field(default=None)
    """
    Time that the query took in milliseconds.
    """

    chat_id: typing.Optional[str] = pydantic.Field(default=None)
    """
    The unique ID of the chat associated with the query, if this query is part of a chat.
    """

    generation: typing.Optional[str] = pydantic.Field(default=None)
    """
    Generated response to the query, if requested.
    """

    factual_consistency_score: typing.Optional[float] = pydantic.Field(default=None)
    """
    The factual consistency score of the generation.
    """

    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
