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

import typing

from ...commons.types.create_score_value import CreateScoreValue
from ...commons.types.score_data_type import ScoreDataType
from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ...core.request_options import RequestOptions
from .raw_client import AsyncRawScoreV1Client, RawScoreV1Client
from .types.create_score_response import CreateScoreResponse

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


class ScoreV1Client:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawScoreV1Client(client_wrapper=client_wrapper)

    @property
    def with_raw_response(self) -> RawScoreV1Client:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        RawScoreV1Client
        """
        return self._raw_client

    def create(
        self,
        *,
        name: str,
        value: CreateScoreValue,
        id: typing.Optional[str] = OMIT,
        trace_id: typing.Optional[str] = OMIT,
        session_id: typing.Optional[str] = OMIT,
        observation_id: typing.Optional[str] = OMIT,
        dataset_run_id: typing.Optional[str] = OMIT,
        comment: typing.Optional[str] = OMIT,
        metadata: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
        environment: typing.Optional[str] = OMIT,
        queue_id: typing.Optional[str] = OMIT,
        data_type: typing.Optional[ScoreDataType] = OMIT,
        config_id: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CreateScoreResponse:
        """
        Create a score (supports both trace and session scores)

        Parameters
        ----------
        name : str

        value : CreateScoreValue
            The value of the score. Must be passed as string for categorical scores, and numeric for boolean and numeric scores. Boolean score values must equal either 1 or 0 (true or false)

        id : typing.Optional[str]

        trace_id : typing.Optional[str]

        session_id : typing.Optional[str]

        observation_id : typing.Optional[str]

        dataset_run_id : typing.Optional[str]

        comment : typing.Optional[str]

        metadata : typing.Optional[typing.Dict[str, typing.Any]]

        environment : typing.Optional[str]
            The environment of the score. Can be any lowercase alphanumeric string with hyphens and underscores that does not start with 'langfuse'.

        queue_id : typing.Optional[str]
            The annotation queue referenced by the score. Indicates if score was initially created while processing annotation queue.

        data_type : typing.Optional[ScoreDataType]
            The data type of the score. When passing a configId this field is inferred. Otherwise, this field must be passed or will default to numeric.

        config_id : typing.Optional[str]
            Reference a score config on a score. The unique langfuse identifier of a score config. When passing this field, the dataType and stringValue fields are automatically populated.

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

        Returns
        -------
        CreateScoreResponse

        Examples
        --------
        from langfuse import LangfuseAPI

        client = LangfuseAPI(
            x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME",
            x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION",
            x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY",
            username="YOUR_USERNAME",
            password="YOUR_PASSWORD",
            base_url="https://yourhost.com/path/to/api",
        )
        client.legacy.score_v1.create(
            name="name",
            value=1.1,
        )
        """
        _response = self._raw_client.create(
            name=name,
            value=value,
            id=id,
            trace_id=trace_id,
            session_id=session_id,
            observation_id=observation_id,
            dataset_run_id=dataset_run_id,
            comment=comment,
            metadata=metadata,
            environment=environment,
            queue_id=queue_id,
            data_type=data_type,
            config_id=config_id,
            request_options=request_options,
        )
        return _response.data

    def delete(
        self, score_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Delete a score (supports both trace and session scores)

        Parameters
        ----------
        score_id : str
            The unique langfuse identifier of a score

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

        Returns
        -------
        None

        Examples
        --------
        from langfuse import LangfuseAPI

        client = LangfuseAPI(
            x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME",
            x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION",
            x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY",
            username="YOUR_USERNAME",
            password="YOUR_PASSWORD",
            base_url="https://yourhost.com/path/to/api",
        )
        client.legacy.score_v1.delete(
            score_id="scoreId",
        )
        """
        _response = self._raw_client.delete(score_id, request_options=request_options)
        return _response.data


class AsyncScoreV1Client:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawScoreV1Client(client_wrapper=client_wrapper)

    @property
    def with_raw_response(self) -> AsyncRawScoreV1Client:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        AsyncRawScoreV1Client
        """
        return self._raw_client

    async def create(
        self,
        *,
        name: str,
        value: CreateScoreValue,
        id: typing.Optional[str] = OMIT,
        trace_id: typing.Optional[str] = OMIT,
        session_id: typing.Optional[str] = OMIT,
        observation_id: typing.Optional[str] = OMIT,
        dataset_run_id: typing.Optional[str] = OMIT,
        comment: typing.Optional[str] = OMIT,
        metadata: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
        environment: typing.Optional[str] = OMIT,
        queue_id: typing.Optional[str] = OMIT,
        data_type: typing.Optional[ScoreDataType] = OMIT,
        config_id: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CreateScoreResponse:
        """
        Create a score (supports both trace and session scores)

        Parameters
        ----------
        name : str

        value : CreateScoreValue
            The value of the score. Must be passed as string for categorical scores, and numeric for boolean and numeric scores. Boolean score values must equal either 1 or 0 (true or false)

        id : typing.Optional[str]

        trace_id : typing.Optional[str]

        session_id : typing.Optional[str]

        observation_id : typing.Optional[str]

        dataset_run_id : typing.Optional[str]

        comment : typing.Optional[str]

        metadata : typing.Optional[typing.Dict[str, typing.Any]]

        environment : typing.Optional[str]
            The environment of the score. Can be any lowercase alphanumeric string with hyphens and underscores that does not start with 'langfuse'.

        queue_id : typing.Optional[str]
            The annotation queue referenced by the score. Indicates if score was initially created while processing annotation queue.

        data_type : typing.Optional[ScoreDataType]
            The data type of the score. When passing a configId this field is inferred. Otherwise, this field must be passed or will default to numeric.

        config_id : typing.Optional[str]
            Reference a score config on a score. The unique langfuse identifier of a score config. When passing this field, the dataType and stringValue fields are automatically populated.

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

        Returns
        -------
        CreateScoreResponse

        Examples
        --------
        import asyncio

        from langfuse import AsyncLangfuseAPI

        client = AsyncLangfuseAPI(
            x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME",
            x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION",
            x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY",
            username="YOUR_USERNAME",
            password="YOUR_PASSWORD",
            base_url="https://yourhost.com/path/to/api",
        )


        async def main() -> None:
            await client.legacy.score_v1.create(
                name="name",
                value=1.1,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create(
            name=name,
            value=value,
            id=id,
            trace_id=trace_id,
            session_id=session_id,
            observation_id=observation_id,
            dataset_run_id=dataset_run_id,
            comment=comment,
            metadata=metadata,
            environment=environment,
            queue_id=queue_id,
            data_type=data_type,
            config_id=config_id,
            request_options=request_options,
        )
        return _response.data

    async def delete(
        self, score_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Delete a score (supports both trace and session scores)

        Parameters
        ----------
        score_id : str
            The unique langfuse identifier of a score

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

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from langfuse import AsyncLangfuseAPI

        client = AsyncLangfuseAPI(
            x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME",
            x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION",
            x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY",
            username="YOUR_USERNAME",
            password="YOUR_PASSWORD",
            base_url="https://yourhost.com/path/to/api",
        )


        async def main() -> None:
            await client.legacy.score_v1.delete(
                score_id="scoreId",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.delete(
            score_id, request_options=request_options
        )
        return _response.data
