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

import datetime as dt
import typing

from ...core.datetime_utils import serialize_datetime
from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1


class DocumentCollectionSearchOptions(pydantic_v1.BaseModel):
    max_chunks: typing.Optional[int] = pydantic_v1.Field(alias="maxChunks", default=None)
    """
    The maximum number of chunks to return. Defaults to 10.
    """

    merge_contents: typing.Optional[bool] = pydantic_v1.Field(alias="mergeContents", default=None)
    """
    Whether to merge the chunks for a document and just return one result per document. Defaults to false.
    """

    threshold: typing.Optional[float] = pydantic_v1.Field(default=None)
    """
    The similarity threshold between 0 and 1 for the search results. A higher number leads to fewer but more relevant results.
    Defaults to 0.45.
    """

    enable_smart_filtering: typing.Optional[bool] = pydantic_v1.Field(alias="enableSmartFiltering", default=None)
    """
    Whether to automatically filter the search results based on the user query and available metadata on the collection. Defaults to false.
    """

    enable_query_extraction: typing.Optional[bool] = pydantic_v1.Field(alias="enableQueryExtraction", default=None)
    """
    / Whether to extract search terms from the user query and use them for semantic search. Defaults to false.
    """

    enable_reranking: typing.Optional[bool] = pydantic_v1.Field(alias="enableReranking", default=None)
    """
    Whether to rerank the search results after the initial semantic search query. Defaults to false.
    """

    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_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
        kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs}

        return deep_union_pydantic_dicts(
            super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none)
        )

    class Config:
        frozen = True
        smart_union = True
        allow_population_by_field_name = True
        populate_by_name = True
        extra = pydantic_v1.Extra.allow
        json_encoders = {dt.datetime: serialize_datetime}
