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

from __future__ import annotations
import pydantic
from pydantic import ConfigDict
from r9s.types import BaseModel
from typing import Any, Dict, Literal, Optional
from typing_extensions import NotRequired, TypedDict


Engine = Literal[
    "exa",
    "tavily",
    "google",
]
r"""Search engine name (optional, defaults to exa)
- exa: AI-native search engine, suitable for semantic search
- tavily: AI search API, supports deep search and summary answers
- google: Google custom search, most comprehensive index

"""


class ExtraTypedDict(TypedDict):
    r"""Engine-specific parameters. Different engines support different parameters:

    **Exa engine parameters:**
    - query (string, required): Search query
    - num (integer): Number of results to return, default 10
    - contents.text (boolean): Whether to return full text content

    **Tavily engine parameters:**
    - query (string, required): Search query
    - max_results (integer): Maximum number of results, default 10
    - search_depth (string): Search depth, \"basic\" or \"advanced\", default \"basic\"
    - include_answer (boolean): Whether to include AI-generated summary answer, default true

    **Google engine parameters:**
    - query (string, required): Search query
    - num (integer): Number of results (1-10), default 10
    - start (integer): Starting position (pagination), default 1
    - safe (string): Safe search, \"active\" or \"off\", default \"active\"

    """

    query: str
    r"""Search query (required for all engines)"""


class Extra(BaseModel):
    r"""Engine-specific parameters. Different engines support different parameters:

    **Exa engine parameters:**
    - query (string, required): Search query
    - num (integer): Number of results to return, default 10
    - contents.text (boolean): Whether to return full text content

    **Tavily engine parameters:**
    - query (string, required): Search query
    - max_results (integer): Maximum number of results, default 10
    - search_depth (string): Search depth, \"basic\" or \"advanced\", default \"basic\"
    - include_answer (boolean): Whether to include AI-generated summary answer, default true

    **Google engine parameters:**
    - query (string, required): Search query
    - num (integer): Number of results (1-10), default 10
    - start (integer): Starting position (pagination), default 1
    - safe (string): Safe search, \"active\" or \"off\", default \"active\"

    """

    model_config = ConfigDict(
        populate_by_name=True, arbitrary_types_allowed=True, extra="allow"
    )
    __pydantic_extra__: Dict[str, Any] = pydantic.Field(init=False)

    query: str
    r"""Search query (required for all engines)"""

    @property
    def additional_properties(self):
        return self.__pydantic_extra__

    @additional_properties.setter
    def additional_properties(self, value):
        self.__pydantic_extra__ = value  # pyright: ignore[reportIncompatibleVariableOverride]


class SearchRequestTypedDict(TypedDict):
    extra: ExtraTypedDict
    r"""Engine-specific parameters. Different engines support different parameters:

    **Exa engine parameters:**
    - query (string, required): Search query
    - num (integer): Number of results to return, default 10
    - contents.text (boolean): Whether to return full text content

    **Tavily engine parameters:**
    - query (string, required): Search query
    - max_results (integer): Maximum number of results, default 10
    - search_depth (string): Search depth, \"basic\" or \"advanced\", default \"basic\" 
    - include_answer (boolean): Whether to include AI-generated summary answer, default true

    **Google engine parameters:**
    - query (string, required): Search query
    - num (integer): Number of results (1-10), default 10
    - start (integer): Starting position (pagination), default 1
    - safe (string): Safe search, \"active\" or \"off\", default \"active\" 

    """
    engine: NotRequired[Engine]
    r"""Search engine name (optional, defaults to exa)
    - exa: AI-native search engine, suitable for semantic search
    - tavily: AI search API, supports deep search and summary answers
    - google: Google custom search, most comprehensive index

    """


class SearchRequest(BaseModel):
    extra: Extra
    r"""Engine-specific parameters. Different engines support different parameters:

    **Exa engine parameters:**
    - query (string, required): Search query
    - num (integer): Number of results to return, default 10
    - contents.text (boolean): Whether to return full text content

    **Tavily engine parameters:**
    - query (string, required): Search query
    - max_results (integer): Maximum number of results, default 10
    - search_depth (string): Search depth, \"basic\" or \"advanced\", default \"basic\" 
    - include_answer (boolean): Whether to include AI-generated summary answer, default true

    **Google engine parameters:**
    - query (string, required): Search query
    - num (integer): Number of results (1-10), default 10
    - start (integer): Starting position (pagination), default 1
    - safe (string): Safe search, \"active\" or \"off\", default \"active\" 

    """

    engine: Optional[Engine] = "exa"
    r"""Search engine name (optional, defaults to exa)
    - exa: AI-native search engine, suitable for semantic search
    - tavily: AI search API, supports deep search and summary answers
    - google: Google custom search, most comprehensive index

    """
