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

import typing

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


class SearchQueryResponse(UniversalBaseModel):
    """
    Schema for search query responses.
    """

    query_text: str = pydantic.Field()
    """
    The search query text
    """

    query_length: int = pydantic.Field()
    """
    Length of the search query in characters
    """

    is_streaming: bool = pydantic.Field()
    """
    Whether this was a streaming search
    """

    retrieval_strategy: str = pydantic.Field()
    """
    Retrieval strategy: 'hybrid', 'neural', 'keyword'
    """

    limit: int = pydantic.Field()
    """
    Maximum number of results requested
    """

    offset: int = pydantic.Field()
    """
    Number of results to skip for pagination
    """

    temporal_relevance: float = pydantic.Field()
    """
    Temporal relevance weight (0.0 to 1.0)
    """

    filter: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None)
    """
    Qdrant filter applied (if any)
    """

    duration_ms: int = pydantic.Field()
    """
    Search execution time in milliseconds
    """

    results_count: int = pydantic.Field()
    """
    Number of results returned
    """

    max_score: typing.Optional[float] = pydantic.Field(default=None)
    """
    Highest relevance score from search results (0.0 to 1.0)
    """

    expand_query: bool = pydantic.Field()
    """
    Whether query expansion was enabled
    """

    interpret_filters: bool = pydantic.Field()
    """
    Whether query interpretation was enabled
    """

    rerank: bool = pydantic.Field()
    """
    Whether LLM reranking was enabled
    """

    generate_answer: bool = pydantic.Field()
    """
    Whether answer generation was enabled
    """

    id: str = pydantic.Field()
    """
    Unique identifier for the search query
    """

    organization_id: str = pydantic.Field()
    """
    ID of the organization
    """

    collection_id: str = pydantic.Field()
    """
    ID of the collection that was searched
    """

    user_id: typing.Optional[str] = pydantic.Field(default=None)
    """
    ID of the user who performed the search
    """

    api_key_id: typing.Optional[str] = pydantic.Field(default=None)
    """
    ID of the API key used for the search
    """

    created_at: str = pydantic.Field()
    """
    When the search query was created
    """

    modified_at: str = pydantic.Field()
    """
    When the search query was last modified
    """

    created_by_email: typing.Optional[str] = pydantic.Field(default=None)
    """
    Email of the user who created the record
    """

    modified_by_email: typing.Optional[str] = pydantic.Field(default=None)
    """
    Email of the user who last modified the record
    """

    confidence: typing.Optional[float] = pydantic.Field(default=None)
    """
    Confidence score of the search results
    """

    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
