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

import typing
import urllib.parse
from json.decoder import JSONDecodeError

from ..core.api_error import ApiError
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.jsonable_encoder import jsonable_encoder
from ..core.pydantic_utilities import pydantic_v1
from ..core.remove_none_from_dict import remove_none_from_dict
from ..core.request_options import RequestOptions
from ..errors.unprocessable_entity_error import UnprocessableEntityError
from ..types.convert_pdf_to_sheet_out import ConvertPdfToSheetOut
from ..types.excecute_tool_first_workflow_out import ExcecuteToolFirstWorkflowOut
from ..types.firecrawl_scrape_url_data_reponse_dto import FirecrawlScrapeUrlDataReponseDto
from ..types.http_validation_error import HttpValidationError
from ..types.langchain_documents_request_out import LangchainDocumentsRequestOut
from ..types.llm_model import LlmModel
from ..types.publish_formats import PublishFormats
from ..types.query_model import QueryModel
from ..types.researcher_out import ResearcherOut
from ..types.semantic_query_out import SemanticQueryOut

# this is used as the default value for optional parameters
OMIT = typing.cast(typing.Any, ...)


class ToolsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._client_wrapper = client_wrapper

    def scrape_url(
        self,
        *,
        url: str,
        params: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> FirecrawlScrapeUrlDataReponseDto:
        """
        Parameters:
            - url: str.

            - params: typing.Optional[typing.Dict[str, typing.Any]].

            - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
        ---
        from athena.client import Athena

        client = Athena(
            api_key="YOUR_API_KEY",
        )
        client.tools.scrape_url(
            url="https://athenaintelligence.ai",
        )
        """
        _request: typing.Dict[str, typing.Any] = {"url": url}
        if params is not OMIT:
            _request["params"] = params
        _response = self._client_wrapper.httpx_client.request(
            method="POST",
            url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v0/tools/firecrawl/scrape-url"),
            params=jsonable_encoder(
                request_options.get("additional_query_parameters") if request_options is not None else None
            ),
            json=jsonable_encoder(_request)
            if request_options is None or request_options.get("additional_body_parameters") is None
            else {
                **jsonable_encoder(_request),
                **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
            },
            headers=jsonable_encoder(
                remove_none_from_dict(
                    {
                        **self._client_wrapper.get_headers(),
                        **(request_options.get("additional_headers", {}) if request_options is not None else {}),
                    }
                )
            ),
            timeout=request_options.get("timeout_in_seconds")
            if request_options is not None and request_options.get("timeout_in_seconds") is not None
            else self._client_wrapper.get_timeout(),
            retries=0,
            max_retries=request_options.get("max_retries") if request_options is not None else 0,  # type: ignore
        )
        if 200 <= _response.status_code < 300:
            return pydantic_v1.parse_obj_as(FirecrawlScrapeUrlDataReponseDto, _response.json())  # type: ignore
        if _response.status_code == 422:
            raise UnprocessableEntityError(
                pydantic_v1.parse_obj_as(HttpValidationError, _response.json())  # type: ignore
            )
        try:
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def langchain_documents(
        self,
        *,
        document_id: str,
        pagination_limit: typing.Optional[int] = OMIT,
        pagination_offset: typing.Optional[int] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> LangchainDocumentsRequestOut:
        """
        Parameters:
            - document_id: str.

            - pagination_limit: typing.Optional[int].

            - pagination_offset: typing.Optional[int].

            - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
        ---
        from athena.client import Athena

        client = Athena(
            api_key="YOUR_API_KEY",
        )
        client.tools.langchain_documents(
            document_id="doc_9249292-d118-42d3-95b4-00eccfe0754f",
            pagination_limit=250,
            pagination_offset=0,
        )
        """
        _request: typing.Dict[str, typing.Any] = {"document_id": document_id}
        if pagination_limit is not OMIT:
            _request["pagination_limit"] = pagination_limit
        if pagination_offset is not OMIT:
            _request["pagination_offset"] = pagination_offset
        _response = self._client_wrapper.httpx_client.request(
            method="POST",
            url=urllib.parse.urljoin(
                f"{self._client_wrapper.get_base_url()}/", "api/v0/tools/file/langchain-documents"
            ),
            params=jsonable_encoder(
                request_options.get("additional_query_parameters") if request_options is not None else None
            ),
            json=jsonable_encoder(_request)
            if request_options is None or request_options.get("additional_body_parameters") is None
            else {
                **jsonable_encoder(_request),
                **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
            },
            headers=jsonable_encoder(
                remove_none_from_dict(
                    {
                        **self._client_wrapper.get_headers(),
                        **(request_options.get("additional_headers", {}) if request_options is not None else {}),
                    }
                )
            ),
            timeout=request_options.get("timeout_in_seconds")
            if request_options is not None and request_options.get("timeout_in_seconds") is not None
            else self._client_wrapper.get_timeout(),
            retries=0,
            max_retries=request_options.get("max_retries") if request_options is not None else 0,  # type: ignore
        )
        if 200 <= _response.status_code < 300:
            return pydantic_v1.parse_obj_as(LangchainDocumentsRequestOut, _response.json())  # type: ignore
        if _response.status_code == 422:
            raise UnprocessableEntityError(
                pydantic_v1.parse_obj_as(HttpValidationError, _response.json())  # type: ignore
            )
        try:
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def tool_first_workflow(
        self,
        *,
        model: typing.Optional[LlmModel] = OMIT,
        tool_name: str,
        content: str,
        tool_kwargs: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ExcecuteToolFirstWorkflowOut:
        """
        Parameters:
            - model: typing.Optional[LlmModel].

            - tool_name: str.

            - content: str.

            - tool_kwargs: typing.Optional[typing.Dict[str, typing.Any]].

            - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
        ---
        from athena import LlmModel
        from athena.client import Athena

        client = Athena(
            api_key="YOUR_API_KEY",
        )
        client.tools.tool_first_workflow(
            model=LlmModel.MISTRAL_LARGE_0224,
            tool_name="tavily_search",
            content="summarize the website in one paragraph",
            tool_kwargs={"query": "website: www.athenaintelligence.ai"},
        )
        """
        _request: typing.Dict[str, typing.Any] = {"tool_name": tool_name, "content": content}
        if model is not OMIT:
            _request["model"] = model
        if tool_kwargs is not OMIT:
            _request["tool_kwargs"] = tool_kwargs
        _response = self._client_wrapper.httpx_client.request(
            method="POST",
            url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v0/tools/first-agent"),
            params=jsonable_encoder(
                request_options.get("additional_query_parameters") if request_options is not None else None
            ),
            json=jsonable_encoder(_request)
            if request_options is None or request_options.get("additional_body_parameters") is None
            else {
                **jsonable_encoder(_request),
                **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
            },
            headers=jsonable_encoder(
                remove_none_from_dict(
                    {
                        **self._client_wrapper.get_headers(),
                        **(request_options.get("additional_headers", {}) if request_options is not None else {}),
                    }
                )
            ),
            timeout=request_options.get("timeout_in_seconds")
            if request_options is not None and request_options.get("timeout_in_seconds") is not None
            else self._client_wrapper.get_timeout(),
            retries=0,
            max_retries=request_options.get("max_retries") if request_options is not None else 0,  # type: ignore
        )
        if 200 <= _response.status_code < 300:
            return pydantic_v1.parse_obj_as(ExcecuteToolFirstWorkflowOut, _response.json())  # type: ignore
        if _response.status_code == 422:
            raise UnprocessableEntityError(
                pydantic_v1.parse_obj_as(HttpValidationError, _response.json())  # type: ignore
            )
        try:
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def researcher(
        self,
        *,
        query: str,
        max_sections: int,
        guidelines: typing.Sequence[str],
        publish_formats: typing.Optional[PublishFormats] = OMIT,
        source: typing.Optional[str] = OMIT,
        athena_document_ids: typing.Optional[typing.Sequence[str]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ResearcherOut:
        """
        Parameters:
            - query: str.

            - max_sections: int.

            - guidelines: typing.Sequence[str].

            - publish_formats: typing.Optional[PublishFormats].

            - source: typing.Optional[str].

            - athena_document_ids: typing.Optional[typing.Sequence[str]].

            - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
        ---
        from athena import PublishFormats
        from athena.client import Athena

        client = Athena(
            api_key="YOUR_API_KEY",
        )
        client.tools.researcher(
            query="Write a report about the company Athena Intelligence.",
            max_sections=10,
            guidelines=[
                "The report MUST be written in APA format",
                "Each sub section MUST include supporting sources using hyperlinks. If none exist, erase the sub section or rewrite it to be a part of the previous section",
                "The report MUST be written in english",
            ],
            publish_formats=PublishFormats(
                markdown=False,
                pdf=True,
                docx=False,
            ),
            source="web",
            athena_document_ids=["doc_1", "doc_2"],
        )
        """
        _request: typing.Dict[str, typing.Any] = {
            "query": query,
            "max_sections": max_sections,
            "guidelines": guidelines,
        }
        if publish_formats is not OMIT:
            _request["publish_formats"] = publish_formats
        if source is not OMIT:
            _request["source"] = source
        if athena_document_ids is not OMIT:
            _request["athena_document_ids"] = athena_document_ids
        _response = self._client_wrapper.httpx_client.request(
            method="POST",
            url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v0/tools/researcher"),
            params=jsonable_encoder(
                request_options.get("additional_query_parameters") if request_options is not None else None
            ),
            json=jsonable_encoder(_request)
            if request_options is None or request_options.get("additional_body_parameters") is None
            else {
                **jsonable_encoder(_request),
                **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
            },
            headers=jsonable_encoder(
                remove_none_from_dict(
                    {
                        **self._client_wrapper.get_headers(),
                        **(request_options.get("additional_headers", {}) if request_options is not None else {}),
                    }
                )
            ),
            timeout=request_options.get("timeout_in_seconds")
            if request_options is not None and request_options.get("timeout_in_seconds") is not None
            else self._client_wrapper.get_timeout(),
            retries=0,
            max_retries=request_options.get("max_retries") if request_options is not None else 0,  # type: ignore
        )
        if 200 <= _response.status_code < 300:
            return pydantic_v1.parse_obj_as(ResearcherOut, _response.json())  # type: ignore
        if _response.status_code == 422:
            raise UnprocessableEntityError(
                pydantic_v1.parse_obj_as(HttpValidationError, _response.json())  # type: ignore
            )
        try:
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def convert_pdf_to_sheet(
        self, *, document_id: str, request_options: typing.Optional[RequestOptions] = None
    ) -> ConvertPdfToSheetOut:
        """
        Parameters:
            - document_id: str.

            - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
        ---
        from athena.client import Athena

        client = Athena(
            api_key="YOUR_API_KEY",
        )
        client.tools.convert_pdf_to_sheet(
            document_id="doc_9249292-d118-42d3-95b4-00eccfe0754f",
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            method="POST",
            url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v0/tools/convert-pdf-to-sheet"),
            params=jsonable_encoder(
                request_options.get("additional_query_parameters") if request_options is not None else None
            ),
            json=jsonable_encoder({"document_id": document_id})
            if request_options is None or request_options.get("additional_body_parameters") is None
            else {
                **jsonable_encoder({"document_id": document_id}),
                **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
            },
            headers=jsonable_encoder(
                remove_none_from_dict(
                    {
                        **self._client_wrapper.get_headers(),
                        **(request_options.get("additional_headers", {}) if request_options is not None else {}),
                    }
                )
            ),
            timeout=request_options.get("timeout_in_seconds")
            if request_options is not None and request_options.get("timeout_in_seconds") is not None
            else self._client_wrapper.get_timeout(),
            retries=0,
            max_retries=request_options.get("max_retries") if request_options is not None else 0,  # type: ignore
        )
        if 200 <= _response.status_code < 300:
            return pydantic_v1.parse_obj_as(ConvertPdfToSheetOut, _response.json())  # type: ignore
        if _response.status_code == 422:
            raise UnprocessableEntityError(
                pydantic_v1.parse_obj_as(HttpValidationError, _response.json())  # type: ignore
            )
        try:
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def semantic_query(
        self,
        *,
        query: QueryModel,
        table_name: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SemanticQueryOut:
        """
        Parameters:
            - query: QueryModel.

            - table_name: typing.Optional[str].

            - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
        ---
        from athena import FilterModel, FilterOperator, QueryModel, TimeDimensionModel
        from athena.client import Athena

        client = Athena(
            api_key="YOUR_API_KEY",
        )
        client.tools.semantic_query(
            query=QueryModel(
                measures=["count"],
                time_dimensions=[
                    TimeDimensionModel(
                        dimension="dimension",
                        granularity="granularity",
                        date_range=["dateRange"],
                    )
                ],
                dimensions=["manufacturer"],
                filters=[
                    FilterModel(
                        dimension="manufacturer",
                        operator=FilterOperator.EQUALS,
                        values=["values"],
                    )
                ],
            ),
        )
        """
        _request: typing.Dict[str, typing.Any] = {"query": query}
        if table_name is not OMIT:
            _request["table_name"] = table_name
        _response = self._client_wrapper.httpx_client.request(
            method="POST",
            url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v0/tools/strict-semantic-query"),
            params=jsonable_encoder(
                request_options.get("additional_query_parameters") if request_options is not None else None
            ),
            json=jsonable_encoder(_request)
            if request_options is None or request_options.get("additional_body_parameters") is None
            else {
                **jsonable_encoder(_request),
                **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
            },
            headers=jsonable_encoder(
                remove_none_from_dict(
                    {
                        **self._client_wrapper.get_headers(),
                        **(request_options.get("additional_headers", {}) if request_options is not None else {}),
                    }
                )
            ),
            timeout=request_options.get("timeout_in_seconds")
            if request_options is not None and request_options.get("timeout_in_seconds") is not None
            else self._client_wrapper.get_timeout(),
            retries=0,
            max_retries=request_options.get("max_retries") if request_options is not None else 0,  # type: ignore
        )
        if 200 <= _response.status_code < 300:
            return pydantic_v1.parse_obj_as(SemanticQueryOut, _response.json())  # type: ignore
        if _response.status_code == 422:
            raise UnprocessableEntityError(
                pydantic_v1.parse_obj_as(HttpValidationError, _response.json())  # type: ignore
            )
        try:
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)


class AsyncToolsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._client_wrapper = client_wrapper

    async def scrape_url(
        self,
        *,
        url: str,
        params: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> FirecrawlScrapeUrlDataReponseDto:
        """
        Parameters:
            - url: str.

            - params: typing.Optional[typing.Dict[str, typing.Any]].

            - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
        ---
        from athena.client import AsyncAthena

        client = AsyncAthena(
            api_key="YOUR_API_KEY",
        )
        await client.tools.scrape_url(
            url="https://athenaintelligence.ai",
        )
        """
        _request: typing.Dict[str, typing.Any] = {"url": url}
        if params is not OMIT:
            _request["params"] = params
        _response = await self._client_wrapper.httpx_client.request(
            method="POST",
            url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v0/tools/firecrawl/scrape-url"),
            params=jsonable_encoder(
                request_options.get("additional_query_parameters") if request_options is not None else None
            ),
            json=jsonable_encoder(_request)
            if request_options is None or request_options.get("additional_body_parameters") is None
            else {
                **jsonable_encoder(_request),
                **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
            },
            headers=jsonable_encoder(
                remove_none_from_dict(
                    {
                        **self._client_wrapper.get_headers(),
                        **(request_options.get("additional_headers", {}) if request_options is not None else {}),
                    }
                )
            ),
            timeout=request_options.get("timeout_in_seconds")
            if request_options is not None and request_options.get("timeout_in_seconds") is not None
            else self._client_wrapper.get_timeout(),
            retries=0,
            max_retries=request_options.get("max_retries") if request_options is not None else 0,  # type: ignore
        )
        if 200 <= _response.status_code < 300:
            return pydantic_v1.parse_obj_as(FirecrawlScrapeUrlDataReponseDto, _response.json())  # type: ignore
        if _response.status_code == 422:
            raise UnprocessableEntityError(
                pydantic_v1.parse_obj_as(HttpValidationError, _response.json())  # type: ignore
            )
        try:
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def langchain_documents(
        self,
        *,
        document_id: str,
        pagination_limit: typing.Optional[int] = OMIT,
        pagination_offset: typing.Optional[int] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> LangchainDocumentsRequestOut:
        """
        Parameters:
            - document_id: str.

            - pagination_limit: typing.Optional[int].

            - pagination_offset: typing.Optional[int].

            - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
        ---
        from athena.client import AsyncAthena

        client = AsyncAthena(
            api_key="YOUR_API_KEY",
        )
        await client.tools.langchain_documents(
            document_id="doc_9249292-d118-42d3-95b4-00eccfe0754f",
            pagination_limit=250,
            pagination_offset=0,
        )
        """
        _request: typing.Dict[str, typing.Any] = {"document_id": document_id}
        if pagination_limit is not OMIT:
            _request["pagination_limit"] = pagination_limit
        if pagination_offset is not OMIT:
            _request["pagination_offset"] = pagination_offset
        _response = await self._client_wrapper.httpx_client.request(
            method="POST",
            url=urllib.parse.urljoin(
                f"{self._client_wrapper.get_base_url()}/", "api/v0/tools/file/langchain-documents"
            ),
            params=jsonable_encoder(
                request_options.get("additional_query_parameters") if request_options is not None else None
            ),
            json=jsonable_encoder(_request)
            if request_options is None or request_options.get("additional_body_parameters") is None
            else {
                **jsonable_encoder(_request),
                **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
            },
            headers=jsonable_encoder(
                remove_none_from_dict(
                    {
                        **self._client_wrapper.get_headers(),
                        **(request_options.get("additional_headers", {}) if request_options is not None else {}),
                    }
                )
            ),
            timeout=request_options.get("timeout_in_seconds")
            if request_options is not None and request_options.get("timeout_in_seconds") is not None
            else self._client_wrapper.get_timeout(),
            retries=0,
            max_retries=request_options.get("max_retries") if request_options is not None else 0,  # type: ignore
        )
        if 200 <= _response.status_code < 300:
            return pydantic_v1.parse_obj_as(LangchainDocumentsRequestOut, _response.json())  # type: ignore
        if _response.status_code == 422:
            raise UnprocessableEntityError(
                pydantic_v1.parse_obj_as(HttpValidationError, _response.json())  # type: ignore
            )
        try:
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def tool_first_workflow(
        self,
        *,
        model: typing.Optional[LlmModel] = OMIT,
        tool_name: str,
        content: str,
        tool_kwargs: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ExcecuteToolFirstWorkflowOut:
        """
        Parameters:
            - model: typing.Optional[LlmModel].

            - tool_name: str.

            - content: str.

            - tool_kwargs: typing.Optional[typing.Dict[str, typing.Any]].

            - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
        ---
        from athena import LlmModel
        from athena.client import AsyncAthena

        client = AsyncAthena(
            api_key="YOUR_API_KEY",
        )
        await client.tools.tool_first_workflow(
            model=LlmModel.MISTRAL_LARGE_0224,
            tool_name="tavily_search",
            content="summarize the website in one paragraph",
            tool_kwargs={"query": "website: www.athenaintelligence.ai"},
        )
        """
        _request: typing.Dict[str, typing.Any] = {"tool_name": tool_name, "content": content}
        if model is not OMIT:
            _request["model"] = model
        if tool_kwargs is not OMIT:
            _request["tool_kwargs"] = tool_kwargs
        _response = await self._client_wrapper.httpx_client.request(
            method="POST",
            url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v0/tools/first-agent"),
            params=jsonable_encoder(
                request_options.get("additional_query_parameters") if request_options is not None else None
            ),
            json=jsonable_encoder(_request)
            if request_options is None or request_options.get("additional_body_parameters") is None
            else {
                **jsonable_encoder(_request),
                **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
            },
            headers=jsonable_encoder(
                remove_none_from_dict(
                    {
                        **self._client_wrapper.get_headers(),
                        **(request_options.get("additional_headers", {}) if request_options is not None else {}),
                    }
                )
            ),
            timeout=request_options.get("timeout_in_seconds")
            if request_options is not None and request_options.get("timeout_in_seconds") is not None
            else self._client_wrapper.get_timeout(),
            retries=0,
            max_retries=request_options.get("max_retries") if request_options is not None else 0,  # type: ignore
        )
        if 200 <= _response.status_code < 300:
            return pydantic_v1.parse_obj_as(ExcecuteToolFirstWorkflowOut, _response.json())  # type: ignore
        if _response.status_code == 422:
            raise UnprocessableEntityError(
                pydantic_v1.parse_obj_as(HttpValidationError, _response.json())  # type: ignore
            )
        try:
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def researcher(
        self,
        *,
        query: str,
        max_sections: int,
        guidelines: typing.Sequence[str],
        publish_formats: typing.Optional[PublishFormats] = OMIT,
        source: typing.Optional[str] = OMIT,
        athena_document_ids: typing.Optional[typing.Sequence[str]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ResearcherOut:
        """
        Parameters:
            - query: str.

            - max_sections: int.

            - guidelines: typing.Sequence[str].

            - publish_formats: typing.Optional[PublishFormats].

            - source: typing.Optional[str].

            - athena_document_ids: typing.Optional[typing.Sequence[str]].

            - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
        ---
        from athena import PublishFormats
        from athena.client import AsyncAthena

        client = AsyncAthena(
            api_key="YOUR_API_KEY",
        )
        await client.tools.researcher(
            query="Write a report about the company Athena Intelligence.",
            max_sections=10,
            guidelines=[
                "The report MUST be written in APA format",
                "Each sub section MUST include supporting sources using hyperlinks. If none exist, erase the sub section or rewrite it to be a part of the previous section",
                "The report MUST be written in english",
            ],
            publish_formats=PublishFormats(
                markdown=False,
                pdf=True,
                docx=False,
            ),
            source="web",
            athena_document_ids=["doc_1", "doc_2"],
        )
        """
        _request: typing.Dict[str, typing.Any] = {
            "query": query,
            "max_sections": max_sections,
            "guidelines": guidelines,
        }
        if publish_formats is not OMIT:
            _request["publish_formats"] = publish_formats
        if source is not OMIT:
            _request["source"] = source
        if athena_document_ids is not OMIT:
            _request["athena_document_ids"] = athena_document_ids
        _response = await self._client_wrapper.httpx_client.request(
            method="POST",
            url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v0/tools/researcher"),
            params=jsonable_encoder(
                request_options.get("additional_query_parameters") if request_options is not None else None
            ),
            json=jsonable_encoder(_request)
            if request_options is None or request_options.get("additional_body_parameters") is None
            else {
                **jsonable_encoder(_request),
                **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
            },
            headers=jsonable_encoder(
                remove_none_from_dict(
                    {
                        **self._client_wrapper.get_headers(),
                        **(request_options.get("additional_headers", {}) if request_options is not None else {}),
                    }
                )
            ),
            timeout=request_options.get("timeout_in_seconds")
            if request_options is not None and request_options.get("timeout_in_seconds") is not None
            else self._client_wrapper.get_timeout(),
            retries=0,
            max_retries=request_options.get("max_retries") if request_options is not None else 0,  # type: ignore
        )
        if 200 <= _response.status_code < 300:
            return pydantic_v1.parse_obj_as(ResearcherOut, _response.json())  # type: ignore
        if _response.status_code == 422:
            raise UnprocessableEntityError(
                pydantic_v1.parse_obj_as(HttpValidationError, _response.json())  # type: ignore
            )
        try:
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def convert_pdf_to_sheet(
        self, *, document_id: str, request_options: typing.Optional[RequestOptions] = None
    ) -> ConvertPdfToSheetOut:
        """
        Parameters:
            - document_id: str.

            - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
        ---
        from athena.client import AsyncAthena

        client = AsyncAthena(
            api_key="YOUR_API_KEY",
        )
        await client.tools.convert_pdf_to_sheet(
            document_id="doc_9249292-d118-42d3-95b4-00eccfe0754f",
        )
        """
        _response = await self._client_wrapper.httpx_client.request(
            method="POST",
            url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v0/tools/convert-pdf-to-sheet"),
            params=jsonable_encoder(
                request_options.get("additional_query_parameters") if request_options is not None else None
            ),
            json=jsonable_encoder({"document_id": document_id})
            if request_options is None or request_options.get("additional_body_parameters") is None
            else {
                **jsonable_encoder({"document_id": document_id}),
                **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
            },
            headers=jsonable_encoder(
                remove_none_from_dict(
                    {
                        **self._client_wrapper.get_headers(),
                        **(request_options.get("additional_headers", {}) if request_options is not None else {}),
                    }
                )
            ),
            timeout=request_options.get("timeout_in_seconds")
            if request_options is not None and request_options.get("timeout_in_seconds") is not None
            else self._client_wrapper.get_timeout(),
            retries=0,
            max_retries=request_options.get("max_retries") if request_options is not None else 0,  # type: ignore
        )
        if 200 <= _response.status_code < 300:
            return pydantic_v1.parse_obj_as(ConvertPdfToSheetOut, _response.json())  # type: ignore
        if _response.status_code == 422:
            raise UnprocessableEntityError(
                pydantic_v1.parse_obj_as(HttpValidationError, _response.json())  # type: ignore
            )
        try:
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def semantic_query(
        self,
        *,
        query: QueryModel,
        table_name: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SemanticQueryOut:
        """
        Parameters:
            - query: QueryModel.

            - table_name: typing.Optional[str].

            - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
        ---
        from athena import FilterModel, FilterOperator, QueryModel, TimeDimensionModel
        from athena.client import AsyncAthena

        client = AsyncAthena(
            api_key="YOUR_API_KEY",
        )
        await client.tools.semantic_query(
            query=QueryModel(
                measures=["count"],
                time_dimensions=[
                    TimeDimensionModel(
                        dimension="dimension",
                        granularity="granularity",
                        date_range=["dateRange"],
                    )
                ],
                dimensions=["manufacturer"],
                filters=[
                    FilterModel(
                        dimension="manufacturer",
                        operator=FilterOperator.EQUALS,
                        values=["values"],
                    )
                ],
            ),
        )
        """
        _request: typing.Dict[str, typing.Any] = {"query": query}
        if table_name is not OMIT:
            _request["table_name"] = table_name
        _response = await self._client_wrapper.httpx_client.request(
            method="POST",
            url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "api/v0/tools/strict-semantic-query"),
            params=jsonable_encoder(
                request_options.get("additional_query_parameters") if request_options is not None else None
            ),
            json=jsonable_encoder(_request)
            if request_options is None or request_options.get("additional_body_parameters") is None
            else {
                **jsonable_encoder(_request),
                **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
            },
            headers=jsonable_encoder(
                remove_none_from_dict(
                    {
                        **self._client_wrapper.get_headers(),
                        **(request_options.get("additional_headers", {}) if request_options is not None else {}),
                    }
                )
            ),
            timeout=request_options.get("timeout_in_seconds")
            if request_options is not None and request_options.get("timeout_in_seconds") is not None
            else self._client_wrapper.get_timeout(),
            retries=0,
            max_retries=request_options.get("max_retries") if request_options is not None else 0,  # type: ignore
        )
        if 200 <= _response.status_code < 300:
            return pydantic_v1.parse_obj_as(SemanticQueryOut, _response.json())  # type: ignore
        if _response.status_code == 422:
            raise UnprocessableEntityError(
                pydantic_v1.parse_obj_as(HttpValidationError, _response.json())  # type: ignore
            )
        try:
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)
