
     jF                         d dl Zd dlZddlmZ ddlmZ ddlmZ ddl	m
Z
mZ ddlmZ dd	lmZmZ dd
lmZ  ej        ej        d          Z G d d          Z G d d          ZdS )    N   )Model)ModelUsageUnit)PricingTierInput)AsyncClientWrapperSyncClientWrapper)RequestOptions   )AsyncRawModelsClientRawModelsClient)PaginatedModels.c                   8   e Zd ZdefdZedefd            Zeeeeeeeedd	de	de	d	e
j        ej                 d
e
j        e         de
j        e         de
j        e         de
j        e         de
j        e
j        e                  de
j        e	         de
j        e
j                 de
j        e         defdZddddde
j        e         de
j        e         de
j        e         defdZddde	de
j        e         defdZddde	de
j        e         ddfdZdS )ModelsClientclient_wrapperc                0    t          |          | _        d S N)r   )r   _raw_clientselfr   s     d/lsinfo/ai/hellotax_ai/base_platform/venv/lib/python3.11/site-packages/langfuse/api/models/client.py__init__zModelsClient.__init__   s    *.III    returnc                     | j         S )z
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        RawModelsClient
        r   r   s    r   with_raw_responsezModelsClient.with_raw_response        r   N	
start_dateunitinput_priceoutput_pricetotal_pricepricing_tierstokenizer_idtokenizer_configrequest_options
model_namematch_patternr    r!   r"   r#   r$   r%   r&   r'   r(   c                Z    | j                             |||||||||	|
|          }|j        S )a  
        Create a model

        Parameters
        ----------
        model_name : str
            Name of the model definition. If multiple with the same name exist, they are applied in the following order: (1) custom over built-in, (2) newest according to startTime where model.startTime<observation.startTime

        match_pattern : str
            Regex pattern which matches this model definition to generation.model. Useful in case of fine-tuned models. If you want to exact match, use `(?i)^modelname$`

        start_date : typing.Optional[dt.datetime]
            Apply only to generations which are newer than this ISO date.

        unit : typing.Optional[ModelUsageUnit]
            Unit used by this model.

        input_price : typing.Optional[float]
            Deprecated. Use 'pricingTiers' instead. Price (USD) per input unit. Creates a default tier if pricingTiers not provided.

        output_price : typing.Optional[float]
            Deprecated. Use 'pricingTiers' instead. Price (USD) per output unit. Creates a default tier if pricingTiers not provided.

        total_price : typing.Optional[float]
            Deprecated. Use 'pricingTiers' instead. Price (USD) per total units. Cannot be set if input or output price is set. Creates a default tier if pricingTiers not provided.

        pricing_tiers : typing.Optional[typing.Sequence[PricingTierInput]]
            Optional. Array of pricing tiers for this model.

            Use pricing tiers for all models - both those with threshold-based pricing variations and those with simple flat pricing:

            - For models with standard flat pricing: Create a single default tier with your prices
              (e.g., one tier with isDefault=true, priority=0, conditions=[], and your standard prices)

            - For models with threshold-based pricing: Create a default tier plus additional conditional tiers
              (e.g., default tier for standard usage + high-volume tier for usage above certain thresholds)

            Requirements:
            - Cannot be provided with flat prices (inputPrice/outputPrice/totalPrice) - use one approach or the other
            - Must include exactly one default tier with isDefault=true, priority=0, and conditions=[]
            - All tier names and priorities must be unique within the model
            - Each tier must define at least one price

            If omitted, you must provide flat prices instead (inputPrice/outputPrice/totalPrice),
            which will automatically create a single default tier named "Standard".

        tokenizer_id : typing.Optional[str]
            Optional. Tokenizer to be applied to observations which match to this model. See docs for more details.

        tokenizer_config : typing.Optional[typing.Any]
            Optional. Configuration for the selected tokenizer. Needs to be JSON. See docs for more details.

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

        Returns
        -------
        Model

        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.models.create(
            model_name="modelName",
            match_pattern="matchPattern",
        )
        r)   r*   r    r!   r"   r#   r$   r%   r&   r'   r(   r   createdatar   r)   r*   r    r!   r"   r#   r$   r%   r&   r'   r(   	_responses                r   r.   zModelsClient.create!   sM    v $++!'!#%#'%-+ , 
 
	 ~r   pagelimitr(   r3   r4   c                J    | j                             |||          }|j        S )aO  
        Get all models

        Parameters
        ----------
        page : typing.Optional[int]
            page number, starts at 1

        limit : typing.Optional[int]
            limit of items per page

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

        Returns
        -------
        PaginatedModels

        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.models.list()
        r2   r   listr/   r   r3   r4   r(   r1   s        r   r7   zModelsClient.list   s3    N $))UO * 
 
	 ~r   r(   idc                H    | j                             ||          }|j        S )a  
        Get a model

        Parameters
        ----------
        id : str

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

        Returns
        -------
        Model

        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.models.get(
            id="id",
        )
        r9   r   getr/   r   r:   r(   r1   s       r   r=   zModelsClient.get   s(    B $((_(MM	~r   c                H    | j                             ||          }|j        S )ak  
        Delete a model. Cannot delete models managed by Langfuse. You can create your own definition with the same modelName to override the definition though.

        Parameters
        ----------
        id : str

        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.models.delete(
            id="id",
        )
        r9   r   deleter/   r>   s       r   rA   zModelsClient.delete   s(    B $++B+PP	~r   )__name__
__module____qualname__r   r   propertyr   r   OMITstrtypingOptionaldtdatetimer   floatSequencer   Anyr	   r   r.   intr   r7   r=   rA    r   r   r   r      s]       J*; J J J J  ?       X  4804.2/3.2LP-18<;?h h h h 	h
 OBK0h on-h _U+h oe,h _U+h v7G'HIh oc*h !/&*5h  8h 
h h h hZ &*&*;?* * * oc"* s#	*
  8* 
* * * *Z NR" " ""+1?>+J"	" " " "J NR" " ""+1?>+J"	" " " " " "r   r   c                   8   e Zd ZdefdZedefd            Zeeeeeeeedd	de	de	d	e
j        ej                 d
e
j        e         de
j        e         de
j        e         de
j        e         de
j        e
j        e                  de
j        e	         de
j        e
j                 de
j        e         defdZddddde
j        e         de
j        e         de
j        e         defdZddde	de
j        e         defdZddde	de
j        e         ddfdZdS )AsyncModelsClientr   c                0    t          |          | _        d S r   )r   r   r   s     r   r   zAsyncModelsClient.__init__  s    /~NNNr   r   c                     | j         S )z
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        AsyncRawModelsClient
        r   r   s    r   r   z#AsyncModelsClient.with_raw_response  r   r   Nr   r)   r*   r    r!   r"   r#   r$   r%   r&   r'   r(   c                j   K   | j                             |||||||||	|
|           d{V }|j        S )a  
        Create a model

        Parameters
        ----------
        model_name : str
            Name of the model definition. If multiple with the same name exist, they are applied in the following order: (1) custom over built-in, (2) newest according to startTime where model.startTime<observation.startTime

        match_pattern : str
            Regex pattern which matches this model definition to generation.model. Useful in case of fine-tuned models. If you want to exact match, use `(?i)^modelname$`

        start_date : typing.Optional[dt.datetime]
            Apply only to generations which are newer than this ISO date.

        unit : typing.Optional[ModelUsageUnit]
            Unit used by this model.

        input_price : typing.Optional[float]
            Deprecated. Use 'pricingTiers' instead. Price (USD) per input unit. Creates a default tier if pricingTiers not provided.

        output_price : typing.Optional[float]
            Deprecated. Use 'pricingTiers' instead. Price (USD) per output unit. Creates a default tier if pricingTiers not provided.

        total_price : typing.Optional[float]
            Deprecated. Use 'pricingTiers' instead. Price (USD) per total units. Cannot be set if input or output price is set. Creates a default tier if pricingTiers not provided.

        pricing_tiers : typing.Optional[typing.Sequence[PricingTierInput]]
            Optional. Array of pricing tiers for this model.

            Use pricing tiers for all models - both those with threshold-based pricing variations and those with simple flat pricing:

            - For models with standard flat pricing: Create a single default tier with your prices
              (e.g., one tier with isDefault=true, priority=0, conditions=[], and your standard prices)

            - For models with threshold-based pricing: Create a default tier plus additional conditional tiers
              (e.g., default tier for standard usage + high-volume tier for usage above certain thresholds)

            Requirements:
            - Cannot be provided with flat prices (inputPrice/outputPrice/totalPrice) - use one approach or the other
            - Must include exactly one default tier with isDefault=true, priority=0, and conditions=[]
            - All tier names and priorities must be unique within the model
            - Each tier must define at least one price

            If omitted, you must provide flat prices instead (inputPrice/outputPrice/totalPrice),
            which will automatically create a single default tier named "Standard".

        tokenizer_id : typing.Optional[str]
            Optional. Tokenizer to be applied to observations which match to this model. See docs for more details.

        tokenizer_config : typing.Optional[typing.Any]
            Optional. Configuration for the selected tokenizer. Needs to be JSON. See docs for more details.

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

        Returns
        -------
        Model

        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.models.create(
                model_name="modelName",
                match_pattern="matchPattern",
            )


        asyncio.run(main())
        r,   Nr-   r0   s                r   r.   zAsyncModelsClient.create  so      F *11!'!#%#'%-+ 2 
 
 
 
 
 
 
 
	 ~r   r2   r3   r4   c                Z   K   | j                             |||           d{V }|j        S )a  
        Get all models

        Parameters
        ----------
        page : typing.Optional[int]
            page number, starts at 1

        limit : typing.Optional[int]
            limit of items per page

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

        Returns
        -------
        PaginatedModels

        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.models.list()


        asyncio.run(main())
        r2   Nr6   r8   s        r   r7   zAsyncModelsClient.list  sU      ^ *//UO 0 
 
 
 
 
 
 
 
	 ~r   r9   r:   c                X   K   | j                             ||           d{V }|j        S )aS  
        Get a model

        Parameters
        ----------
        id : str

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

        Returns
        -------
        Model

        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.models.get(
                id="id",
            )


        asyncio.run(main())
        r9   Nr<   r>   s       r   r=   zAsyncModelsClient.get  s>      R *..r?.SSSSSSSS	~r   c                X   K   | j                             ||           d{V }|j        S )a  
        Delete a model. Cannot delete models managed by Langfuse. You can create your own definition with the same modelName to override the definition though.

        Parameters
        ----------
        id : str

        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.models.delete(
                id="id",
            )


        asyncio.run(main())
        r9   Nr@   r>   s       r   rA   zAsyncModelsClient.delete  s>      R *11"o1VVVVVVVV	~r   )rB   rC   rD   r   r   rE   r   r   rF   rG   rH   rI   rJ   rK   r   rL   rM   r   rN   r	   r   r.   rO   r   r7   r=   rA   rP   r   r   rR   rR      s^       O*< O O O O  #7       X  4804.2/3.2LP-18<;?p p p p 	p
 OBK0p on-p _U+p oe,p _U+p v7G'HIp oc*p !/&*5p  8p 
p p p pj &*&*;?2 2 2 oc"2 s#	2
  82 
2 2 2 2j NR* * **+1?>+J*	* * * *Z NR* * **+1?>+J*	* * * * * *r   rR   )rK   rJ   rH   commons.types.modelr   commons.types.model_usage_unitr    commons.types.pricing_tier_inputr   core.client_wrapperr   r   core.request_optionsr	   
raw_clientr   r   types.paginated_modelsr   castrN   rF   r   rR   rP   r   r   <module>ra      s*        ' ' ' ' ' ' ; ; ; ; ; ; ? ? ? ? ? ? G G G G G G G G 1 1 1 1 1 1 = = = = = = = = 3 3 3 3 3 3 v{6:s##k k k k k k k k\K K K K K K K K K Kr   