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

from ...core.client_wrapper import SyncClientWrapper
import typing
from ...core.request_options import RequestOptions
from .types.model_version_annotator_agreement_stats_response import ModelVersionAnnotatorAgreementStatsResponse
from ...core.jsonable_encoder import jsonable_encoder
from ...core.unchecked_base_model import construct_type
from json.decoder import JSONDecodeError
from ...core.api_error import ApiError
from .types.model_version_ground_truth_agreement_stats_response import ModelVersionGroundTruthAgreementStatsResponse
from .types.model_version_prediction_agreement_stats_response import ModelVersionPredictionAgreementStatsResponse
from .types.iaa_stats_response import IaaStatsResponse
from .types.users_ground_truth_agreement_stats_response import UsersGroundTruthAgreementStatsResponse
from .types.agreement_annotator_stats_response import AgreementAnnotatorStatsResponse
from .types.agreement_annotators_stats_response import AgreementAnnotatorsStatsResponse
from .types.data_filters_stats_response import DataFiltersStatsResponse
from .types.finished_tasks_stats_response import FinishedTasksStatsResponse
from .types.lead_time_stats_response import LeadTimeStatsResponse
from .types.total_agreement_stats_response import TotalAgreementStatsResponse
from .types.users_prediction_agreement_stats_response import UsersPredictionAgreementStatsResponse
from .types.users_review_score_stats_response import UsersReviewScoreStatsResponse
from .types.user_prediction_agreement_stats_response import UserPredictionAgreementStatsResponse
from .types.user_review_score_stats_response import UserReviewScoreStatsResponse
from .types.user_ground_truth_agreement_stats_response import UserGroundTruthAgreementStatsResponse
from ...core.client_wrapper import AsyncClientWrapper


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

    def model_version_annotator_agreement(
        self, id: int, model_version: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> ModelVersionAnnotatorAgreementStatsResponse:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Get agreement between a given model version and all annotators in the project for overlapping tasks.

        Parameters
        ----------
        id : int

        model_version : str

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

        Returns
        -------
        ModelVersionAnnotatorAgreementStatsResponse
            Model-version overall agreement vs annotators

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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.projects.stats.model_version_annotator_agreement(
            id=1,
            model_version="model_version",
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/projects/{jsonable_encoder(id)}/model-stats/{jsonable_encoder(model_version)}/agreement",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    ModelVersionAnnotatorAgreementStatsResponse,
                    construct_type(
                        type_=ModelVersionAnnotatorAgreementStatsResponse,  # 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 model_version_ground_truth_agreement(
        self,
        id: int,
        model_version: str,
        *,
        per_label: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ModelVersionGroundTruthAgreementStatsResponse:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Get agreement between a given model version and ground truth annotations in the project for overlapping tasks.

        Parameters
        ----------
        id : int

        model_version : str

        per_label : typing.Optional[bool]
            Calculate agreement per label

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

        Returns
        -------
        ModelVersionGroundTruthAgreementStatsResponse
            Model-version ground truth agreement

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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.projects.stats.model_version_ground_truth_agreement(
            id=1,
            model_version="model_version",
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/projects/{jsonable_encoder(id)}/model-stats/{jsonable_encoder(model_version)}/agreement-groundtruth",
            method="GET",
            params={
                "per_label": per_label,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    ModelVersionGroundTruthAgreementStatsResponse,
                    construct_type(
                        type_=ModelVersionGroundTruthAgreementStatsResponse,  # 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 model_version_prediction_agreement(
        self,
        id: int,
        model_version: str,
        *,
        per_label: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ModelVersionPredictionAgreementStatsResponse:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Get agreement between a given model version and all other model versions in the project for overlapping tasks.

        Parameters
        ----------
        id : int

        model_version : str

        per_label : typing.Optional[bool]
            Calculate agreement per label

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

        Returns
        -------
        ModelVersionPredictionAgreementStatsResponse
            Model-version prediction agreement

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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.projects.stats.model_version_prediction_agreement(
            id=1,
            model_version="model_version",
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/projects/{jsonable_encoder(id)}/model-stats/{jsonable_encoder(model_version)}/prediction",
            method="GET",
            params={
                "per_label": per_label,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    ModelVersionPredictionAgreementStatsResponse,
                    construct_type(
                        type_=ModelVersionPredictionAgreementStatsResponse,  # 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 iaa(
        self,
        id: int,
        *,
        expand: typing.Optional[str] = None,
        per_label: typing.Optional[bool] = None,
        std: typing.Optional[bool] = None,
        task: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> IaaStatsResponse:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Get Inter-Annotator Agreement (IAA) matrix for a project, showing agreement between all annotators.

        Parameters
        ----------
        id : int

        expand : typing.Optional[str]
            Comma-separated list of fields to expand

        per_label : typing.Optional[bool]
            Calculate IAA per label

        std : typing.Optional[bool]
            Include standard deviation in results

        task : typing.Optional[str]
            Comma-separated list of task IDs to filter by

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

        Returns
        -------
        IaaStatsResponse
            Inter-Annotator Agreement matrix

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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.projects.stats.iaa(
            id=1,
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/projects/{jsonable_encoder(id)}/stats/IAA",
            method="GET",
            params={
                "expand": expand,
                "per_label": per_label,
                "std": std,
                "task": task,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    IaaStatsResponse,
                    construct_type(
                        type_=IaaStatsResponse,  # 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 users_ground_truth_agreement(
        self,
        id: int,
        *,
        ids: str,
        per_label: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UsersGroundTruthAgreementStatsResponse:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Get ground truth agreement statistics for multiple users within a project.

        Parameters
        ----------
        id : int

        ids : str
            Comma separated list of user IDs to get ground truth agreement for

        per_label : typing.Optional[bool]
            Per label

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

        Returns
        -------
        UsersGroundTruthAgreementStatsResponse
            Ground truth agreement statistics for multiple users

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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.projects.stats.users_ground_truth_agreement(
            id=1,
            ids="ids",
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/projects/{jsonable_encoder(id)}/stats/agreement-groundtruth",
            method="GET",
            params={
                "ids": ids,
                "per_label": per_label,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    UsersGroundTruthAgreementStatsResponse,
                    construct_type(
                        type_=UsersGroundTruthAgreementStatsResponse,  # 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 agreement_annotator(
        self, id: int, user_id: int, *, request_options: typing.Optional[RequestOptions] = None
    ) -> AgreementAnnotatorStatsResponse:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Get agreement statistics for a specific annotator within a project.

        Parameters
        ----------
        id : int

        user_id : int

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

        Returns
        -------
        AgreementAnnotatorStatsResponse
            Individual annotator agreement statistics

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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.projects.stats.agreement_annotator(
            id=1,
            user_id=1,
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/projects/{jsonable_encoder(id)}/stats/agreement_annotator/{jsonable_encoder(user_id)}",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    AgreementAnnotatorStatsResponse,
                    construct_type(
                        type_=AgreementAnnotatorStatsResponse,  # 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 agreement_annotators(
        self, id: int, *, ids: str, request_options: typing.Optional[RequestOptions] = None
    ) -> AgreementAnnotatorsStatsResponse:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Get agreement statistics for multiple annotators within a project.

        Parameters
        ----------
        id : int

        ids : str
            Comma separated list of annotator user IDs to get agreement scores for

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

        Returns
        -------
        AgreementAnnotatorsStatsResponse
            Multiple annotator agreement statistics

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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.projects.stats.agreement_annotators(
            id=1,
            ids="ids",
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/projects/{jsonable_encoder(id)}/stats/agreement_annotators",
            method="GET",
            params={
                "ids": ids,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    AgreementAnnotatorsStatsResponse,
                    construct_type(
                        type_=AgreementAnnotatorsStatsResponse,  # 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 data_filters(
        self, id: int, *, request_options: typing.Optional[RequestOptions] = None
    ) -> DataFiltersStatsResponse:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Get statistics about user data filters and their usage within a project.

        Parameters
        ----------
        id : int

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

        Returns
        -------
        DataFiltersStatsResponse
            User data filter statistics

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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.projects.stats.data_filters(
            id=1,
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/projects/{jsonable_encoder(id)}/stats/data_filter",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    DataFiltersStatsResponse,
                    construct_type(
                        type_=DataFiltersStatsResponse,  # 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 finished_tasks(
        self, id: int, *, user_pk: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None
    ) -> FinishedTasksStatsResponse:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Get statistics about finished tasks for a project.

        Parameters
        ----------
        id : int

        user_pk : typing.Optional[int]
            User ID to filter statistics by (optional)

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

        Returns
        -------
        FinishedTasksStatsResponse
            Finished tasks statistics

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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.projects.stats.finished_tasks(
            id=1,
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/projects/{jsonable_encoder(id)}/stats/finished",
            method="GET",
            params={
                "user_pk": user_pk,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    FinishedTasksStatsResponse,
                    construct_type(
                        type_=FinishedTasksStatsResponse,  # 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 lead_time(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> LeadTimeStatsResponse:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Get lead time statistics across the project, including average annotation time.

        Parameters
        ----------
        id : int

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

        Returns
        -------
        LeadTimeStatsResponse
            Lead time statistics

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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.projects.stats.lead_time(
            id=1,
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/projects/{jsonable_encoder(id)}/stats/lead_time",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    LeadTimeStatsResponse,
                    construct_type(
                        type_=LeadTimeStatsResponse,  # 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 total_agreement(
        self,
        id: int,
        *,
        per_label: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> TotalAgreementStatsResponse:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Overall or per-label total agreement across the project.

        NOTE: due to an open issue in Fern, SDK clients will raise ApiError upon handling a 204 response. As a workaround, wrap call to this function in a try-except block.

        Parameters
        ----------
        id : int

        per_label : typing.Optional[bool]
            Return agreement per label

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

        Returns
        -------
        TotalAgreementStatsResponse
            Total agreement

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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.projects.stats.total_agreement(
            id=1,
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/projects/{jsonable_encoder(id)}/stats/total_agreement",
            method="GET",
            params={
                "per_label": per_label,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    TotalAgreementStatsResponse,
                    construct_type(
                        type_=TotalAgreementStatsResponse,  # 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 update_stats(
        self,
        id: int,
        *,
        stat_type: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Dict[str, typing.Optional[typing.Any]]:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Start stats recalculation for given project

        Parameters
        ----------
        id : int

        stat_type : typing.Optional[str]
            Stat type to recalculate. Possible values: label, stats

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

        Returns
        -------
        typing.Dict[str, typing.Optional[typing.Any]]
            Successful response returns job id

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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.projects.stats.update_stats(
            id=1,
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/projects/{jsonable_encoder(id)}/update-stats",
            method="GET",
            params={
                "stat_type": stat_type,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    typing.Dict[str, typing.Optional[typing.Any]],
                    construct_type(
                        type_=typing.Dict[str, typing.Optional[typing.Any]],  # 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 users_prediction_agreement(
        self,
        id: int,
        *,
        ids: str,
        per_label: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UsersPredictionAgreementStatsResponse:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Get prediction agreement statistics for multiple annotators within a project.

        Parameters
        ----------
        id : int

        ids : str
            Comma separated list of annotator user IDs to get agreement scores for

        per_label : typing.Optional[bool]
            Per label

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

        Returns
        -------
        UsersPredictionAgreementStatsResponse
            Prediction agreement statistics for multiple annotators

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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.projects.stats.users_prediction_agreement(
            id=1,
            ids="ids",
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/projects/{jsonable_encoder(id)}/user-stats/prediction",
            method="GET",
            params={
                "ids": ids,
                "per_label": per_label,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    UsersPredictionAgreementStatsResponse,
                    construct_type(
                        type_=UsersPredictionAgreementStatsResponse,  # 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 users_review_score(
        self,
        id: int,
        *,
        ids: str,
        per_label: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UsersReviewScoreStatsResponse:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Get review score and performance score statistics for multiple annotators within a project.

        Parameters
        ----------
        id : int

        ids : str
            Comma separated list of annotator user IDs to get review scores for

        per_label : typing.Optional[bool]
            Per label

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

        Returns
        -------
        UsersReviewScoreStatsResponse
            Review scores and performance scores for multiple annotators

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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.projects.stats.users_review_score(
            id=1,
            ids="ids",
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/projects/{jsonable_encoder(id)}/user-stats/review_score",
            method="GET",
            params={
                "ids": ids,
                "per_label": per_label,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    UsersReviewScoreStatsResponse,
                    construct_type(
                        type_=UsersReviewScoreStatsResponse,  # 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 user_prediction_agreement(
        self,
        id: int,
        user_pk: int,
        *,
        per_label: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UserPredictionAgreementStatsResponse:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Get prediction agreement statistics for a specific user within a project.

        Parameters
        ----------
        id : int

        user_pk : int

        per_label : typing.Optional[bool]
            Calculate agreement per label

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

        Returns
        -------
        UserPredictionAgreementStatsResponse
            Individual user prediction agreement statistics

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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.projects.stats.user_prediction_agreement(
            id=1,
            user_pk=1,
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/projects/{jsonable_encoder(id)}/user-stats/{jsonable_encoder(user_pk)}/prediction",
            method="GET",
            params={
                "per_label": per_label,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    UserPredictionAgreementStatsResponse,
                    construct_type(
                        type_=UserPredictionAgreementStatsResponse,  # 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 user_review_score(
        self,
        id: int,
        user_pk: int,
        *,
        per_label: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UserReviewScoreStatsResponse:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Get review score statistics for a specific user within a project.

        Parameters
        ----------
        id : int

        user_pk : int

        per_label : typing.Optional[bool]
            Calculate agreement per label

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

        Returns
        -------
        UserReviewScoreStatsResponse
            Individual user review score statistics

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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.projects.stats.user_review_score(
            id=1,
            user_pk=1,
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/projects/{jsonable_encoder(id)}/user-stats/{jsonable_encoder(user_pk)}/review_score",
            method="GET",
            params={
                "per_label": per_label,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    UserReviewScoreStatsResponse,
                    construct_type(
                        type_=UserReviewScoreStatsResponse,  # 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 user_ground_truth_agreement(
        self,
        id: int,
        user_pk: int,
        *,
        per_label: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UserGroundTruthAgreementStatsResponse:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Get ground truth agreement statistics for a specific user within a project.

        Parameters
        ----------
        id : int

        user_pk : int

        per_label : typing.Optional[bool]
            Calculate agreement per label

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

        Returns
        -------
        UserGroundTruthAgreementStatsResponse
            Individual user ground truth agreement statistics

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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.projects.stats.user_ground_truth_agreement(
            id=1,
            user_pk=1,
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/projects/{jsonable_encoder(id)}/users/{jsonable_encoder(user_pk)}/stats/agreement-groundtruth",
            method="GET",
            params={
                "per_label": per_label,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    UserGroundTruthAgreementStatsResponse,
                    construct_type(
                        type_=UserGroundTruthAgreementStatsResponse,  # 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 AsyncStatsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._client_wrapper = client_wrapper

    async def model_version_annotator_agreement(
        self, id: int, model_version: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> ModelVersionAnnotatorAgreementStatsResponse:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Get agreement between a given model version and all annotators in the project for overlapping tasks.

        Parameters
        ----------
        id : int

        model_version : str

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

        Returns
        -------
        ModelVersionAnnotatorAgreementStatsResponse
            Model-version overall agreement vs annotators

        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.projects.stats.model_version_annotator_agreement(
                id=1,
                model_version="model_version",
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/projects/{jsonable_encoder(id)}/model-stats/{jsonable_encoder(model_version)}/agreement",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    ModelVersionAnnotatorAgreementStatsResponse,
                    construct_type(
                        type_=ModelVersionAnnotatorAgreementStatsResponse,  # 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 model_version_ground_truth_agreement(
        self,
        id: int,
        model_version: str,
        *,
        per_label: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ModelVersionGroundTruthAgreementStatsResponse:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Get agreement between a given model version and ground truth annotations in the project for overlapping tasks.

        Parameters
        ----------
        id : int

        model_version : str

        per_label : typing.Optional[bool]
            Calculate agreement per label

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

        Returns
        -------
        ModelVersionGroundTruthAgreementStatsResponse
            Model-version ground truth agreement

        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.projects.stats.model_version_ground_truth_agreement(
                id=1,
                model_version="model_version",
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/projects/{jsonable_encoder(id)}/model-stats/{jsonable_encoder(model_version)}/agreement-groundtruth",
            method="GET",
            params={
                "per_label": per_label,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    ModelVersionGroundTruthAgreementStatsResponse,
                    construct_type(
                        type_=ModelVersionGroundTruthAgreementStatsResponse,  # 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 model_version_prediction_agreement(
        self,
        id: int,
        model_version: str,
        *,
        per_label: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ModelVersionPredictionAgreementStatsResponse:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Get agreement between a given model version and all other model versions in the project for overlapping tasks.

        Parameters
        ----------
        id : int

        model_version : str

        per_label : typing.Optional[bool]
            Calculate agreement per label

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

        Returns
        -------
        ModelVersionPredictionAgreementStatsResponse
            Model-version prediction agreement

        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.projects.stats.model_version_prediction_agreement(
                id=1,
                model_version="model_version",
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/projects/{jsonable_encoder(id)}/model-stats/{jsonable_encoder(model_version)}/prediction",
            method="GET",
            params={
                "per_label": per_label,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    ModelVersionPredictionAgreementStatsResponse,
                    construct_type(
                        type_=ModelVersionPredictionAgreementStatsResponse,  # 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 iaa(
        self,
        id: int,
        *,
        expand: typing.Optional[str] = None,
        per_label: typing.Optional[bool] = None,
        std: typing.Optional[bool] = None,
        task: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> IaaStatsResponse:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Get Inter-Annotator Agreement (IAA) matrix for a project, showing agreement between all annotators.

        Parameters
        ----------
        id : int

        expand : typing.Optional[str]
            Comma-separated list of fields to expand

        per_label : typing.Optional[bool]
            Calculate IAA per label

        std : typing.Optional[bool]
            Include standard deviation in results

        task : typing.Optional[str]
            Comma-separated list of task IDs to filter by

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

        Returns
        -------
        IaaStatsResponse
            Inter-Annotator Agreement matrix

        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.projects.stats.iaa(
                id=1,
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/projects/{jsonable_encoder(id)}/stats/IAA",
            method="GET",
            params={
                "expand": expand,
                "per_label": per_label,
                "std": std,
                "task": task,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    IaaStatsResponse,
                    construct_type(
                        type_=IaaStatsResponse,  # 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 users_ground_truth_agreement(
        self,
        id: int,
        *,
        ids: str,
        per_label: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UsersGroundTruthAgreementStatsResponse:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Get ground truth agreement statistics for multiple users within a project.

        Parameters
        ----------
        id : int

        ids : str
            Comma separated list of user IDs to get ground truth agreement for

        per_label : typing.Optional[bool]
            Per label

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

        Returns
        -------
        UsersGroundTruthAgreementStatsResponse
            Ground truth agreement statistics for multiple users

        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.projects.stats.users_ground_truth_agreement(
                id=1,
                ids="ids",
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/projects/{jsonable_encoder(id)}/stats/agreement-groundtruth",
            method="GET",
            params={
                "ids": ids,
                "per_label": per_label,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    UsersGroundTruthAgreementStatsResponse,
                    construct_type(
                        type_=UsersGroundTruthAgreementStatsResponse,  # 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 agreement_annotator(
        self, id: int, user_id: int, *, request_options: typing.Optional[RequestOptions] = None
    ) -> AgreementAnnotatorStatsResponse:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Get agreement statistics for a specific annotator within a project.

        Parameters
        ----------
        id : int

        user_id : int

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

        Returns
        -------
        AgreementAnnotatorStatsResponse
            Individual annotator agreement statistics

        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.projects.stats.agreement_annotator(
                id=1,
                user_id=1,
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/projects/{jsonable_encoder(id)}/stats/agreement_annotator/{jsonable_encoder(user_id)}",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    AgreementAnnotatorStatsResponse,
                    construct_type(
                        type_=AgreementAnnotatorStatsResponse,  # 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 agreement_annotators(
        self, id: int, *, ids: str, request_options: typing.Optional[RequestOptions] = None
    ) -> AgreementAnnotatorsStatsResponse:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Get agreement statistics for multiple annotators within a project.

        Parameters
        ----------
        id : int

        ids : str
            Comma separated list of annotator user IDs to get agreement scores for

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

        Returns
        -------
        AgreementAnnotatorsStatsResponse
            Multiple annotator agreement statistics

        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.projects.stats.agreement_annotators(
                id=1,
                ids="ids",
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/projects/{jsonable_encoder(id)}/stats/agreement_annotators",
            method="GET",
            params={
                "ids": ids,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    AgreementAnnotatorsStatsResponse,
                    construct_type(
                        type_=AgreementAnnotatorsStatsResponse,  # 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 data_filters(
        self, id: int, *, request_options: typing.Optional[RequestOptions] = None
    ) -> DataFiltersStatsResponse:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Get statistics about user data filters and their usage within a project.

        Parameters
        ----------
        id : int

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

        Returns
        -------
        DataFiltersStatsResponse
            User data filter statistics

        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.projects.stats.data_filters(
                id=1,
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/projects/{jsonable_encoder(id)}/stats/data_filter",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    DataFiltersStatsResponse,
                    construct_type(
                        type_=DataFiltersStatsResponse,  # 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 finished_tasks(
        self, id: int, *, user_pk: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None
    ) -> FinishedTasksStatsResponse:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Get statistics about finished tasks for a project.

        Parameters
        ----------
        id : int

        user_pk : typing.Optional[int]
            User ID to filter statistics by (optional)

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

        Returns
        -------
        FinishedTasksStatsResponse
            Finished tasks statistics

        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.projects.stats.finished_tasks(
                id=1,
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/projects/{jsonable_encoder(id)}/stats/finished",
            method="GET",
            params={
                "user_pk": user_pk,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    FinishedTasksStatsResponse,
                    construct_type(
                        type_=FinishedTasksStatsResponse,  # 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 lead_time(
        self, id: int, *, request_options: typing.Optional[RequestOptions] = None
    ) -> LeadTimeStatsResponse:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Get lead time statistics across the project, including average annotation time.

        Parameters
        ----------
        id : int

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

        Returns
        -------
        LeadTimeStatsResponse
            Lead time statistics

        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.projects.stats.lead_time(
                id=1,
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/projects/{jsonable_encoder(id)}/stats/lead_time",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    LeadTimeStatsResponse,
                    construct_type(
                        type_=LeadTimeStatsResponse,  # 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 total_agreement(
        self,
        id: int,
        *,
        per_label: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> TotalAgreementStatsResponse:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Overall or per-label total agreement across the project.

        NOTE: due to an open issue in Fern, SDK clients will raise ApiError upon handling a 204 response. As a workaround, wrap call to this function in a try-except block.

        Parameters
        ----------
        id : int

        per_label : typing.Optional[bool]
            Return agreement per label

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

        Returns
        -------
        TotalAgreementStatsResponse
            Total agreement

        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.projects.stats.total_agreement(
                id=1,
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/projects/{jsonable_encoder(id)}/stats/total_agreement",
            method="GET",
            params={
                "per_label": per_label,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    TotalAgreementStatsResponse,
                    construct_type(
                        type_=TotalAgreementStatsResponse,  # 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 update_stats(
        self,
        id: int,
        *,
        stat_type: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Dict[str, typing.Optional[typing.Any]]:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Start stats recalculation for given project

        Parameters
        ----------
        id : int

        stat_type : typing.Optional[str]
            Stat type to recalculate. Possible values: label, stats

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

        Returns
        -------
        typing.Dict[str, typing.Optional[typing.Any]]
            Successful response returns job id

        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.projects.stats.update_stats(
                id=1,
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/projects/{jsonable_encoder(id)}/update-stats",
            method="GET",
            params={
                "stat_type": stat_type,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    typing.Dict[str, typing.Optional[typing.Any]],
                    construct_type(
                        type_=typing.Dict[str, typing.Optional[typing.Any]],  # 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 users_prediction_agreement(
        self,
        id: int,
        *,
        ids: str,
        per_label: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UsersPredictionAgreementStatsResponse:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Get prediction agreement statistics for multiple annotators within a project.

        Parameters
        ----------
        id : int

        ids : str
            Comma separated list of annotator user IDs to get agreement scores for

        per_label : typing.Optional[bool]
            Per label

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

        Returns
        -------
        UsersPredictionAgreementStatsResponse
            Prediction agreement statistics for multiple annotators

        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.projects.stats.users_prediction_agreement(
                id=1,
                ids="ids",
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/projects/{jsonable_encoder(id)}/user-stats/prediction",
            method="GET",
            params={
                "ids": ids,
                "per_label": per_label,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    UsersPredictionAgreementStatsResponse,
                    construct_type(
                        type_=UsersPredictionAgreementStatsResponse,  # 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 users_review_score(
        self,
        id: int,
        *,
        ids: str,
        per_label: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UsersReviewScoreStatsResponse:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Get review score and performance score statistics for multiple annotators within a project.

        Parameters
        ----------
        id : int

        ids : str
            Comma separated list of annotator user IDs to get review scores for

        per_label : typing.Optional[bool]
            Per label

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

        Returns
        -------
        UsersReviewScoreStatsResponse
            Review scores and performance scores for multiple annotators

        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.projects.stats.users_review_score(
                id=1,
                ids="ids",
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/projects/{jsonable_encoder(id)}/user-stats/review_score",
            method="GET",
            params={
                "ids": ids,
                "per_label": per_label,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    UsersReviewScoreStatsResponse,
                    construct_type(
                        type_=UsersReviewScoreStatsResponse,  # 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 user_prediction_agreement(
        self,
        id: int,
        user_pk: int,
        *,
        per_label: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UserPredictionAgreementStatsResponse:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Get prediction agreement statistics for a specific user within a project.

        Parameters
        ----------
        id : int

        user_pk : int

        per_label : typing.Optional[bool]
            Calculate agreement per label

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

        Returns
        -------
        UserPredictionAgreementStatsResponse
            Individual user prediction agreement statistics

        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.projects.stats.user_prediction_agreement(
                id=1,
                user_pk=1,
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/projects/{jsonable_encoder(id)}/user-stats/{jsonable_encoder(user_pk)}/prediction",
            method="GET",
            params={
                "per_label": per_label,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    UserPredictionAgreementStatsResponse,
                    construct_type(
                        type_=UserPredictionAgreementStatsResponse,  # 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 user_review_score(
        self,
        id: int,
        user_pk: int,
        *,
        per_label: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UserReviewScoreStatsResponse:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Get review score statistics for a specific user within a project.

        Parameters
        ----------
        id : int

        user_pk : int

        per_label : typing.Optional[bool]
            Calculate agreement per label

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

        Returns
        -------
        UserReviewScoreStatsResponse
            Individual user review score statistics

        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.projects.stats.user_review_score(
                id=1,
                user_pk=1,
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/projects/{jsonable_encoder(id)}/user-stats/{jsonable_encoder(user_pk)}/review_score",
            method="GET",
            params={
                "per_label": per_label,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    UserReviewScoreStatsResponse,
                    construct_type(
                        type_=UserReviewScoreStatsResponse,  # 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 user_ground_truth_agreement(
        self,
        id: int,
        user_pk: int,
        *,
        per_label: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UserGroundTruthAgreementStatsResponse:
        """
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>
        Get ground truth agreement statistics for a specific user within a project.

        Parameters
        ----------
        id : int

        user_pk : int

        per_label : typing.Optional[bool]
            Calculate agreement per label

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

        Returns
        -------
        UserGroundTruthAgreementStatsResponse
            Individual user ground truth agreement statistics

        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.projects.stats.user_ground_truth_agreement(
                id=1,
                user_pk=1,
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/projects/{jsonable_encoder(id)}/users/{jsonable_encoder(user_pk)}/stats/agreement-groundtruth",
            method="GET",
            params={
                "per_label": per_label,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    UserGroundTruthAgreementStatsResponse,
                    construct_type(
                        type_=UserGroundTruthAgreementStatsResponse,  # 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)
