
     j1                         d dl Zd dl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 ddlmZ dd	lmZ  ej        ej        d
          Z G d d          Z G d d          ZdS )    N   )AsyncClientWrapperSyncClientWrapper)RequestOptions   )AsyncRawMediaClientRawMediaClient)GetMediaResponse)GetMediaUploadUrlResponse)MediaContentType.c                   <   e Zd ZdefdZedefd            Zdddede	j
        e         defd	Zeedd
dedej        dede	j
        e         de	j
        e         de	j
        e         ddfdZedddededededede	j
        e         de	j
        e         defdZdS )MediaClientclient_wrapperc                0    t          |          | _        d S N)r   )r	   _raw_clientselfr   s     c/lsinfo/ai/hellotax_ai/base_platform/venv/lib/python3.11/site-packages/langfuse/api/media/client.py__init__zMediaClient.__init__   s    )HHH    returnc                     | j         S )z
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        RawMediaClient
        r   r   s    r   with_raw_responsezMediaClient.with_raw_response        r   Nrequest_optionsmedia_idr   c                H    | j                             ||          }|j        S )a<  
        Get a media record

        Parameters
        ----------
        media_id : str
            The unique langfuse identifier of a media record

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

        Returns
        -------
        GetMediaResponse

        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.media.get(
            media_id="mediaId",
        )
        r   r   getdatar   r    r   	_responses       r   r#   zMediaClient.get    s(    D $((?(SS	~r   upload_http_errorupload_time_msr   uploaded_atupload_http_statusr(   r)   c                P    | j                             ||||||          }|j        S )as  
        Patch a media record

        Parameters
        ----------
        media_id : str
            The unique langfuse identifier of a media record

        uploaded_at : dt.datetime
            The date and time when the media record was uploaded

        upload_http_status : int
            The HTTP status code of the upload

        upload_http_error : typing.Optional[str]
            The HTTP error message of the upload

        upload_time_ms : typing.Optional[int]
            The time in milliseconds it took to upload the media record

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

        Returns
        -------
        None

        Examples
        --------
        import datetime

        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.media.patch(
            media_id="mediaId",
            uploaded_at=datetime.datetime.fromisoformat(
                "2024-01-15 09:30:00+00:00",
            ),
            upload_http_status=1,
        )
        r*   r+   r(   r)   r   r   patchr$   r   r    r*   r+   r(   r)   r   r&   s           r   r/   zMediaClient.patchE   s>    v $**#1/)+ + 
 
	 ~r   observation_idr   trace_idcontent_typecontent_length
sha256hashfieldr2   c          	      R    | j                             |||||||          }|j        S )aD  
        Get a presigned upload URL for a media record

        Parameters
        ----------
        trace_id : str
            The trace ID associated with the media record

        content_type : MediaContentType

        content_length : int
            The size of the media record in bytes

        sha256hash : str
            The SHA-256 hash of the media record

        field : str
            The trace / observation field the media record is associated with. This can be one of `input`, `output`, `metadata`

        observation_id : typing.Optional[str]
            The observation ID associated with the media record. If the media record is associated directly with a trace, this will be null.

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

        Returns
        -------
        GetMediaUploadUrlResponse

        Examples
        --------
        from langfuse import LangfuseAPI
        from langfuse.media import MediaContentType

        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.media.get_upload_url(
            trace_id="traceId",
            content_type=MediaContentType.IMAGE_PNG,
            content_length=1,
            sha256hash="sha256Hash",
            field="field",
        )
        r3   r4   r5   r6   r7   r2   r   r   get_upload_urlr$   	r   r3   r4   r5   r6   r7   r2   r   r&   s	            r   r;   zMediaClient.get_upload_url   sA    z $33%)!)+ 4 
 
	 ~r   )__name__
__module____qualname__r   r   propertyr	   r   strtypingOptionalr   r
   r#   OMITdtdatetimeintr/   r   r   r;    r   r   r   r      s       I*; I I I I  >       X  TX# # ##171P#	# # # #V 37/3;?C C CC [	C
  C "?3/C ,C  8C 
C C C CZ 04;?F F F F '	F
 F F F ,F  8F 
#F F F F F Fr   r   c                   <   e Zd ZdefdZedefd            Zdddede	j
        e         defd	Zeedd
dedej        dede	j
        e         de	j
        e         de	j
        e         ddfdZedddededededede	j
        e         de	j
        e         defdZdS )AsyncMediaClientr   c                0    t          |          | _        d S r   )r   r   r   s     r   r   zAsyncMediaClient.__init__   s    .nMMMr   r   c                     | j         S )z
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        AsyncRawMediaClient
        r   r   s    r   r   z"AsyncMediaClient.with_raw_response   r   r   Nr   r    r   c                X   K   | j                             ||           d{V }|j        S )a  
        Get a media record

        Parameters
        ----------
        media_id : str
            The unique langfuse identifier of a media record

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

        Returns
        -------
        GetMediaResponse

        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.media.get(
                media_id="mediaId",
            )


        asyncio.run(main())
        r   Nr"   r%   s       r   r#   zAsyncMediaClient.get   sS      T *..o / 
 
 
 
 
 
 
 
	 ~r   r'   r*   r+   r(   r)   c                `   K   | j                             ||||||           d{V }|j        S )a  
        Patch a media record

        Parameters
        ----------
        media_id : str
            The unique langfuse identifier of a media record

        uploaded_at : dt.datetime
            The date and time when the media record was uploaded

        upload_http_status : int
            The HTTP status code of the upload

        upload_http_error : typing.Optional[str]
            The HTTP error message of the upload

        upload_time_ms : typing.Optional[int]
            The time in milliseconds it took to upload the media record

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

        Returns
        -------
        None

        Examples
        --------
        import asyncio
        import datetime

        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.media.patch(
                media_id="mediaId",
                uploaded_at=datetime.datetime.fromisoformat(
                    "2024-01-15 09:30:00+00:00",
                ),
                upload_http_status=1,
            )


        asyncio.run(main())
        r-   Nr.   r0   s           r   r/   zAsyncMediaClient.patch  s`      D *00#1/)+ 1 
 
 
 
 
 
 
 
	 ~r   r1   r3   r4   r5   r6   r7   r2   c          	      b   K   | j                             |||||||           d{V }|j        S )a  
        Get a presigned upload URL for a media record

        Parameters
        ----------
        trace_id : str
            The trace ID associated with the media record

        content_type : MediaContentType

        content_length : int
            The size of the media record in bytes

        sha256hash : str
            The SHA-256 hash of the media record

        field : str
            The trace / observation field the media record is associated with. This can be one of `input`, `output`, `metadata`

        observation_id : typing.Optional[str]
            The observation ID associated with the media record. If the media record is associated directly with a trace, this will be null.

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

        Returns
        -------
        GetMediaUploadUrlResponse

        Examples
        --------
        import asyncio

        from langfuse import AsyncLangfuseAPI
        from langfuse.media import MediaContentType

        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.media.get_upload_url(
                trace_id="traceId",
                content_type=MediaContentType.IMAGE_PNG,
                content_length=1,
                sha256hash="sha256Hash",
                field="field",
            )


        asyncio.run(main())
        r9   Nr:   r<   s	            r   r;   zAsyncMediaClient.get_upload_url]  sc      J *99%)!)+ : 
 
 
 
 
 
 
 
	 ~r   )r=   r>   r?   r   r   r@   r   r   rA   rB   rC   r   r
   r#   rD   rE   rF   rG   r/   r   r   r;   rH   r   r   rJ   rJ      s       N*< N N N N  #6       X  TX- - --171P-	- - - -j 37/3;?J J JJ [	J
  J "?3/J ,J  8J 
J J J Jh 04;?N N N N '	N
 N N N ,N  8N 
#N N N N N Nr   rJ   )rF   rE   rB   core.client_wrapperr   r   core.request_optionsr   
raw_clientr   r	   types.get_media_responser
   #types.get_media_upload_url_responser   types.media_content_typer   castAnyrD   r   rJ   rH   r   r   <module>rX      s        G G G G G G G G 1 1 1 1 1 1 ; ; ; ; ; ; ; ; 6 6 6 6 6 6 J J J J J J 6 6 6 6 6 6 v{6:s##       DX X X X X X X X X Xr   