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

import typing
from ..core.client_wrapper import SyncClientWrapper
from .versions.client import VersionsClient
from .runs.client import RunsClient
from .indicators.client import IndicatorsClient
from ..core.request_options import RequestOptions
from ..types.prompt import Prompt
from ..core.pydantic_utilities import parse_obj_as
from json.decoder import JSONDecodeError
from ..core.api_error import ApiError
from ..types.prompt_created_by import PromptCreatedBy
import datetime as dt
from ..types.prompt_organization import PromptOrganization
from ..types.prompt_associated_projects_item import PromptAssociatedProjectsItem
from ..core.serialization import convert_and_respect_annotation_metadata
from ..core.jsonable_encoder import jsonable_encoder
from .types.prompts_batch_predictions_request_results_item import PromptsBatchPredictionsRequestResultsItem
from .types.prompts_batch_predictions_response import PromptsBatchPredictionsResponse
from .types.prompts_batch_failed_predictions_request_failed_predictions_item import (
    PromptsBatchFailedPredictionsRequestFailedPredictionsItem,
)
from .types.prompts_batch_failed_predictions_response import PromptsBatchFailedPredictionsResponse
from ..core.client_wrapper import AsyncClientWrapper
from .versions.client import AsyncVersionsClient
from .runs.client import AsyncRunsClient
from .indicators.client import AsyncIndicatorsClient

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


class PromptsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._client_wrapper = client_wrapper
        self.versions = VersionsClient(client_wrapper=self._client_wrapper)
        self.runs = RunsClient(client_wrapper=self._client_wrapper)
        self.indicators = IndicatorsClient(client_wrapper=self._client_wrapper)

    def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.List[Prompt]:
        """
        Get a list of prompts.

        Parameters
        ----------
        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.List[Prompt]


        Examples
        --------
        from label_studio_sdk import LabelStudio

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.prompts.list()
        """
        _response = self._client_wrapper.httpx_client.request(
            "api/prompts/",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    typing.List[Prompt],
                    parse_obj_as(
                        type_=typing.List[Prompt],  # type: ignore
                        object_=_response.json(),
                    ),
                )
            _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 create(
        self,
        *,
        title: str,
        input_fields: typing.Sequence[str],
        output_classes: typing.Sequence[str],
        description: typing.Optional[str] = OMIT,
        created_by: typing.Optional[PromptCreatedBy] = OMIT,
        created_at: typing.Optional[dt.datetime] = OMIT,
        updated_at: typing.Optional[dt.datetime] = OMIT,
        organization: typing.Optional[PromptOrganization] = OMIT,
        associated_projects: typing.Optional[typing.Sequence[PromptAssociatedProjectsItem]] = OMIT,
        skill_name: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> Prompt:
        """
        Create a new prompt.

        Parameters
        ----------
        title : str
            Title of the prompt

        input_fields : typing.Sequence[str]
            List of input fields

        output_classes : typing.Sequence[str]
            List of output classes

        description : typing.Optional[str]
            Description of the prompt

        created_by : typing.Optional[PromptCreatedBy]
            User ID of the creator of the prompt

        created_at : typing.Optional[dt.datetime]
            Date and time the prompt was created

        updated_at : typing.Optional[dt.datetime]
            Date and time the prompt was last updated

        organization : typing.Optional[PromptOrganization]
            Organization ID of the prompt

        associated_projects : typing.Optional[typing.Sequence[PromptAssociatedProjectsItem]]
            List of associated projects IDs or objects

        skill_name : typing.Optional[str]
            Name of the skill

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        Prompt


        Examples
        --------
        from label_studio_sdk import LabelStudio

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.prompts.create(
            title="title",
            input_fields=["input_fields"],
            output_classes=["output_classes"],
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            "api/prompts/",
            method="POST",
            json={
                "title": title,
                "description": description,
                "created_by": convert_and_respect_annotation_metadata(
                    object_=created_by, annotation=PromptCreatedBy, direction="write"
                ),
                "created_at": created_at,
                "updated_at": updated_at,
                "organization": convert_and_respect_annotation_metadata(
                    object_=organization, annotation=PromptOrganization, direction="write"
                ),
                "input_fields": input_fields,
                "output_classes": output_classes,
                "associated_projects": convert_and_respect_annotation_metadata(
                    object_=associated_projects,
                    annotation=typing.Sequence[PromptAssociatedProjectsItem],
                    direction="write",
                ),
                "skill_name": skill_name,
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    Prompt,
                    parse_obj_as(
                        type_=Prompt,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            _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 get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> Prompt:
        """
        Get a prompt by ID.

        Parameters
        ----------
        id : int
            Prompt ID

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        Prompt


        Examples
        --------
        from label_studio_sdk import LabelStudio

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.prompts.get(
            id=1,
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/prompts/{jsonable_encoder(id)}",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    Prompt,
                    parse_obj_as(
                        type_=Prompt,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            _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 delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
        """
        Delete a prompt by ID.

        Parameters
        ----------
        id : int
            Prompt ID

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        None

        Examples
        --------
        from label_studio_sdk import LabelStudio

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.prompts.delete(
            id=1,
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/prompts/{jsonable_encoder(id)}",
            method="DELETE",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return
            _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 update(
        self,
        id: int,
        *,
        title: str,
        input_fields: typing.Sequence[str],
        output_classes: typing.Sequence[str],
        description: typing.Optional[str] = OMIT,
        created_by: typing.Optional[PromptCreatedBy] = OMIT,
        created_at: typing.Optional[dt.datetime] = OMIT,
        updated_at: typing.Optional[dt.datetime] = OMIT,
        organization: typing.Optional[PromptOrganization] = OMIT,
        associated_projects: typing.Optional[typing.Sequence[PromptAssociatedProjectsItem]] = OMIT,
        skill_name: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> Prompt:
        """
        Update a prompt by ID.

        Parameters
        ----------
        id : int
            Prompt ID

        title : str
            Title of the prompt

        input_fields : typing.Sequence[str]
            List of input fields

        output_classes : typing.Sequence[str]
            List of output classes

        description : typing.Optional[str]
            Description of the prompt

        created_by : typing.Optional[PromptCreatedBy]
            User ID of the creator of the prompt

        created_at : typing.Optional[dt.datetime]
            Date and time the prompt was created

        updated_at : typing.Optional[dt.datetime]
            Date and time the prompt was last updated

        organization : typing.Optional[PromptOrganization]
            Organization ID of the prompt

        associated_projects : typing.Optional[typing.Sequence[PromptAssociatedProjectsItem]]
            List of associated projects IDs or objects

        skill_name : typing.Optional[str]
            Name of the skill

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        Prompt


        Examples
        --------
        from label_studio_sdk import LabelStudio

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.prompts.update(
            id=1,
            title="title",
            input_fields=["input_fields"],
            output_classes=["output_classes"],
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/prompts/{jsonable_encoder(id)}",
            method="PATCH",
            json={
                "title": title,
                "description": description,
                "created_by": convert_and_respect_annotation_metadata(
                    object_=created_by, annotation=PromptCreatedBy, direction="write"
                ),
                "created_at": created_at,
                "updated_at": updated_at,
                "organization": convert_and_respect_annotation_metadata(
                    object_=organization, annotation=PromptOrganization, direction="write"
                ),
                "input_fields": input_fields,
                "output_classes": output_classes,
                "associated_projects": convert_and_respect_annotation_metadata(
                    object_=associated_projects,
                    annotation=typing.Sequence[PromptAssociatedProjectsItem],
                    direction="write",
                ),
                "skill_name": skill_name,
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    Prompt,
                    parse_obj_as(
                        type_=Prompt,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            _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 batch_predictions(
        self,
        *,
        num_predictions: typing.Optional[int] = None,
        modelrun_id: typing.Optional[int] = OMIT,
        results: typing.Optional[typing.Sequence[PromptsBatchPredictionsRequestResultsItem]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PromptsBatchPredictionsResponse:
        """
        Create a new batch prediction.

        Parameters
        ----------
        num_predictions : typing.Optional[int]
            Number of predictions being sent

        modelrun_id : typing.Optional[int]
            Model Run ID to associate the prediction with

        results : typing.Optional[typing.Sequence[PromptsBatchPredictionsRequestResultsItem]]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        PromptsBatchPredictionsResponse


        Examples
        --------
        from label_studio_sdk import LabelStudio

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.prompts.batch_predictions()
        """
        _response = self._client_wrapper.httpx_client.request(
            "api/model-run/batch-predictions",
            method="POST",
            params={
                "num_predictions": num_predictions,
            },
            json={
                "modelrun_id": modelrun_id,
                "results": convert_and_respect_annotation_metadata(
                    object_=results,
                    annotation=typing.Sequence[PromptsBatchPredictionsRequestResultsItem],
                    direction="write",
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    PromptsBatchPredictionsResponse,
                    parse_obj_as(
                        type_=PromptsBatchPredictionsResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            _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 batch_failed_predictions(
        self,
        *,
        num_failed_predictions: typing.Optional[int] = None,
        modelrun_id: typing.Optional[int] = OMIT,
        failed_predictions: typing.Optional[
            typing.Sequence[PromptsBatchFailedPredictionsRequestFailedPredictionsItem]
        ] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PromptsBatchFailedPredictionsResponse:
        """
        Create a new batch of failed predictions.

        Parameters
        ----------
        num_failed_predictions : typing.Optional[int]
            Number of failed predictions being sent

        modelrun_id : typing.Optional[int]
            Model Run ID where the failed predictions came from

        failed_predictions : typing.Optional[typing.Sequence[PromptsBatchFailedPredictionsRequestFailedPredictionsItem]]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        PromptsBatchFailedPredictionsResponse


        Examples
        --------
        from label_studio_sdk import LabelStudio

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.prompts.batch_failed_predictions()
        """
        _response = self._client_wrapper.httpx_client.request(
            "api/model-run/batch-failed-predictions",
            method="POST",
            params={
                "num_failed_predictions": num_failed_predictions,
            },
            json={
                "modelrun_id": modelrun_id,
                "failed_predictions": convert_and_respect_annotation_metadata(
                    object_=failed_predictions,
                    annotation=typing.Sequence[PromptsBatchFailedPredictionsRequestFailedPredictionsItem],
                    direction="write",
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    PromptsBatchFailedPredictionsResponse,
                    parse_obj_as(
                        type_=PromptsBatchFailedPredictionsResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            _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 AsyncPromptsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._client_wrapper = client_wrapper
        self.versions = AsyncVersionsClient(client_wrapper=self._client_wrapper)
        self.runs = AsyncRunsClient(client_wrapper=self._client_wrapper)
        self.indicators = AsyncIndicatorsClient(client_wrapper=self._client_wrapper)

    async def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.List[Prompt]:
        """
        Get a list of prompts.

        Parameters
        ----------
        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        typing.List[Prompt]


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.prompts.list()


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            "api/prompts/",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    typing.List[Prompt],
                    parse_obj_as(
                        type_=typing.List[Prompt],  # type: ignore
                        object_=_response.json(),
                    ),
                )
            _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 create(
        self,
        *,
        title: str,
        input_fields: typing.Sequence[str],
        output_classes: typing.Sequence[str],
        description: typing.Optional[str] = OMIT,
        created_by: typing.Optional[PromptCreatedBy] = OMIT,
        created_at: typing.Optional[dt.datetime] = OMIT,
        updated_at: typing.Optional[dt.datetime] = OMIT,
        organization: typing.Optional[PromptOrganization] = OMIT,
        associated_projects: typing.Optional[typing.Sequence[PromptAssociatedProjectsItem]] = OMIT,
        skill_name: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> Prompt:
        """
        Create a new prompt.

        Parameters
        ----------
        title : str
            Title of the prompt

        input_fields : typing.Sequence[str]
            List of input fields

        output_classes : typing.Sequence[str]
            List of output classes

        description : typing.Optional[str]
            Description of the prompt

        created_by : typing.Optional[PromptCreatedBy]
            User ID of the creator of the prompt

        created_at : typing.Optional[dt.datetime]
            Date and time the prompt was created

        updated_at : typing.Optional[dt.datetime]
            Date and time the prompt was last updated

        organization : typing.Optional[PromptOrganization]
            Organization ID of the prompt

        associated_projects : typing.Optional[typing.Sequence[PromptAssociatedProjectsItem]]
            List of associated projects IDs or objects

        skill_name : typing.Optional[str]
            Name of the skill

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        Prompt


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.prompts.create(
                title="title",
                input_fields=["input_fields"],
                output_classes=["output_classes"],
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            "api/prompts/",
            method="POST",
            json={
                "title": title,
                "description": description,
                "created_by": convert_and_respect_annotation_metadata(
                    object_=created_by, annotation=PromptCreatedBy, direction="write"
                ),
                "created_at": created_at,
                "updated_at": updated_at,
                "organization": convert_and_respect_annotation_metadata(
                    object_=organization, annotation=PromptOrganization, direction="write"
                ),
                "input_fields": input_fields,
                "output_classes": output_classes,
                "associated_projects": convert_and_respect_annotation_metadata(
                    object_=associated_projects,
                    annotation=typing.Sequence[PromptAssociatedProjectsItem],
                    direction="write",
                ),
                "skill_name": skill_name,
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    Prompt,
                    parse_obj_as(
                        type_=Prompt,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            _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 get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> Prompt:
        """
        Get a prompt by ID.

        Parameters
        ----------
        id : int
            Prompt ID

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        Prompt


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.prompts.get(
                id=1,
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/prompts/{jsonable_encoder(id)}",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    Prompt,
                    parse_obj_as(
                        type_=Prompt,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            _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 delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
        """
        Delete a prompt by ID.

        Parameters
        ----------
        id : int
            Prompt ID

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.prompts.delete(
                id=1,
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/prompts/{jsonable_encoder(id)}",
            method="DELETE",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return
            _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 update(
        self,
        id: int,
        *,
        title: str,
        input_fields: typing.Sequence[str],
        output_classes: typing.Sequence[str],
        description: typing.Optional[str] = OMIT,
        created_by: typing.Optional[PromptCreatedBy] = OMIT,
        created_at: typing.Optional[dt.datetime] = OMIT,
        updated_at: typing.Optional[dt.datetime] = OMIT,
        organization: typing.Optional[PromptOrganization] = OMIT,
        associated_projects: typing.Optional[typing.Sequence[PromptAssociatedProjectsItem]] = OMIT,
        skill_name: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> Prompt:
        """
        Update a prompt by ID.

        Parameters
        ----------
        id : int
            Prompt ID

        title : str
            Title of the prompt

        input_fields : typing.Sequence[str]
            List of input fields

        output_classes : typing.Sequence[str]
            List of output classes

        description : typing.Optional[str]
            Description of the prompt

        created_by : typing.Optional[PromptCreatedBy]
            User ID of the creator of the prompt

        created_at : typing.Optional[dt.datetime]
            Date and time the prompt was created

        updated_at : typing.Optional[dt.datetime]
            Date and time the prompt was last updated

        organization : typing.Optional[PromptOrganization]
            Organization ID of the prompt

        associated_projects : typing.Optional[typing.Sequence[PromptAssociatedProjectsItem]]
            List of associated projects IDs or objects

        skill_name : typing.Optional[str]
            Name of the skill

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        Prompt


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.prompts.update(
                id=1,
                title="title",
                input_fields=["input_fields"],
                output_classes=["output_classes"],
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/prompts/{jsonable_encoder(id)}",
            method="PATCH",
            json={
                "title": title,
                "description": description,
                "created_by": convert_and_respect_annotation_metadata(
                    object_=created_by, annotation=PromptCreatedBy, direction="write"
                ),
                "created_at": created_at,
                "updated_at": updated_at,
                "organization": convert_and_respect_annotation_metadata(
                    object_=organization, annotation=PromptOrganization, direction="write"
                ),
                "input_fields": input_fields,
                "output_classes": output_classes,
                "associated_projects": convert_and_respect_annotation_metadata(
                    object_=associated_projects,
                    annotation=typing.Sequence[PromptAssociatedProjectsItem],
                    direction="write",
                ),
                "skill_name": skill_name,
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    Prompt,
                    parse_obj_as(
                        type_=Prompt,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            _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 batch_predictions(
        self,
        *,
        num_predictions: typing.Optional[int] = None,
        modelrun_id: typing.Optional[int] = OMIT,
        results: typing.Optional[typing.Sequence[PromptsBatchPredictionsRequestResultsItem]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PromptsBatchPredictionsResponse:
        """
        Create a new batch prediction.

        Parameters
        ----------
        num_predictions : typing.Optional[int]
            Number of predictions being sent

        modelrun_id : typing.Optional[int]
            Model Run ID to associate the prediction with

        results : typing.Optional[typing.Sequence[PromptsBatchPredictionsRequestResultsItem]]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        PromptsBatchPredictionsResponse


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.prompts.batch_predictions()


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            "api/model-run/batch-predictions",
            method="POST",
            params={
                "num_predictions": num_predictions,
            },
            json={
                "modelrun_id": modelrun_id,
                "results": convert_and_respect_annotation_metadata(
                    object_=results,
                    annotation=typing.Sequence[PromptsBatchPredictionsRequestResultsItem],
                    direction="write",
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    PromptsBatchPredictionsResponse,
                    parse_obj_as(
                        type_=PromptsBatchPredictionsResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            _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 batch_failed_predictions(
        self,
        *,
        num_failed_predictions: typing.Optional[int] = None,
        modelrun_id: typing.Optional[int] = OMIT,
        failed_predictions: typing.Optional[
            typing.Sequence[PromptsBatchFailedPredictionsRequestFailedPredictionsItem]
        ] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PromptsBatchFailedPredictionsResponse:
        """
        Create a new batch of failed predictions.

        Parameters
        ----------
        num_failed_predictions : typing.Optional[int]
            Number of failed predictions being sent

        modelrun_id : typing.Optional[int]
            Model Run ID where the failed predictions came from

        failed_predictions : typing.Optional[typing.Sequence[PromptsBatchFailedPredictionsRequestFailedPredictionsItem]]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        PromptsBatchFailedPredictionsResponse


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.prompts.batch_failed_predictions()


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            "api/model-run/batch-failed-predictions",
            method="POST",
            params={
                "num_failed_predictions": num_failed_predictions,
            },
            json={
                "modelrun_id": modelrun_id,
                "failed_predictions": convert_and_respect_annotation_metadata(
                    object_=failed_predictions,
                    annotation=typing.Sequence[PromptsBatchFailedPredictionsRequestFailedPredictionsItem],
                    direction="write",
                ),
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    PromptsBatchFailedPredictionsResponse,
                    parse_obj_as(
                        type_=PromptsBatchFailedPredictionsResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            _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)
