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

from __future__ import annotations
from duckyai.types import BaseModel
from typing import Any, Dict, Optional
from typing_extensions import NotRequired, TypedDict


class RetrieveDocumentsRequestTypedDict(TypedDict):
    index_name: str
    r"""The name of the index to retrieve documents from"""
    query: str
    r"""The search query used for retrieving documents"""
    top_k: int
    r"""The number of documents to retrieve"""
    alpha: NotRequired[float]
    r"""Between 0 and 1, configures balance between keyword and semantic retrieval"""
    rerank: NotRequired[bool]
    r"""Whether to rerank the results after retrieval"""
    metadata_filter: NotRequired[Dict[str, Any]]
    r"""The filter object is used to specify query criteria for filtering results.
    Each key in the filter object represents a field name, and its value is a dictionary
    of comparison operators. Logical operators can be used within these dictionaries
    to combine multiple conditions.

    - **Comparison Operators**:
    - **`$eq`**: Checks if a field is equal to a specified value (string, number, or boolean).
    - Simplified form: `\"field1\": \"value1\"` is equivalent to `\"field1\": {\"$eq\": \"value1\"}`.
    - **`$ne`**: Checks if a field is not equal to a specified value (string, number, or boolean).
    - **`$gt`**: Checks if a field is greater than a specified numeric value.
    - **`$gte`**: Checks if a field is greater than or equal to a specified numeric value.
    - **`$lt`**: Checks if a field is less than a specified numeric value.
    - **`$lte`**: Checks if a field is less than or equal to a specified numeric value.
    - **`$in`**: Checks if a field's value is within a specified list of values (strings, numbers).
    - **`$nin`**: Checks if a field's value is not within a specified list of values (strings, numbers).

    - **Logical Operators** (used within field-specific dictionaries):
    - **`$and`**: An array of filter objects, all of which must evaluate to true.
    - **`$or`**: An array of filter objects, at least one of which must evaluate to true.

    Example:
    ```json
    {
    \"field1\": \"value1\",  // Simplified equals check
    \"field2\": {\"$gt\": 10},
    \"field3\": {
    \"$or\": [
    {\"$in\": [\"value2\", \"value3\"]},
    {\"$ne\": \"value4\"}
    ]
    }
    }
    ```

    """


class RetrieveDocumentsRequest(BaseModel):
    index_name: str
    r"""The name of the index to retrieve documents from"""

    query: str
    r"""The search query used for retrieving documents"""

    top_k: int
    r"""The number of documents to retrieve"""

    alpha: Optional[float] = None
    r"""Between 0 and 1, configures balance between keyword and semantic retrieval"""

    rerank: Optional[bool] = None
    r"""Whether to rerank the results after retrieval"""

    metadata_filter: Optional[Dict[str, Any]] = None
    r"""The filter object is used to specify query criteria for filtering results.
    Each key in the filter object represents a field name, and its value is a dictionary
    of comparison operators. Logical operators can be used within these dictionaries
    to combine multiple conditions.

    - **Comparison Operators**:
    - **`$eq`**: Checks if a field is equal to a specified value (string, number, or boolean).
    - Simplified form: `\"field1\": \"value1\"` is equivalent to `\"field1\": {\"$eq\": \"value1\"}`.
    - **`$ne`**: Checks if a field is not equal to a specified value (string, number, or boolean).
    - **`$gt`**: Checks if a field is greater than a specified numeric value.
    - **`$gte`**: Checks if a field is greater than or equal to a specified numeric value.
    - **`$lt`**: Checks if a field is less than a specified numeric value.
    - **`$lte`**: Checks if a field is less than or equal to a specified numeric value.
    - **`$in`**: Checks if a field's value is within a specified list of values (strings, numbers).
    - **`$nin`**: Checks if a field's value is not within a specified list of values (strings, numbers).

    - **Logical Operators** (used within field-specific dictionaries):
    - **`$and`**: An array of filter objects, all of which must evaluate to true.
    - **`$or`**: An array of filter objects, at least one of which must evaluate to true.

    Example:
    ```json
    {
    \"field1\": \"value1\",  // Simplified equals check
    \"field2\": {\"$gt\": 10},
    \"field3\": {
    \"$or\": [
    {\"$in\": [\"value2\", \"value3\"]},
    {\"$ne\": \"value4\"}
    ]
    }
    }
    ```

    """
