§
     jó"  ã                   ó²   — 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  e j        e j        d	¦  «        Z G d
„ d¦  «        Z G d„ d¦  «        ZdS )é    Né   )ÚAsyncClientWrapperÚSyncClientWrapper)ÚRequestOptionsé   )ÚAsyncRawIngestionClientÚRawIngestionClient)ÚIngestionEvent)ÚIngestionResponse.c            	       ó¢   — e Zd Zdefd„Zedefd„¦   «         Zeddœde	j
        e         de	j        e	j                 d	e	j        e         defd
„ZdS )ÚIngestionClientÚclient_wrapperc                ó0   — t          |¬¦  «        | _        d S ©N)r   )r	   Ú_raw_client©Úselfr   s     úg/lsinfo/ai/hellotax_ai/base_platform/venv/lib/python3.11/site-packages/langfuse/api/ingestion/client.pyÚ__init__zIngestionClient.__init__   s   € Ý-¸^ÐLÑLÔLˆÔÐÐó    Úreturnc                 ó   — | j         S )z—
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        RawIngestionClient
        ©r   ©r   s    r   Úwith_raw_responsez!IngestionClient.with_raw_response   ó   € ð ÔÐr   N©ÚmetadataÚrequest_optionsÚbatchr   r   c                óJ   — | j                              |||¬¦  «        }|j        S )aË  
        **Legacy endpoint for batch ingestion for Langfuse Observability.**

        -> Please use the OpenTelemetry endpoint (`/api/public/otel/v1/traces`). Learn more: https://langfuse.com/integrations/native/opentelemetry

        Within each batch, there can be multiple events.
        Each event has a type, an id, a timestamp, metadata and a body.
        Internally, we refer to this as the "event envelope" as it tells us something about the event but not the trace.
        We use the event id within this envelope to deduplicate messages to avoid processing the same event twice, i.e. the event id should be unique per request.
        The event.body.id is the ID of the actual trace and will be used for updates and will be visible within the Langfuse App.
        I.e. if you want to update a trace, you'd use the same body id, but separate event IDs.

        Notes:
        - Introduction to data model: https://langfuse.com/docs/observability/data-model
        - Batch sizes are limited to 3.5 MB in total. You need to adjust the number of events per batch accordingly.
        - The API does not return a 4xx status code for input errors. Instead, it responds with a 207 status code, which includes a list of the encountered errors.

        Parameters
        ----------
        batch : typing.Sequence[IngestionEvent]
            Batch of tracing events to be ingested. Discriminated by attribute `type`.

        metadata : typing.Optional[typing.Any]
            Optional. Metadata field used by the Langfuse SDKs for debugging.

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

        Returns
        -------
        IngestionResponse

        Examples
        --------
        import datetime

        from langfuse import LangfuseAPI
        from langfuse.ingestion import IngestionEvent_TraceCreate, TraceBody

        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.ingestion.batch(
            batch=[
                IngestionEvent_TraceCreate(
                    id="abcdef-1234-5678-90ab",
                    timestamp="2022-01-01T00:00:00.000Z",
                    body=TraceBody(
                        id="abcdef-1234-5678-90ab",
                        timestamp=datetime.datetime.fromisoformat(
                            "2022-01-01 00:00:00+00:00",
                        ),
                        environment="production",
                        name="My Trace",
                        user_id="1234-5678-90ab-cdef",
                        input="My input",
                        output="My output",
                        session_id="1234-5678-90ab-cdef",
                        release="1.0.0",
                        version="1.0.0",
                        metadata="My metadata",
                        tags=["tag1", "tag2"],
                        public=True,
                    ),
                )
            ],
        )
        ©r    r   r   ©r   r    Údata©r   r    r   r   Ú	_responses        r   r    zIngestionClient.batch   s3   € ð` Ô$×*Ò*Ø (¸Oð +ñ 
ô 
ˆ	ð Œ~Ðr   )Ú__name__Ú
__module__Ú__qualname__r   r   Úpropertyr	   r   ÚOMITÚtypingÚSequencer
   ÚOptionalÚAnyr   r   r    © r   r   r   r      sÎ   € € € € € ðMÐ*;ð Mð Mð Mð Mð ð Ð#5ð  ð  ð  ñ „Xð ð 15Ø;?ðSð Sð Sð Œ˜~Ô.ðSð ”/ &¤*Ô-ð	Sð
  œ¨Ô8ðSð 
ðSð Sð Sð Sð Sð Sr   r   c            	       ó¢   — e Zd Zdefd„Zedefd„¦   «         Zeddœde	j
        e         de	j        e	j                 d	e	j        e         defd
„ZdS )ÚAsyncIngestionClientr   c                ó0   — t          |¬¦  «        | _        d S r   )r   r   r   s     r   r   zAsyncIngestionClient.__init__u   s   € Ý2À.ÐQÑQÔQˆÔÐÐr   r   c                 ó   — | j         S )zœ
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        AsyncRawIngestionClient
        r   r   s    r   r   z&AsyncIngestionClient.with_raw_responsex   r   r   Nr   r    r   r   c             ƒ   óZ   K  — | j                              |||¬¦  «        ƒ d{V —†}|j        S )a˜  
        **Legacy endpoint for batch ingestion for Langfuse Observability.**

        -> Please use the OpenTelemetry endpoint (`/api/public/otel/v1/traces`). Learn more: https://langfuse.com/integrations/native/opentelemetry

        Within each batch, there can be multiple events.
        Each event has a type, an id, a timestamp, metadata and a body.
        Internally, we refer to this as the "event envelope" as it tells us something about the event but not the trace.
        We use the event id within this envelope to deduplicate messages to avoid processing the same event twice, i.e. the event id should be unique per request.
        The event.body.id is the ID of the actual trace and will be used for updates and will be visible within the Langfuse App.
        I.e. if you want to update a trace, you'd use the same body id, but separate event IDs.

        Notes:
        - Introduction to data model: https://langfuse.com/docs/observability/data-model
        - Batch sizes are limited to 3.5 MB in total. You need to adjust the number of events per batch accordingly.
        - The API does not return a 4xx status code for input errors. Instead, it responds with a 207 status code, which includes a list of the encountered errors.

        Parameters
        ----------
        batch : typing.Sequence[IngestionEvent]
            Batch of tracing events to be ingested. Discriminated by attribute `type`.

        metadata : typing.Optional[typing.Any]
            Optional. Metadata field used by the Langfuse SDKs for debugging.

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

        Returns
        -------
        IngestionResponse

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

        from langfuse import AsyncLangfuseAPI
        from langfuse.ingestion import IngestionEvent_TraceCreate, TraceBody

        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.ingestion.batch(
                batch=[
                    IngestionEvent_TraceCreate(
                        id="abcdef-1234-5678-90ab",
                        timestamp="2022-01-01T00:00:00.000Z",
                        body=TraceBody(
                            id="abcdef-1234-5678-90ab",
                            timestamp=datetime.datetime.fromisoformat(
                                "2022-01-01 00:00:00+00:00",
                            ),
                            environment="production",
                            name="My Trace",
                            user_id="1234-5678-90ab-cdef",
                            input="My input",
                            output="My output",
                            session_id="1234-5678-90ab-cdef",
                            release="1.0.0",
                            version="1.0.0",
                            metadata="My metadata",
                            tags=["tag1", "tag2"],
                            public=True,
                        ),
                    )
                ],
            )


        asyncio.run(main())
        r"   Nr#   r%   s        r   r    zAsyncIngestionClient.batchƒ   sU   è è € ðn Ô*×0Ò0Ø (¸Oð 1ñ 
ô 
ð 
ð 
ð 
ð 
ð 
ð 
ˆ	ð Œ~Ðr   )r'   r(   r)   r   r   r*   r   r   r+   r,   r-   r
   r.   r/   r   r   r    r0   r   r   r2   r2   t   sÎ   € € € € € ðRÐ*<ð Rð Rð Rð Rð ð Ð#:ð  ð  ð  ñ „Xð ð 15Ø;?ðZð Zð Zð Œ˜~Ô.ðZð ”/ &¤*Ô-ð	Zð
  œ¨Ô8ðZð 
ðZð Zð Zð Zð Zð Zr   r2   )r,   Úcore.client_wrapperr   r   Úcore.request_optionsr   Ú
raw_clientr   r	   Útypes.ingestion_eventr
   Útypes.ingestion_responser   Úcastr/   r+   r   r2   r0   r   r   ú<module>r<      sú   ðð €€€à GÐ GÐ GÐ GÐ GÐ GÐ GÐ GØ 1Ð 1Ð 1Ð 1Ð 1Ð 1Ø CÐ CÐ CÐ CÐ CÐ CÐ CÐ CØ 1Ð 1Ð 1Ð 1Ð 1Ð 1Ø 7Ð 7Ð 7Ð 7Ð 7Ð 7ð €v„{6”:˜sÑ#Ô#€ðbð bð bð bð bñ bô bð bðJið ið ið ið iñ iô ið ið ið ir   