"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
from lambdadb.types import BaseModel
from lambdadb.utils import FieldMetadata, PathParamMetadata, RequestMetadata
import pydantic
from typing import Any, Dict, List, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class QueryCollectionRequestBodyTypedDict(TypedDict):
    size: int
    r"""Number of documents to return. Note that the maximum number of documents is 100."""
    query: NotRequired[Dict[str, Any]]
    r"""Query object."""
    consistent_read: NotRequired[bool]
    r"""If your application requires a strongly consistent read, set consistentRead to true. Although a strongly consistent read might take more time than an eventually consistent read, it always returns the last updated value."""
    include_vectors: NotRequired[bool]
    r"""If your application need to include vector values in the response, set includeVectors to true."""
    sort: NotRequired[List[Dict[str, Any]]]
    r"""List of field name, sort direction pairs."""
    fields: NotRequired[List[str]]
    r"""List of field name to include in results"""


class QueryCollectionRequestBody(BaseModel):
    size: int
    r"""Number of documents to return. Note that the maximum number of documents is 100."""

    query: Optional[Dict[str, Any]] = None
    r"""Query object."""

    consistent_read: Annotated[
        Optional[bool], pydantic.Field(alias="consistentRead")
    ] = False
    r"""If your application requires a strongly consistent read, set consistentRead to true. Although a strongly consistent read might take more time than an eventually consistent read, it always returns the last updated value."""

    include_vectors: Annotated[
        Optional[bool], pydantic.Field(alias="includeVectors")
    ] = False
    r"""If your application need to include vector values in the response, set includeVectors to true."""

    sort: Optional[List[Dict[str, Any]]] = None
    r"""List of field name, sort direction pairs."""

    fields: Optional[List[str]] = None
    r"""List of field name to include in results"""


class QueryCollectionRequestTypedDict(TypedDict):
    project_name: str
    r"""Project name."""
    collection_name: str
    r"""Collection name."""
    request_body: QueryCollectionRequestBodyTypedDict


class QueryCollectionRequest(BaseModel):
    project_name: Annotated[
        str,
        pydantic.Field(alias="projectName"),
        FieldMetadata(path=PathParamMetadata(style="simple", explode=False)),
    ]
    r"""Project name."""

    collection_name: Annotated[
        str,
        pydantic.Field(alias="collectionName"),
        FieldMetadata(path=PathParamMetadata(style="simple", explode=False)),
    ]
    r"""Collection name."""

    request_body: Annotated[
        QueryCollectionRequestBody,
        FieldMetadata(request=RequestMetadata(media_type="application/json")),
    ]


class QueryCollectionDocTypedDict(TypedDict):
    collection: str
    r"""Collection name."""
    score: float
    r"""Document similarity score."""
    doc: Dict[str, Any]


class QueryCollectionDoc(BaseModel):
    collection: str
    r"""Collection name."""

    score: float
    r"""Document similarity score."""

    doc: Dict[str, Any]


class QueryCollectionResponseTypedDict(TypedDict):
    r"""Documents selected by query."""

    took: int
    r"""Elapsed time in milliseconds."""
    max_score: float
    r"""Maximum score."""
    total: int
    r"""Total number of documents returned."""
    docs: List[QueryCollectionDocTypedDict]
    r"""List of documents."""


class QueryCollectionResponse(BaseModel):
    r"""Documents selected by query."""

    took: int
    r"""Elapsed time in milliseconds."""

    max_score: Annotated[float, pydantic.Field(alias="maxScore")]
    r"""Maximum score."""

    total: int
    r"""Total number of documents returned."""

    docs: List[QueryCollectionDoc]
    r"""List of documents."""
