
    j=                       d dl Z d dlZd dlmZ ddlmZ ddlmZmZ ddl	m
Z
mZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddl m!Z! ddl"m#Z# ddl$m%Z% ddl&m'Z' ddl(m)Z) ddl*m+Z+ ddl,m-Z- ddl.m/Z/ ddl0m1Z1 ddl2m3Z3 ddl4m5Z5 ddl6m7Z7 ddl8m9Z9 ddl:m;Z; dd l<m=Z= dd!l>m?Z? dd"l@mAZA  ej                  ej                  d#      ZD G d$ d%      ZE G d& d'      ZFy)(    N)JSONDecodeError   )ApiError)AsyncClientWrapperSyncClientWrapper)AsyncHttpResponseHttpResponse)jsonable_encoder)parse_obj_as)RequestOptions)'convert_and_respect_annotation_metadata)BadRequestError)ConflictError)NotFoundError)UnprocessableEntityError)#ExperimentGroupAggregationsResponse)ExperimentGroupResponse)ExperimentItem)3ExperimentItemBulkRecordExperimentItemBulkWriteView)ExperimentItemPublic)ExperimentPagePublic)ExperimentPublic)ExperimentScore)ExperimentScoreWrite)ExperimentUpdate)ExperimentUpdateStatus)ExperimentUpdateType)FeedbackScoreNamesPublic)JsonListStringWrite)JsonNode)PromptVersionLinkWrite   )ExperimentWriteEvaluationMethod)ExperimentWriteStatus)ExperimentWriteType.c            $          e Zd ZdefdZedddej                  e   de	dej                  e   dej                  e   d	ed   f
d
Zdddddddddddddddddej                  e   dej                  e   dej                  e   dej                  e   dej                  e   dej                  e   dej                  e   dej                  e   dej                  e   dej                  e   dej                  e   dej                  e   dej                  e   dej                  e   dej                  e   d	ee   f dZeeeeeeeeeeeeeeedddej                  e   dej                  e   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   dej                  e   d#ej                  e   d$ej                  ej                  e      d%ej                  e   d&ej                  ej                  e      d'ej                  e   dej                  e   d	ed   f"d(Zdd)d*ej                  e   dej                  e   d	ed   fd+Zdd)dej                  e   dej                  e   d	ed   fd,Zdd)dej                  e   dej                  e   d	ed   fd-Zedd.d/eded0ej                  e   d1ej                  e   dej                  e   d	ed   fd2Zddd3dej                  e   dej                  e   d	ee   fd4Z dddddddd5d6ej                  e   dej                  e   dej                  e   dej                  e   dej                  e   dej                  e   dej                  e   d	ee!   fd7Z"dddddddd5d6ej                  e   dej                  e   dej                  e   dej                  e   dej                  e   dej                  e   dej                  e   d	ee#   fd8Z$dd)dej                  e   dej                  e   d	ed   fd9Z%dd)dedej                  e   d	ee&   fd:Z'eeeeeeeedd;	dedej                  e   dej                  e(   d ej                  ej                  e      d<ej                  ej                  e      d=ej                  ej                  e      d!ej                  e)   d#ej                  e*   d$ej                  ej                  e+      dej                  e   d	ed   fd>Z,dd)dedej                  e   d	ee-   fd?Z.e/j`                  eeedd@d/edAej                  e   dBej                  e   dCej                  e   dej                  e   d	ejb                  eejb                  e2         fdD       Z3e/j`                  eeddEdedAej                  e   dBej                  e   dej                  e   d	ejb                  eejb                  e2         f
dF       Z4y)GRawExperimentsClientclient_wrapperc                    || _         y N_client_wrapperselfr(   s     }/Users/manta/Documents/Projects/TheRoad-I1/backend/.venv/lib/python3.12/site-packages/opik/rest_api/experiments/raw_client.py__init__zRawExperimentsClient.__init__-   
    -    N
merge_tagsrequest_optionsidsupdater4   r5   returnc                   | j                   j                  j                  dd|t        |t        d      |dddi|t
              }	 d	|j                  cxk  rd
k  rn nt        |d      S |j                  dk(  rt        t        |j                        t        j                  t        j                  t        j                     t        t        j                  t        j                     |j!                                           |j!                         }t%        |j                  t        |j                        |      # t"        $ r6 t%        |j                  t        |j                        |j&                        w xY w)a  
        Update multiple experiments

        Parameters
        ----------
        ids : typing.Sequence[str]
            List of experiment IDs to update (max 1000)

        update : ExperimentUpdate

        merge_tags : typing.Optional[bool]
            If true, merge tags with existing tags instead of replacing them. Default: false

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

        Returns
        -------
        HttpResponse[None]
        v1/private/experiments/batchPATCHwriteobject_
annotation	directionr6   r7   r4   content-typeapplication/jsonmethodjsonheadersr5   omit   ,  Nresponsedata  type_r>   rG   bodystatus_coderG   rR   )r,   httpx_clientrequestr   r   OMITrT   r	   r   dictrG   typingcastOptionalAnyr   rF   r   r   textr.   r6   r7   r4   r5   	_response_response_jsons          r/   batch_update_experimentsz-RawExperimentsClient.batch_update_experiments0   sU   8 ((55==*A"/?7 )  2 , > 
	 	ti++1c1#YTBB$$+% !2!23

3$"(//&**"=$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`noo  	ty'<'<d9K\K\F]dmdrdrss	ts   $E ,B*E ?F pagesize
dataset_idoptimization_idtypesnamedataset_deleted	prompt_id
project_idproject_deletedsortingfiltersexperiment_idsforce_sortingr5   rc   rd   re   rf   rg   rh   ri   rj   rk   rl   rm   rn   ro   rp   c                Z   | j                   j                  j                  dd|||||||||	|
||||d|      }	 d|j                  cxk  rdk  rGn nDt	        j
                  t        t        t        |j                                     }t        ||      S |j                  d	k(  rt        t        |j                        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                     
      |j                         }t!        |j                  t        |j                        |      # t        $ r6 t!        |j                  t        |j                        |j"                        w xY w)aq  
        Find experiments

        Parameters
        ----------
        page : typing.Optional[int]

        size : typing.Optional[int]

        dataset_id : typing.Optional[str]

        optimization_id : typing.Optional[str]

        types : typing.Optional[str]

        name : typing.Optional[str]

        dataset_deleted : typing.Optional[bool]

        prompt_id : typing.Optional[str]

        project_id : typing.Optional[str]

        project_deleted : typing.Optional[bool]

        sorting : typing.Optional[str]

        filters : typing.Optional[str]

        experiment_ids : typing.Optional[str]

        force_sorting : typing.Optional[bool]

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

        Returns
        -------
        HttpResponse[ExperimentPagePublic]
            Experiments resource
        v1/private/experimentsGETrc   rd   	datasetIdrf   rg   rh   ri   rj   rk   rl   rm   rn   ro   rp   rE   paramsr5   rI   rJ   rO   rK   rN   rQ   rS   )r,   rU   rV   rT   rY   rZ   r   r   rF   r	   r   rX   rG   r[   r\   r   r   r]   r.   rc   rd   re   rf   rg   rh   ri   rj   rk   rl   rm   rn   ro   rp   r5   r_   _datar`   s                      r/   find_experimentsz%RawExperimentsClient.find_experimentso   s   x ((55==$'#2#2&(#2"""0!.  ,' > 
	*	ti++1c1( 2 ) 0 $YUCC$$+% !2!23

3$"(//&**"=$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`noo  	ty'<'<d9K\K\F]dmdrdrss	ts   AE+ B*E+ +?F*iddataset_namerk   project_namerh   metadatatagstypeevaluation_methodrf   statusexperiment_scoresprompt_versionprompt_versionsdataset_version_idr5   r|   r}   r~   r   r   r   r   r   r   r   r   r   c                   | j                   j                  j                  dd|||||t        |t        d      |||	|
|t        |t
        j                  t           d      t        |t        d      t        |t
        j                  t           d      |dddi|t              }	 d	|j                  cxk  rd
k  rn nt        |d      S |j                         }t        |j                  t        |j                         |      # t        $ r6 t        |j                  t        |j                         |j"                        w xY w)a  
        Create experiment

        Parameters
        ----------
        id : typing.Optional[str]

        dataset_name : typing.Optional[str]

        project_id : typing.Optional[str]
            Project ID. Takes precedence over project_name when both are provided.

        project_name : typing.Optional[str]
            Project name. Creates project if it doesn't exist. Ignored when project_id is provided.

        name : typing.Optional[str]

        metadata : typing.Optional[JsonListStringWrite]

        tags : typing.Optional[typing.Sequence[str]]

        type : typing.Optional[ExperimentWriteType]

        evaluation_method : typing.Optional[ExperimentWriteEvaluationMethod]

        optimization_id : typing.Optional[str]

        status : typing.Optional[ExperimentWriteStatus]

        experiment_scores : typing.Optional[typing.Sequence[ExperimentScoreWrite]]

        prompt_version : typing.Optional[PromptVersionLinkWrite]

        prompt_versions : typing.Optional[typing.Sequence[PromptVersionLinkWrite]]

        dataset_version_id : typing.Optional[str]
            ID of the dataset version this experiment is linked to. If not provided at creation, experiment will be automatically linked to the latest version.

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

        Returns
        -------
        HttpResponse[None]
        rr   POSTr<   r=   r|   r}   rk   r~   rh   r   r   r   r   rf   r   r   r   r   r   rB   rC   rD   rI   rJ   NrK   rS   )r,   rU   rV   r   r   rY   Sequencer   r!   rW   rT   r	   rF   r   r   rX   rG   r]   r.   r|   r}   rk   r~   rh   r   r   r   r   rf   r   r   r   r   r   r5   r_   r`   s                      r/   create_experimentz&RawExperimentsClient.create_experiment   sX   B ((55==$ ,( ,C$1DPW %6#2 %L-&//J^:_kr& #J*7MY`# $K+H^8_kr$ '9/4  2 ,A > !
	D	ti++1c1#YTBB&^^-N 9#8#8$yGXGXBY`noo  	ty'<'<d9K\K\F]dmdrdrss	ts   %$D 
D ?Er5   experiment_itemsc          
         | j                   j                  j                  dddt        |t        j
                  t           d      iddi|t              }	 d	|j                  cxk  rd
k  rn nt        |d      S |j                         }t        |j                  t        |j                        |      # t        $ r6 t        |j                  t        |j                        |j                        w xY w)a.  
        Create experiment items

        Parameters
        ----------
        experiment_items : typing.Sequence[ExperimentItem]

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

        Returns
        -------
        HttpResponse[None]
        v1/private/experiments/itemsr   r   r<   r=   rB   rC   rD   rI   rJ   NrK   rS   )r,   rU   rV   r   rY   r   r   rW   rT   r	   rF   r   r   rX   rG   r]   r.   r   r5   r_   r`   s        r/   create_experiment_itemsz,RawExperimentsClient.create_experiment_itemsE  s    ( ((55==*"$K,9Xdk%  2 , > 
		ti++1c1#YTBB&^^-N 9#8#8$yGXGXBY`noo  	ty'<'<d9K\K\F]dmdrdrss	ts   $B6 ;B6 6?C5c                   | j                   j                  j                  ddd|iddi|t              }	 d|j                  cxk  rdk  rn nt        |d	
      S |j                         }t        |j                  t        |j                        |      # t        $ r6 t        |j                  t        |j                        |j                        w xY w)a  
        Delete experiment items

        Parameters
        ----------
        ids : typing.Sequence[str]

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

        Returns
        -------
        HttpResponse[None]
        #v1/private/experiments/items/deleter   r6   rB   rC   rD   rI   rJ   NrK   rS   r,   rU   rV   rW   rT   r	   rF   r   r   rX   rG   r]   r.   r6   r5   r_   r`   s        r/   delete_experiment_itemsz,RawExperimentsClient.delete_experiment_itemso  s    " ((55==1s  2 , > 
		ti++1c1#YTBB&^^-N 9#8#8$yGXGXBY`noo  	ty'<'<d9K\K\F]dmdrdrss	t   $B B ?Cc                   | j                   j                  j                  ddd|iddi|t              }	 d|j                  cxk  rdk  rn nt        |d	
      S |j                         }t        |j                  t        |j                        |      # t        $ r6 t        |j                  t        |j                        |j                        w xY w)a  
        Delete experiments by id

        Parameters
        ----------
        ids : typing.Sequence[str]

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

        Returns
        -------
        HttpResponse[None]
        v1/private/experiments/deleter   r6   rB   rC   rD   rI   rJ   NrK   rS   r   r   s        r/   delete_experiments_by_idz-RawExperimentsClient.delete_experiments_by_id  s    " ((55==+s  2 , > 
		ti++1c1#YTBB&^^-N 9#8#8$yGXGXBY`noo  	ty'<'<d9K\K\F]dmdrdrss	tr   experiment_idr5   experiment_nameitemsr   c                   | j                   j                  j                  dd|||t        |t        j
                  t           d      dddi|t              }	 d	|j                  cxk  rd
k  rn nt        |d      S |j                  dk(  rt        t        |j                        t	        j                  t        j                  t        j                     t!        t        j                  t        j                     |j#                                           |j                  dk(  rt%        t        |j                        t	        j                  t        j                  t        j                     t!        t        j                  t        j                     |j#                                           |j                  dk(  rt'        t        |j                        t	        j                  t        j                  t        j                     t!        t        j                  t        j                     |j#                                           |j#                         }t+        |j                  t        |j                        |      # t(        $ r6 t+        |j                  t        |j                        |j,                        w xY w)a  
        Record experiment items in bulk with traces, spans, and feedback scores. Maximum request size is 4MB.

        Parameters
        ----------
        experiment_name : str

        dataset_name : str

        items : typing.Sequence[ExperimentItemBulkRecordExperimentItemBulkWriteView]

        experiment_id : typing.Optional[str]
            Optional experiment ID. If provided, items will be added to the existing experiment and experimentName will be ignored. If not provided or experiment with that ID doesn't exist, a new experiment will be created with the given experimentName

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

        Returns
        -------
        HttpResponse[None]
        !v1/private/experiments/items/bulkPUTr<   r=   r   r}   r   r   rB   rC   rD   rI   rJ   NrK   rN   rO   rQ       rS   )r,   rU   rV   r   rY   r   r   rW   rT   r	   r   rX   rG   rZ   r[   r\   r   rF   r   r   r   r   r]   r.   r   r}   r   r   r5   r_   r`   s           r/   experiment_items_bulkz*RawExperimentsClient.experiment_items_bulk  s3   < ((55==/#2 ,!.@!%/bc%		  2 ,# > 
	&&	ti++1c1#YTBB$$+% !2!23

3$"(//&**"=$-NN$4	 	 $$+# !2!23

3$"(//&**"=$-NN$4	 	 $$+. !2!23

3$"(//&**"=$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`noo  	ty'<'<d9K\K\F]dmdrdrss	ts   $J >GJ ?Kro   r5   c                   | j                   j                  j                  ddd|i|      }	 d|j                  cxk  rdk  rGn nDt	        j
                  t        t        t        |j                                     }t        ||      S |j                         }t        |j                  t        |j                        |	      # t        $ r6 t        |j                  t        |j                        |j                  	      w xY w)
a\  
        Find Feedback Score names

        Parameters
        ----------
        experiment_ids : typing.Optional[str]

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

        Returns
        -------
        HttpResponse[FeedbackScoreNamesPublic]
            Feedback Scores resource
        ,v1/private/experiments/feedback-scores/namesrs   ro   rv   rI   rJ   rO   rK   rS   )r,   rU   rV   rT   rY   rZ   r   r   rF   r	   r   r   rX   rG   r]   r.   ro   r5   r_   ry   r`   s         r/   find_feedback_score_namesz.RawExperimentsClient.find_feedback_score_names  s    $ ((55==: . , > 
		ti++1c1, 6 ) 0 $YUCC&^^-N 9#8#8$yGXGXBY`noo  	ty'<'<d9K\K\F]dmdrdrss	ts   AC 	C ?Dgroupsrg   rh   rk   rl   rn   r5   r   c                J   | j                   j                  j                  dd||||||d|      }	 d|j                  cxk  rdk  rGn nDt	        j
                  t        t        t        |j                                     }	t        ||	      S |j                  d	k(  rt        t        |j                        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                     
      |j                         }
t!        |j                  t        |j                        |
      # t        $ r6 t!        |j                  t        |j                        |j"                        w xY w)a.  
        Find experiments grouped by specified fields

        Parameters
        ----------
        groups : typing.Optional[str]

        types : typing.Optional[str]

        name : typing.Optional[str]

        project_id : typing.Optional[str]

        project_deleted : typing.Optional[bool]

        filters : typing.Optional[str]

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

        Returns
        -------
        HttpResponse[ExperimentGroupResponse]
            Experiment groups
        v1/private/experiments/groupsrs   r   rg   rh   rk   rl   rn   rv   rI   rJ   rO   rK   rN   rQ   rS   )r,   rU   rV   rT   rY   rZ   r   r   rF   r	   r   rX   rG   r[   r\   r   r   r]   r.   r   rg   rh   rk   rl   rn   r5   r_   ry   r`   s              r/   find_experiment_groupsz+RawExperimentsClient.find_experiment_groups<  sh   H ((55==+ (#2" , > 
		ti++1c1+ 5 ) 0 $YUCC$$+% !2!23

3$"(//&**"=$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`noo  	ty'<'<d9K\K\F]dmdrdrss	t   AE# B*E# #?F"c                J   | j                   j                  j                  dd||||||d|      }	 d|j                  cxk  rdk  rGn nDt	        j
                  t        t        t        |j                                     }	t        ||	      S |j                  d	k(  rt        t        |j                        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                     
      |j                         }
t!        |j                  t        |j                        |
      # t        $ r6 t!        |j                  t        |j                        |j"                        w xY w)ae  
        Find experiments grouped by specified fields with aggregation metrics

        Parameters
        ----------
        groups : typing.Optional[str]

        types : typing.Optional[str]

        name : typing.Optional[str]

        project_id : typing.Optional[str]

        project_deleted : typing.Optional[bool]

        filters : typing.Optional[str]

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

        Returns
        -------
        HttpResponse[ExperimentGroupAggregationsResponse]
            Experiment groups with aggregations
        *v1/private/experiments/groups/aggregationsrs   r   rv   rI   rJ   rO   rK   rN   rQ   rS   )r,   rU   rV   rT   rY   rZ   r   r   rF   r	   r   rX   rG   r[   r\   r   r   r]   r   s              r/   #find_experiment_groups_aggregationsz8RawExperimentsClient.find_experiment_groups_aggregations  sh   H ((55==8 (#2" , > 
		ti++1c17 A ) 0 $YUCC$$+% !2!23

3$"(//&**"=$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`noo  	ty'<'<d9K\K\F]dmdrdrss	tr   c                   | j                   j                  j                  ddd|iddi|t              }	 d|j                  cxk  rdk  rn nt        |d	
      S |j                  dk(  rt        t        |j                        t        j                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                         }t!        |j                  t        |j                        |      # t        $ r6 t!        |j                  t        |j                        |j"                        w xY w)a*  
        Finish experiments and trigger alert events

        Parameters
        ----------
        ids : typing.Sequence[str]

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

        Returns
        -------
        HttpResponse[None]
        v1/private/experiments/finishr   r6   rB   rC   rD   rI   rJ   NrK   rN   rO   rQ   rS   )r,   rU   rV   rW   rT   r	   r   rX   rG   rY   rZ   r[   r\   r   rF   r   r   r]   r   s        r/   finish_experimentsz'RawExperimentsClient.finish_experiments  sB   " ((55==+s  2 , > 
		ti++1c1#YTBB$$+% !2!23

3$"(//&**"=$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`noo  	ty'<'<d9K\K\F]dmdrdrss	ts   $D/ B*D/ /?E.c                R   | j                   j                  j                  dt        |       d|      }	 d|j                  cxk  rdk  rGn nDt        j                  t        t        t        |j                                     }t        ||      S |j                  dk(  rt        t        |j                        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                     	      |j                         }t#        |j                  t        |j                        |
      # t         $ r6 t#        |j                  t        |j                        |j$                  
      w xY w)a-  
        Get experiment by id

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

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

        Returns
        -------
        HttpResponse[ExperimentPublic]
            Experiment resource
        v1/private/experiments/rs   rE   r5   rI   rJ   rO   rK     rQ   rS   )r,   rU   rV   r
   rT   rY   rZ   r   r   rF   r	   r   rX   rG   r[   r\   r   r   r]   r.   r|   r5   r_   ry   r`   s         r/   get_experiment_by_idz)RawExperimentsClient.get_experiment_by_id  s\   $ ((55==%&6r&:%;<+ > 
	
	ti++1c1$ . ) 0 $YUCC$$+# !2!23

3$"(//&**"=$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`noo  	ty'<'<d9K\K\F]dmdrdrss	t   AE' B*E' '?F&	rh   r   r   tags_to_addtags_to_remover   r   r   r5   r   r   c       	         ~   | j                   j                  j                  dt        |       d|||||||t	        |	t
        j                  t           d      dddi|
t              }	 d	|j                  cxk  rd
k  rn nt        |d      S |j                  dk(  rt        t        |j                        t        j                  t
        j                  t
        j                      t#        t
        j                  t
        j                      |j%                                           |j                  dk(  rt'        t        |j                        t        j                  t
        j                  t
        j                      t#        t
        j                  t
        j                      |j%                                           |j%                         }t+        |j                  t        |j                        |      # t(        $ r6 t+        |j                  t        |j                        |j,                        w xY w)a6  
        Update experiment by id

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

        name : typing.Optional[str]

        metadata : typing.Optional[JsonNode]

        tags : typing.Optional[typing.Sequence[str]]
            Tags

        tags_to_add : typing.Optional[typing.Sequence[str]]
            Tags to add

        tags_to_remove : typing.Optional[typing.Sequence[str]]
            Tags to remove

        type : typing.Optional[ExperimentUpdateType]

        status : typing.Optional[ExperimentUpdateStatus]
            The status of the experiment

        experiment_scores : typing.Optional[typing.Sequence[ExperimentScore]]

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

        Returns
        -------
        HttpResponse[None]
        r   r;   r<   r=   rh   r   r   r   r   r   r   r   rB   rC   rD   rI   rJ   NrK   rN   rO   rQ   r   rS   )r,   rU   rV   r
   r   rY   r   r   rW   rT   r	   r   rX   rG   rZ   r[   r\   r   rF   r   r   r   r]   r.   r|   rh   r   r   r   r   r   r   r   r5   r_   r`   s                r/   update_experimentz&RawExperimentsClient.update_experiment3  s   ` ((55==%&6r&:%;<$*"0 %L-&///:Zfm&  2 ,' > 
	*	ti++1c1#YTBB$$+% !2!23

3$"(//&**"=$-NN$4	 	 $$+# !2!23

3$"(//&**"=$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`noo  	ty'<'<d9K\K\F]dmdrdrss	ts   )$G= EG= =?H<c                R   | j                   j                  j                  dt        |       d|      }	 d|j                  cxk  rdk  rGn nDt        j                  t        t        t        |j                                     }t        ||      S |j                  dk(  rt        t        |j                        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                     	      |j                         }t#        |j                  t        |j                        |
      # t         $ r6 t#        |j                  t        |j                        |j$                  
      w xY w)a;  
        Get experiment item by id

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

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

        Returns
        -------
        HttpResponse[ExperimentItemPublic]
            Experiment item resource
        v1/private/experiments/items/rs   r   rI   rJ   rO   rK   r   rQ   rS   )r,   rU   rV   r
   rT   rY   rZ   r   r   rF   r	   r   rX   rG   r[   r\   r   r   r]   r   s         r/   get_experiment_item_by_idz.RawExperimentsClient.get_experiment_item_by_id  s\   $ ((55==+,<R,@+AB+ > 
	
	ti++1c1( 2 ) 0 $YUCC$$+# !2!23

3$"(//&**"=$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`noo  	ty'<'<d9K\K\F]dmdrdrss	tr   limitlast_retrieved_idtruncater5   r   r   r   c          	   #     K   | j                   j                  j                  dd||||dddit              5 dt        t
        j                  t              ffd} |        d	d	d	       y	# 1 sw Y   y	xY ww)
a  
        Stream experiment items

        Parameters
        ----------
        experiment_name : str

        limit : typing.Optional[int]

        last_retrieved_id : typing.Optional[str]

        truncate : typing.Optional[bool]
            Truncate image included in either input, output or metadata

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.

        Returns
        -------
        typing.Iterator[HttpResponse[typing.Iterator[bytes]]]
            Experiment items stream or error during process
        #v1/private/experiments/items/streamr   r   r   r   r   rB   rC   rD   r8   c                     	 dj                   cxk  rdk  r=n n:j                  dd       nd } t        d j                  |       D              S j	                          j                         }t        j                   t        j                        |      # t        $ r6 t        j                   t        j                        j                        w xY w)NrI   rJ   
chunk_sizec              3       K   | ]  }|  y wr*    .0_chunks     r/   	<genexpr>zORawExperimentsClient.stream_experiment_items.<locals>.stream.<locals>.<genexpr>       5xKwfKw   r   rK   rS   rT   getr	   
iter_bytesreadrF   r   r   rX   rG   r]   _chunk_sizer`   r_   r5   s     r/   streamz<RawExperimentsClient.stream_experiment_items.<locals>.stream      i339c9Q`Qlo&9&9,&Mrv+%.5x9K_K_kvK_Kw5x   NN$%.^^%5N
 9+@+@$yO`O`Jahvww	 ' "$-$9$94	HYHYCZajaoao    AB   B   ?CNr,   rU   r   rW   r	   rY   Iteratorbytesr.   r   r   r   r   r5   r   r_   s        ` @r/   stream_experiment_itemsz,RawExperimentsClient.stream_experiment_items  s     @ !!..551#2%6$	  2 , 6 
 xL)?@ x (N?
 
 
s   7A?/A3*	A?3A<8A?r   r   r5   c             #      K   | j                   j                  j                  dd|||dddit              5 dt        t
        j                  t              ffd} |        d	d	d	       y	# 1 sw Y   y	xY ww)
a  
        Stream experiments

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

        limit : typing.Optional[int]

        last_retrieved_id : typing.Optional[str]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.

        Returns
        -------
        typing.Iterator[HttpResponse[typing.Iterator[bytes]]]
            Experiments stream or error during process
        v1/private/experiments/streamr   rh   r   r   rB   rC   rD   r8   c                     	 dj                   cxk  rdk  r=n n:j                  dd       nd } t        d j                  |       D              S j	                          j                         }t        j                   t        j                        |      # t        $ r6 t        j                   t        j                        j                        w xY w)NrI   rJ   r   c              3       K   | ]  }|  y wr*   r   r   s     r/   r   zJRawExperimentsClient.stream_experiments.<locals>.stream.<locals>.<genexpr>8  r   r   r   rK   rS   r   r   s     r/   r   z7RawExperimentsClient.stream_experiments.<locals>.stream3  r   r   Nr   r.   rh   r   r   r5   r   r_   s       ` @r/   stream_experimentsz'RawExperimentsClient.stream_experiments  s     8 !!..55+%6  2 , 6 
 xL)?@ x (N=
 
 
s   6A>/A2)	A>2A;7A>)5__name__
__module____qualname__r   r0   rW   rY   r   strr   r[   boolr   r	   ra   intr   rz   r   r%   r#   r$   r   r!   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r   r   r   r   r   r   
contextlibcontextmanagerr   r   r   r   r   r2   r/   r'   r'   ,   s	   .*; . -1;?=p __S!=p !	=p
 OOD)=p  8=p 
d	=pD &*%)+/04&*%)15*.+/15(,(,/3/3;?#ip ooc"ip ooc"	ip
 OOC(ip  -ip s#ip ooc"ip  .ip ??3'ip OOC(ip  .ip %ip %ip ,ip  t,!ip"  8#ip$ 
*	+%ip\ $(-1+/-1%)9=6:59NR049=TXBFTX37;?%ip OOC ip ooc*	ip
 OOC(ip ooc*ip ooc"ip //"56ip oofooc23ip oo12ip "??+JKip  -ip  56ip "??6??;O+PQip (>?ip   9O)PQ!ip" #OOC0#ip$  8%ip& 
d	'ip^ <@	(p !//.9(p  8	(p
 
d	(pV `d#pooc*#p=C__^=\#p	d	#pL `d#pooc*#p=C__^=\#p	d	#pV /3;?Xp Xp 	Xp
 RSXp s+Xp  8Xp 
d	Xpv 9=qu'p!'!5'pOU_mOn'p	.	/'pX (,&*%)+/15(,;?Ip $Ip s#	Ip
 ooc"Ip OOC(Ip  .Ip %Ip  8Ip 
-	.Ip\ (,&*%)+/15(,;?Ip $Ip s#	Ip
 ooc"Ip OOC(Ip  .Ip %Ip  8Ip 
9	:IpX `d.pooc*.p=C__^=\.p	d	.pb NR/p/p+1??>+J/p	&	'/pj &*.26:=A@D6::>OS;?apap ooc"	ap
 //(+ap oofooc23ap __V__S%9:ap (<=ap oo23ap  67ap "??6???+KLap  8ap 
d	apH NR/p/p+1??>+J/p	*	+/pb 
 '+26*.;?> > s#	>
 "??3/> //$'>  8> 
fooe&<=	>> >@ 
 '+26;?9 9 s#	9
 "??3/9  89 
fooe&<=	>9 9r2   r'   c            $          e Zd ZdefdZedddej                  e   de	dej                  e   dej                  e   d	ed   f
d
Zdddddddddddddddddej                  e   dej                  e   dej                  e   dej                  e   dej                  e   dej                  e   dej                  e   dej                  e   dej                  e   dej                  e   dej                  e   dej                  e   dej                  e   dej                  e   dej                  e   d	ee   f dZeeeeeeeeeeeeeeedddej                  e   dej                  e   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   dej                  e   d#ej                  e   d$ej                  ej                  e      d%ej                  e   d&ej                  ej                  e      d'ej                  e   dej                  e   d	ed   f"d(Zdd)d*ej                  e   dej                  e   d	ed   fd+Zdd)dej                  e   dej                  e   d	ed   fd,Zdd)dej                  e   dej                  e   d	ed   fd-Zedd.d/eded0ej                  e   d1ej                  e   dej                  e   d	ed   fd2Zddd3dej                  e   dej                  e   d	ee   fd4Z dddddddd5d6ej                  e   dej                  e   dej                  e   dej                  e   dej                  e   dej                  e   dej                  e   d	ee!   fd7Z"dddddddd5d6ej                  e   dej                  e   dej                  e   dej                  e   dej                  e   dej                  e   dej                  e   d	ee#   fd8Z$dd)dej                  e   dej                  e   d	ed   fd9Z%dd)dedej                  e   d	ee&   fd:Z'eeeeeeeedd;	dedej                  e   dej                  e(   d ej                  ej                  e      d<ej                  ej                  e      d=ej                  ej                  e      d!ej                  e)   d#ej                  e*   d$ej                  ej                  e+      dej                  e   d	ed   fd>Z,dd)dedej                  e   d	ee-   fd?Z.e/j`                  eeedd@d/edAej                  e   dBej                  e   dCej                  e   dej                  e   d	ejb                  eejb                  e2         fdD       Z3e/j`                  eeddEdedAej                  e   dBej                  e   dej                  e   d	ejb                  eejb                  e2         f
dF       Z4y)GAsyncRawExperimentsClientr(   c                    || _         y r*   r+   r-   s     r/   r0   z"AsyncRawExperimentsClient.__init__F  r1   r2   Nr3   r6   r7   r4   r5   r8   c                "  K   | j                   j                  j                  dd|t        |t        d      |dddi|t
               d	{   }	 d
|j                  cxk  rdk  rn nt        |d	      S |j                  dk(  rt        t        |j                        t        j                  t        j                  t        j                     t        t        j                  t        j                     |j!                                           |j!                         }t%        |j                  t        |j                        |      7 # t"        $ r6 t%        |j                  t        |j                        |j&                        w xY ww)a  
        Update multiple experiments

        Parameters
        ----------
        ids : typing.Sequence[str]
            List of experiment IDs to update (max 1000)

        update : ExperimentUpdate

        merge_tags : typing.Optional[bool]
            If true, merge tags with existing tags instead of replacing them. Default: false

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

        Returns
        -------
        AsyncHttpResponse[None]
        r:   r;   r<   r=   rA   rB   rC   rD   NrI   rJ   rK   rN   rO   rQ   rS   )r,   rU   rV   r   r   rW   rT   r   r   rX   rG   rY   rZ   r[   r\   r   rF   r   r   r]   r^   s          r/   ra   z2AsyncRawExperimentsClient.batch_update_experimentsI  sd    8 ..;;CC*A"/?7 )  2 , D 
 
	 	ti++1c1()$GG$$+% !2!23

3$"(//&**"=$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`nooC
>  	ty'<'<d9K\K\F]dmdrdrss	ts7   A	FEF$E 5F6B*E  ,F?FFrb   rc   rd   re   rf   rg   rh   ri   rj   rk   rl   rm   rn   ro   rp   c                x  K   | j                   j                  j                  dd|||||||||	|
||||d|       d{   }	 d|j                  cxk  rdk  rGn nDt	        j
                  t        t        t        |j                                     }t        ||	      S |j                  d
k(  rt        t        |j                        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                         }t!        |j                  t        |j                        |      7 7# t        $ r6 t!        |j                  t        |j                        |j"                        w xY ww)av  
        Find experiments

        Parameters
        ----------
        page : typing.Optional[int]

        size : typing.Optional[int]

        dataset_id : typing.Optional[str]

        optimization_id : typing.Optional[str]

        types : typing.Optional[str]

        name : typing.Optional[str]

        dataset_deleted : typing.Optional[bool]

        prompt_id : typing.Optional[str]

        project_id : typing.Optional[str]

        project_deleted : typing.Optional[bool]

        sorting : typing.Optional[str]

        filters : typing.Optional[str]

        experiment_ids : typing.Optional[str]

        force_sorting : typing.Optional[bool]

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

        Returns
        -------
        AsyncHttpResponse[ExperimentPagePublic]
            Experiments resource
        rr   rs   rt   rv   NrI   rJ   rO   rK   rN   rQ   rS   )r,   rU   rV   rT   rY   rZ   r   r   rF   r   r   rX   rG   r[   r\   r   r   r]   rx   s                      r/   rz   z*AsyncRawExperimentsClient.find_experiments  s    x ..;;CC$'#2#2&(#2"""0!.  ,' D 
 
	*	ti++1c1( 2 ) 0 ))%HH$$+% !2!23

3$"(//&**"=$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`noo[
V  	ty'<'<d9K\K\F]dmdrdrss	ts5   <F:E5F:AE8 F: B*E8 
,F:8?F77F:r{   r|   r}   r~   r   r   r   r   r   r   r   r   r   c                  K   | j                   j                  j                  dd|||||t        |t        d      |||	|
|t        |t
        j                  t           d      t        |t        d      t        |t
        j                  t           d      |dddi|t               d	{   }	 d
|j                  cxk  rdk  rn nt        |d	      S |j                         }t        |j                  t        |j                         |      7 e# t        $ r6 t        |j                  t        |j                         |j"                        w xY ww)a  
        Create experiment

        Parameters
        ----------
        id : typing.Optional[str]

        dataset_name : typing.Optional[str]

        project_id : typing.Optional[str]
            Project ID. Takes precedence over project_name when both are provided.

        project_name : typing.Optional[str]
            Project name. Creates project if it doesn't exist. Ignored when project_id is provided.

        name : typing.Optional[str]

        metadata : typing.Optional[JsonListStringWrite]

        tags : typing.Optional[typing.Sequence[str]]

        type : typing.Optional[ExperimentWriteType]

        evaluation_method : typing.Optional[ExperimentWriteEvaluationMethod]

        optimization_id : typing.Optional[str]

        status : typing.Optional[ExperimentWriteStatus]

        experiment_scores : typing.Optional[typing.Sequence[ExperimentScoreWrite]]

        prompt_version : typing.Optional[PromptVersionLinkWrite]

        prompt_versions : typing.Optional[typing.Sequence[PromptVersionLinkWrite]]

        dataset_version_id : typing.Optional[str]
            ID of the dataset version this experiment is linked to. If not provided at creation, experiment will be automatically linked to the latest version.

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

        Returns
        -------
        AsyncHttpResponse[None]
        rr   r   r<   r=   r   rB   rC   rD   NrI   rJ   rK   rS   )r,   rU   rV   r   r   rY   r   r   r!   rW   rT   r   rF   r   r   rX   rG   r]   r   s                      r/   r   z+AsyncRawExperimentsClient.create_experiment  sh    B ..;;CC$ ,( ,C$1DPW %6#2 %L-&//J^:_kr& #J*7MY`# $K+H^8_kr$ '9/4  2 ,A D !
 !
	D	ti++1c1()$GG&^^-N 9#8#8$yGXGXBY`nooQ!
L  	ty'<'<d9K\K\F]dmdrdrss	ts6   B'E)D*E/$D ED $,E?EEr   r   c          
        K   | j                   j                  j                  dddt        |t        j
                  t           d      iddi|t               d	{   }	 d
|j                  cxk  rdk  rn nt        |d	      S |j                         }t        |j                  t        |j                        |      7 e# t        $ r6 t        |j                  t        |j                        |j                        w xY ww)a3  
        Create experiment items

        Parameters
        ----------
        experiment_items : typing.Sequence[ExperimentItem]

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

        Returns
        -------
        AsyncHttpResponse[None]
        r   r   r   r<   r=   rB   rC   rD   NrI   rJ   rK   rS   )r,   rU   rV   r   rY   r   r   rW   rT   r   rF   r   r   rX   rG   r]   r   s        r/   r   z1AsyncRawExperimentsClient.create_experiment_items^  s     ( ..;;CC*"$K,9Xdk%  2 , D 
 
		ti++1c1()$GG&^^-N 9#8#8$yGXGXBY`noo)
$  	ty'<'<d9K\K\F]dmdrdrss	ts6   ADC D $C DC ,D?DDc                  K   | j                   j                  j                  ddd|iddi|t               d{   }	 d|j                  cxk  rd	k  rn nt        |d
      S |j                         }t        |j                  t        |j                        |      7 e# t        $ r6 t        |j                  t        |j                        |j                        w xY ww)a  
        Delete experiment items

        Parameters
        ----------
        ids : typing.Sequence[str]

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

        Returns
        -------
        AsyncHttpResponse[None]
        r   r   r6   rB   rC   rD   NrI   rJ   rK   rS   r,   rU   rV   rW   rT   r   rF   r   r   rX   rG   r]   r   s        r/   r   z1AsyncRawExperimentsClient.delete_experiment_items  s     " ..;;CC1s  2 , D 
 
		ti++1c1()$GG&^^-N 9#8#8$yGXGXBY`noo%
   	ty'<'<d9K\K\F]dmdrdrss	t2   7C#BC#$B! #C#$B! 4,C#!?C  C#c                  K   | j                   j                  j                  ddd|iddi|t               d{   }	 d|j                  cxk  rd	k  rn nt        |d
      S |j                         }t        |j                  t        |j                        |      7 e# t        $ r6 t        |j                  t        |j                        |j                        w xY ww)a  
        Delete experiments by id

        Parameters
        ----------
        ids : typing.Sequence[str]

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

        Returns
        -------
        AsyncHttpResponse[None]
        r   r   r6   rB   rC   rD   NrI   rJ   rK   rS   r  r   s        r/   r   z2AsyncRawExperimentsClient.delete_experiments_by_id  s     " ..;;CC+s  2 , D 
 
		ti++1c1()$GG&^^-N 9#8#8$yGXGXBY`noo%
   	ty'<'<d9K\K\F]dmdrdrss	tr  r   r   r   r   c                  K   | j                   j                  j                  dd|||t        |t        j
                  t           d      dddi|t               d	{   }	 d
|j                  cxk  rdk  rn nt        |d	      S |j                  dk(  rt        t        |j                        t	        j                  t        j                  t        j                     t!        t        j                  t        j                     |j#                                           |j                  dk(  rt%        t        |j                        t	        j                  t        j                  t        j                     t!        t        j                  t        j                     |j#                                           |j                  dk(  rt'        t        |j                        t	        j                  t        j                  t        j                     t!        t        j                  t        j                     |j#                                           |j#                         }t+        |j                  t        |j                        |      7 4# t(        $ r6 t+        |j                  t        |j                        |j,                        w xY ww)a  
        Record experiment items in bulk with traces, spans, and feedback scores. Maximum request size is 4MB.

        Parameters
        ----------
        experiment_name : str

        dataset_name : str

        items : typing.Sequence[ExperimentItemBulkRecordExperimentItemBulkWriteView]

        experiment_id : typing.Optional[str]
            Optional experiment ID. If provided, items will be added to the existing experiment and experimentName will be ignored. If not provided or experiment with that ID doesn't exist, a new experiment will be created with the given experimentName

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

        Returns
        -------
        AsyncHttpResponse[None]
        r   r   r<   r=   r   rB   rC   rD   NrI   rJ   rK   rN   rO   rQ   r   r   rS   )r,   rU   rV   r   rY   r   r   rW   rT   r   r   rX   rG   rZ   r[   r\   r   rF   r   r   r   r   r]   r   s           r/   r   z/AsyncRawExperimentsClient.experiment_items_bulk  sC    < ..;;CC/#2 ,!.@!%/bc%		  2 ,# D 
 
	&&	ti++1c1()$GG$$+% !2!23

3$"(//&**"=$-NN$4	 	 $$+# !2!23

3$"(//&**"=$-NN$4	 	 $$+. !2!23

3$"(//&**"=$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`noou
p  	ty'<'<d9K\K\F]dmdrdrss	ts7   AKJK#$J KGJ &,K?KKr   c                (  K   | j                   j                  j                  ddd|i|       d{   }	 d|j                  cxk  rdk  rGn nDt	        j
                  t        t        t        |j                                     }t        ||	      S |j                         }t        |j                  t        |j                        |
      7 # t        $ r6 t        |j                  t        |j                        |j                  
      w xY ww)aa  
        Find Feedback Score names

        Parameters
        ----------
        experiment_ids : typing.Optional[str]

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

        Returns
        -------
        AsyncHttpResponse[FeedbackScoreNamesPublic]
            Feedback Scores resource
        r   rs   ro   rv   NrI   rJ   rO   rK   rS   )r,   rU   rV   rT   rY   rZ   r   r   rF   r   r   r   rX   rG   r]   r   s         r/   r   z3AsyncRawExperimentsClient.find_feedback_score_names,  s     $ ..;;CC: . , D 
 
		ti++1c1, 6 ) 0 ))%HH&^^-N 9#8#8$yGXGXBY`noo+
&  	ty'<'<d9K\K\F]dmdrdrss	ts3   /DCDAC DC #,D?DDr   r   c                h  K   | j                   j                  j                  dd||||||d|       d{   }	 d|j                  cxk  rdk  rGn nDt	        j
                  t        t        t        |j                                     }	t        ||		      S |j                  d
k(  rt        t        |j                        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                         }
t!        |j                  t        |j                        |
      7 7# t        $ r6 t!        |j                  t        |j                        |j"                        w xY ww)a3  
        Find experiments grouped by specified fields

        Parameters
        ----------
        groups : typing.Optional[str]

        types : typing.Optional[str]

        name : typing.Optional[str]

        project_id : typing.Optional[str]

        project_deleted : typing.Optional[bool]

        filters : typing.Optional[str]

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

        Returns
        -------
        AsyncHttpResponse[ExperimentGroupResponse]
            Experiment groups
        r   rs   r   rv   NrI   rJ   rO   rK   rN   rQ   rS   )r,   rU   rV   rT   rY   rZ   r   r   rF   r   r   rX   rG   r[   r\   r   r   r]   r   s              r/   r   z0AsyncRawExperimentsClient.find_experiment_groupsU  sx    H ..;;CC+ (#2" , D 
 
		ti++1c1+ 5 ) 0 ))%HH$$+% !2!23

3$"(//&**"=$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`nooK
F  	ty'<'<d9K\K\F]dmdrdrss	t4   4F2E-F2AE0 F2B*E0 ,F20?F//F2c                h  K   | j                   j                  j                  dd||||||d|       d{   }	 d|j                  cxk  rdk  rGn nDt	        j
                  t        t        t        |j                                     }	t        ||		      S |j                  d
k(  rt        t        |j                        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                         }
t!        |j                  t        |j                        |
      7 7# t        $ r6 t!        |j                  t        |j                        |j"                        w xY ww)aj  
        Find experiments grouped by specified fields with aggregation metrics

        Parameters
        ----------
        groups : typing.Optional[str]

        types : typing.Optional[str]

        name : typing.Optional[str]

        project_id : typing.Optional[str]

        project_deleted : typing.Optional[bool]

        filters : typing.Optional[str]

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

        Returns
        -------
        AsyncHttpResponse[ExperimentGroupAggregationsResponse]
            Experiment groups with aggregations
        r   rs   r   rv   NrI   rJ   rO   rK   rN   rQ   rS   )r,   rU   rV   rT   rY   rZ   r   r   rF   r   r   rX   rG   r[   r\   r   r   r]   r   s              r/   r   z=AsyncRawExperimentsClient.find_experiment_groups_aggregations  sx    H ..;;CC8 (#2" , D 
 
		ti++1c17 A ) 0 ))%HH$$+% !2!23

3$"(//&**"=$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`nooK
F  	ty'<'<d9K\K\F]dmdrdrss	tr  c                  K   | j                   j                  j                  ddd|iddi|t               d{   }	 d|j                  cxk  rd	k  rn nt        |d
      S |j                  dk(  rt        t        |j                        t        j                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                         }t!        |j                  t        |j                        |      7 # t        $ r6 t!        |j                  t        |j                        |j"                        w xY ww)a/  
        Finish experiments and trigger alert events

        Parameters
        ----------
        ids : typing.Sequence[str]

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

        Returns
        -------
        AsyncHttpResponse[None]
        r   r   r6   rB   rC   rD   NrI   rJ   rK   rN   rO   rQ   rS   )r,   rU   rV   rW   rT   r   r   rX   rG   rY   rZ   r[   r\   r   rF   r   r   r]   r   s        r/   r   z,AsyncRawExperimentsClient.finish_experiments  sP    " ..;;CC+s  2 , D 
 
		ti++1c1()$GG$$+% !2!23

3$"(//&**"=$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`noo;
6  	ty'<'<d9K\K\F]dmdrdrss	ts3   7E=D9E=$D; #E=$B*D; ,E=;?E::E=c                p  K   | j                   j                  j                  dt        |       d|       d{   }	 d|j                  cxk  rdk  rGn nDt        j                  t        t        t        |j                                     }t        ||      S |j                  d	k(  rt        t        |j                        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                     
      |j                         }t#        |j                  t        |j                        |      7 7# t         $ r6 t#        |j                  t        |j                        |j$                        w xY ww)a2  
        Get experiment by id

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

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

        Returns
        -------
        AsyncHttpResponse[ExperimentPublic]
            Experiment resource
        r   rs   r   NrI   rJ   rO   rK   r   rQ   rS   )r,   rU   rV   r
   rT   rY   rZ   r   r   rF   r   r   rX   rG   r[   r\   r   r   r]   r   s         r/   r   z.AsyncRawExperimentsClient.get_experiment_by_id  sj    $ ..;;CC%&6r&:%;<+ D 
 
	
	ti++1c1$ . ) 0 ))%HH$$+# !2!23

3$"(//&**"=$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`noo;
6  	ty'<'<d9K\K\F]dmdrdrss	t5   8F6E1F6 AE4 F6B*E4 ,F64?F33F6r   r   r   c       	           K   | j                   j                  j                  dt        |       d|||||||t	        |	t
        j                  t           d      dddi|
t               d	{   }	 d
|j                  cxk  rdk  rn nt        |d	      S |j                  dk(  rt        t        |j                        t        j                  t
        j                  t
        j                      t#        t
        j                  t
        j                      |j%                                           |j                  dk(  rt'        t        |j                        t        j                  t
        j                  t
        j                      t#        t
        j                  t
        j                      |j%                                           |j%                         }t+        |j                  t        |j                        |      7 # t(        $ r6 t+        |j                  t        |j                        |j,                        w xY ww)a;  
        Update experiment by id

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

        name : typing.Optional[str]

        metadata : typing.Optional[JsonNode]

        tags : typing.Optional[typing.Sequence[str]]
            Tags

        tags_to_add : typing.Optional[typing.Sequence[str]]
            Tags to add

        tags_to_remove : typing.Optional[typing.Sequence[str]]
            Tags to remove

        type : typing.Optional[ExperimentUpdateType]

        status : typing.Optional[ExperimentUpdateStatus]
            The status of the experiment

        experiment_scores : typing.Optional[typing.Sequence[ExperimentScore]]

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

        Returns
        -------
        AsyncHttpResponse[None]
        r   r;   r<   r=   r   rB   rC   rD   NrI   rJ   rK   rN   rO   rQ   r   rS   )r,   rU   rV   r
   r   rY   r   r   rW   rT   r   r   rX   rG   rZ   r[   r\   r   rF   r   r   r   r]   r   s                r/   r   z+AsyncRawExperimentsClient.update_experimentL  s    ` ..;;CC%&6r&:%;<$*"0 %L-&///:Zfm&  2 ,' D 
 
	*	ti++1c1()$GG$$+% !2!23

3$"(//&**"=$-NN$4	 	 $$+# !2!23

3$"(//&**"=$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`nooc
^  	ty'<'<d9K\K\F]dmdrdrss	ts7   A+I-H.I3$H
 IEH
 ,I
?I		Ic                p  K   | j                   j                  j                  dt        |       d|       d{   }	 d|j                  cxk  rdk  rGn nDt        j                  t        t        t        |j                                     }t        ||      S |j                  d	k(  rt        t        |j                        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                     
      |j                         }t#        |j                  t        |j                        |      7 7# t         $ r6 t#        |j                  t        |j                        |j$                        w xY ww)a@  
        Get experiment item by id

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

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

        Returns
        -------
        AsyncHttpResponse[ExperimentItemPublic]
            Experiment item resource
        r   rs   r   NrI   rJ   rO   rK   r   rQ   rS   )r,   rU   rV   r
   rT   rY   rZ   r   r   rF   r   r   rX   rG   r[   r\   r   r   r]   r   s         r/   r   z3AsyncRawExperimentsClient.get_experiment_item_by_id  sj    $ ..;;CC+,<R,@+AB+ D 
 
	
	ti++1c1( 2 ) 0 ))%HH$$+# !2!23

3$"(//&**"=$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`noo;
6  	ty'<'<d9K\K\F]dmdrdrss	tr  r   r   r   r   c          	     R  K   | j                   j                  j                  dd||||dddit              4 d{   dt        t
        j                  t              ffd	} |        d{    ddd      d{    y7 L7 7 	# 1 d{  7  sw Y   yxY ww)
a  
        Stream experiment items

        Parameters
        ----------
        experiment_name : str

        limit : typing.Optional[int]

        last_retrieved_id : typing.Optional[str]

        truncate : typing.Optional[bool]
            Truncate image included in either input, output or metadata

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.

        Returns
        -------
        typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]]
            Experiment items stream or error during process
        r   r   r   rB   rC   rD   Nr8   c                    K   	 dj                   cxk  rdk  r=n n:j                  dd       nd } t        d j                  |       2              S j	                          d {    j                         }t        j                   t        j                        |      7 ?# t        $ r6 t        j                   t        j                        j                        w xY ww)NrI   rJ   r   c                2   K   | 3 d {   }| 7 
6 y wr*   r   r   s     r/   r   zTAsyncRawExperimentsClient.stream_experiment_items.<locals>.stream.<locals>.<genexpr>       !k!k6&!k!k   r   rK   rS   rT   r   r   aiter_bytesareadrF   r   r   rX   rG   r]   r   s     r/   r   zAAsyncRawExperimentsClient.stream_experiment_items.<locals>.stream       i339c9Q`Qlo&9&9,&Mrv0%.!kY=R=R^i=R=j!k   $//+++%.^^%5N
 9+@+@$yO`O`Jahvww ,& "$-$9$94	HYHYCZajaoao ;   C.AB, C.B, *B*+B, ?+C.*B, ,?C++C.r,   rU   r   rW   r   rY   AsyncIteratorr   r   s        ` @r/   r   z1AsyncRawExperimentsClient.stream_experiment_items  s     @ ''44;;1#2%6$	  2 , < 
 
 x"3F4H4H4O"P x  . A
 
 
@ !A
 
 
 
sX   ;B'B B'0B3B4B;B'BB'BB'B$BB$ B'r   c               P  K   | j                   j                  j                  dd|||dddit              4 d{   dt        t
        j                  t              ffd	} |        d{    ddd      d{    y7 L7 7 	# 1 d{  7  sw Y   yxY ww)
a&  
        Stream experiments

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

        limit : typing.Optional[int]

        last_retrieved_id : typing.Optional[str]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.

        Returns
        -------
        typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]]
            Experiments stream or error during process
        r   r   r   rB   rC   rD   Nr8   c                    K   	 dj                   cxk  rdk  r=n n:j                  dd       nd } t        d j                  |       2              S j	                          d {    j                         }t        j                   t        j                        |      7 ?# t        $ r6 t        j                   t        j                        j                        w xY ww)NrI   rJ   r   c                2   K   | 3 d {   }| 7 
6 y wr*   r   r   s     r/   r   zOAsyncRawExperimentsClient.stream_experiments.<locals>.stream.<locals>.<genexpr>S  r  r  r   rK   rS   r  r   s     r/   r   z<AsyncRawExperimentsClient.stream_experiments.<locals>.streamM  r  r  r  r   s       ` @r/   r   z,AsyncRawExperimentsClient.stream_experiments"  s     8 ''44;;+%6  2 , < 
 
 x"3F4H4H4O"P x  . ?
 
 
> !?
 
 
 
sW   :B&BB&0B2B3B:B&BB&BB&B#BB#B&)5r   r   r   r   r0   rW   rY   r   r   r   r[   r   r   r   ra   r   r   rz   r   r%   r#   r$   r   r!   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r   r   r   r   r   r   r   asynccontextmanagerr  r   r   r   r   r2   r/   r   r   E  s	   .*< . -1;?=p __S!=p !	=p
 OOD)=p  8=p 
4	 =pD &*%)+/04&*%)15*.+/15(,(,/3/3;?#ip ooc"ip ooc"	ip
 OOC(ip  -ip s#ip ooc"ip  .ip ??3'ip OOC(ip  .ip %ip %ip ,ip  t,!ip"  8#ip$ 
/	0%ip\ $(-1+/-1%)9=6:59NR049=TXBFTX37;?%ip OOC ip ooc*	ip
 OOC(ip ooc*ip ooc"ip //"56ip oofooc23ip oo12ip "??+JKip  -ip  56ip "??6??;O+PQip (>?ip   9O)PQ!ip" #OOC0#ip$  8%ip& 
4	 'ip^ <@	(p !//.9(p  8	(p
 
4	 (pV `d#pooc*#p=C__^=\#p	4	 #pL `d#pooc*#p=C__^=\#p	4	 #pV /3;?Xp Xp 	Xp
 RSXp s+Xp  8Xp 
4	 Xpv 9=qu'p!'!5'pOU_mOn'p	3	4'pX (,&*%)+/15(,;?Ip $Ip s#	Ip
 ooc"Ip OOC(Ip  .Ip %Ip  8Ip 
2	3Ip\ (,&*%)+/15(,;?Ip $Ip s#	Ip
 ooc"Ip OOC(Ip  .Ip %Ip  8Ip 
>	?IpX `d.pooc*.p=C__^=\.p	4	 .pb NR/p/p+1??>+J/p	+	,/pj &*.26:=A@D6::>OS;?apap ooc"	ap
 //(+ap oofooc23ap __V__S%9:ap (<=ap oo23ap  67ap "??6???+KLap  8ap 
4	 apH NR/p/p+1??>+J/p	/	0/pb ##
 '+26*.;??! ?! s#	?!
 "??3/?! //$'?!  8?! 
		/0D0DU0KL	M?! $?!B ##
 '+26;?:! :! s#	:!
 "??3/:!  8:! 
		/0D0DU0KL	M:! $:!r2   r   )Gr   rY   json.decoderr   core.api_errorr   core.client_wrapperr   r   core.http_responser   r	   core.jsonable_encoderr
   core.pydantic_utilitiesr   core.request_optionsr   core.serializationr   errors.bad_request_errorr   errors.conflict_errorr   errors.not_found_errorr   !errors.unprocessable_entity_errorr   ,types.experiment_group_aggregations_responser   types.experiment_group_responser   types.experiment_itemr   Atypes.experiment_item_bulk_record_experiment_item_bulk_write_viewr   types.experiment_item_publicr   types.experiment_page_publicr   types.experiment_publicr   types.experiment_scorer   types.experiment_score_writer   types.experiment_updater   types.experiment_update_statusr   types.experiment_update_typer   !types.feedback_score_names_publicr   types.json_list_string_writer   types.json_noder    types.prompt_version_link_writer!   (types.experiment_write_evaluation_methodr#   types.experiment_write_statusr$   types.experiment_write_typer%   rZ   r\   rW   r'   r   r   r2   r/   <module>rA     s      ( % G @ 4 2 1 H 6 1 2 H ^ E 2 @ ? 6 4 ? 6 C ? H > & D U @ < v{{6::s#V Vr X! X!r2   