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

from ...core.unchecked_base_model import UncheckedBaseModel
import typing
from .v2rerank_response_results_item_document import V2RerankResponseResultsItemDocument
import pydantic
from ...core.pydantic_utilities import IS_PYDANTIC_V2


class V2RerankResponseResultsItem(UncheckedBaseModel):
    document: typing.Optional[V2RerankResponseResultsItemDocument] = pydantic.Field(default=None)
    """
    If `return_documents` is set as `false` this will return none, if `true` it will return the documents passed in
    """

    index: int = pydantic.Field()
    """
    Corresponds to the index in the original list of documents to which the ranked document belongs. (i.e. if the first value in the `results` object has an `index` value of 3, it means in the list of documents passed in, the document at `index=3` had the highest relevance)
    """

    relevance_score: float = pydantic.Field()
    """
    Relevance scores are normalized to be in the range `[0, 1]`. Scores close to `1` indicate a high relevance to the query, and scores closer to `0` indicate low relevance. It is not accurate to assume a score of 0.9 means the document is 2x more relevant than a document with a score of 0.45
    """

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

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