
    ]j                        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  e j6                  e j8                  d      Z G d d      Z G d d      Zy)    N)JSONDecodeError   )ApiError)AsyncClientWrapperSyncClientWrapper)AsyncHttpResponseHttpResponse)jsonable_encoder)RequestOptions)construct_type)InternalServerError)	MlBackend   )CreateMlRequestAuthMethod)ListModelVersionsMlResponse)UpdateMlRequestAuthMethod.c                      e Zd ZdefdZddddej                  e   dej                  e   de	ej                  e      fdZ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j                   eej"                  f      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dddedej                  e   de	e   fdZdddedej                  e   de	d   fdZeeeeeeeeeedd	ded
ej                  e   dej                  e   dej                  e   dej                  e   dej                  ej                   eej"                  f      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dddededej                  ej"                     dej                  e   de	d   f
dZddddedej                  e   dej                  e   de	d   fdZedd ded!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y)$RawMlClientclient_wrapperc                    || _         y N_client_wrapperselfr   s     H/root/env/lib/python3.12/site-packages/label_studio_sdk/ml/raw_client.py__init__zRawMlClient.__init__   
    -    Nprojectrequest_optionsr!   r"   returnc                P   | j                   j                  j                  ddd|i|      }	 d|j                  cxk  rdk  rin nft	        j
                  t        j                  t           t        t        j                  t           |j                                     }t        ||      S |j                         }t        |j                  t        |j                        |	      # t        $ r6 t        |j                  t        |j                        |j                  	      w xY w)
a  

            List all configured ML backends for a specific project by ID.
            Use the following cURL command:
            ```bash
            curl http://localhost:8000/api/ml?project={project_id} -H 'Authorization: Token abc123'


        Parameters
        ----------
        project : typing.Optional[int]
            Project ID

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

        Returns
        -------
        HttpResponse[typing.List[MlBackend]]

        api/ml/GETr!   methodparamsr"      ,  type_object_responsedatastatus_codeheadersbody)r   httpx_clientrequestr3   typingcastListr   r   jsonr	   r   r   dictr4   textr   r!   r"   	_response_data_response_jsons         r   listzRawMlClient.list   s   0 ((55==7 , > 
		ti++1c1KK	*"$kk)4 ) 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%auth_methodbasic_auth_passbasic_auth_userdescriptionextra_paramsis_interactiver!   timeouttitleurlr"   rD   rE   rF   rG   rH   rI   rJ   rK   rL   c                .   | j                   j                  j                  dd|||||||||	|
d
ddi|t              }	 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  
        
            Add an ML backend to a project using the Label Studio UI or by sending a POST request using the following cURL 
            command:
            ```bash
            curl -X POST -H 'Content-type: application/json' http://localhost:8000/api/ml -H 'Authorization: Token abc123'\
            --data '{"url": "http://localhost:9090", "project": {project_id}}' 
            
        
        Parameters
        ----------
        auth_method : typing.Optional[CreateMlRequestAuthMethod]
            Auth method
        
        basic_auth_pass : typing.Optional[str]
            Basic auth password
        
        basic_auth_user : typing.Optional[str]
            Basic auth user
        
        description : typing.Optional[str]
            Description
        
        extra_params : typing.Optional[typing.Dict[str, typing.Any]]
            Extra parameters
        
        is_interactive : typing.Optional[bool]
            Is interactive
        
        project : typing.Optional[int]
            Project ID
        
        timeout : typing.Optional[int]
            Response model timeout
        
        title : typing.Optional[str]
            Title
        
        url : typing.Optional[str]
            ML backend URL
        
        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.
        
        Returns
        -------
        HttpResponse[MlBackend]
            
        r%   POST
rD   rE   rF   rG   rH   rI   r!   rJ   rK   rL   content-typeapplication/jsonr(   r;   r4   r"   omitr*   r+   r,   r/   r2   )r   r6   r7   OMITr3   r8   r9   r   r   r;   r	   r   r   r<   r4   r=   r   rD   rE   rF   rG   rH   rI   r!   rJ   rK   rL   r"   r?   r@   rA   s                  r   createzRawMlClient.createI   s   @ ((55==*#2#2* ,"0""  2 ,' > 
	*	ti++1c1"' ) 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r"   idc                   | j                   j                  j                  dt        |       d|      }	 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  

            Get details about a specific ML backend connection by ID. For example, make a GET request using the
            following cURL command:
            ```bash
            curl http://localhost:8000/api/ml/{ml_backend_ID} -H 'Authorization: Token abc123'


        Parameters
        ----------
        id : int

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

        Returns
        -------
        HttpResponse[MlBackend]

        r%   r&   r(   r"   r*   r+   r,   r/   r2   )r   r6   r7   r
   r3   r8   r9   r   r   r;   r	   r   r   r<   r4   r=   r   rX   r"   r?   r@   rA   s         r   getzRawMlClient.get   s    * ((55==&r*+,+ > 
	
	ti++1c1"' ) 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c                   | j                   j                  j                  dt        |       d|      }	 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  

            Remove an existing ML backend connection by ID. For example, use the
            following cURL command:
            ```bash
            curl -X DELETE http://localhost:8000/api/ml/{ml_backend_ID} -H 'Authorization: Token abc123'


        Parameters
        ----------
        id : int

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

        Returns
        -------
        HttpResponse[None]
        r%   DELETErZ   r*   r+   Nr/   r2   r   r6   r7   r
   r3   r	   r;   r   r   r<   r4   r=   r   rX   r"   r?   rA   s        r   deletezRawMlClient.delete   s    ( ((55==&r*+,+ > 
	
	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   $B B ?Cc                F   | j                   j                  j                  dt        |       d||||||||	|
|d
ddi|t              }	 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  
        
            Update ML backend parameters using the Label Studio UI or by sending a PATCH request using the following cURL command:
            ```bash
            curl -X PATCH -H 'Content-type: application/json' http://localhost:8000/api/ml/{ml_backend_ID} -H 'Authorization: Token abc123'\
            --data '{"url": "http://localhost:9091"}' 
            
        
        Parameters
        ----------
        id : int
        
        auth_method : typing.Optional[UpdateMlRequestAuthMethod]
            Auth method
        
        basic_auth_pass : typing.Optional[str]
            Basic auth password
        
        basic_auth_user : typing.Optional[str]
            Basic auth user
        
        description : typing.Optional[str]
            Description
        
        extra_params : typing.Optional[typing.Dict[str, typing.Any]]
            Extra parameters
        
        is_interactive : typing.Optional[bool]
            Is interactive
        
        project : typing.Optional[int]
            Project ID
        
        timeout : typing.Optional[int]
            Response model timeout
        
        title : typing.Optional[str]
            Title
        
        url : typing.Optional[str]
            ML backend URL
        
        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.
        
        Returns
        -------
        HttpResponse[MlBackend]
            
        r%   PATCHrO   rP   rQ   rR   r*   r+   r,   r/   r2   )r   r6   r7   r
   rT   r3   r8   r9   r   r   r;   r	   r   r   r<   r4   r=   r   rX   rD   rE   rF   rG   rH   rI   r!   rJ   rK   rL   r"   r?   r@   rA   s                   r   updatezRawMlClient.update   s)   D ((55==&r*+,*#2#2* ,"0""  2 ,' > 
	*	ti++1c1"' ) 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 contextr"   taskrg   c                   | j                   j                  j                  dt        |       d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  

                Send a request to the machine learning backend set up to be used for interactive preannotations to retrieve a
                predicted region based on annotator input.
                See [set up machine learning](https://labelstud.io/guide/ml.html#Get-interactive-preannotations) for more.


        Parameters
        ----------
        id : int
            A unique integer value identifying this ML backend.

        task : int
            ID of task to annotate

        context : typing.Optional[typing.Any]
            Context for ML model

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

        Returns
        -------
        HttpResponse[None]
        r%   /interactive-annotatingrN   rg   rh   rP   rQ   rR   r*   r+   Nr/   r2   )r   r6   r7   r
   rT   r3   r	   r;   r   r   r<   r4   r=   r   rX   rh   rg   r"   r?   rA   s          r   predict_interactivezRawMlClient.predict_interactive]  s    B ((55==&r*++BC"
  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   $B# (B# #?C"
batch_sizer"   ro   c                   | j                   j                  j                  dt        |       ddd|i|      }	 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  
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>


        Create predictions for all tasks using a specific ML backend so that you can set up an active learning strategy based on the confidence or uncertainty scores associated with the predictions. Creating predictions requires a Label Studio ML backend set up and configured for your project.

        See [Set up machine learning](https://labelstud.io/guide/ml.html) for more details about a Label Studio ML backend.

        Reference the ML backend ID in the path of this API call. Get the ML backend ID by [listing the ML backends for a project](https://labelstud.io/api/#operation/api_ml_list).

        Parameters
        ----------
        id : int
            A unique integer value identifying this ML backend.

        batch_size : typing.Optional[int]
            Computed number of tasks without predictions that the ML backend needs to predict.

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

        Returns
        -------
        HttpResponse[None]
        r%   /predictrN   ro   r'   r*   r+   Nr/   r2   r_   r   rX   ro   r"   r?   rA   s         r   predict_all_taskszRawMlClient.predict_all_tasks  s    J ((55==&r*+84j , > 
		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   $B B ?Cuse_ground_truthr"   ru   c                   | j                   j                  j                  dt        |       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(  rit        t        |j                        t        j                  t        j                  t        t        j                  |j                                           |j                         }t!        |j
                  t        |j                        |      # t        $ r6 t!        |j
                  t        |j                        |j"                        w xY w)a  

                After you add an ML backend, call this API with the ML backend ID to start training with
                already-labeled tasks.

                Get the ML backend ID by [listing the ML backends for a project](https://labelstud.io/api/#operation/api_ml_list).


        Parameters
        ----------
        id : int
            A unique integer value identifying this ML backend.

        use_ground_truth : typing.Optional[bool]
            Whether to include ground truth annotations in training

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

        Returns
        -------
        HttpResponse[None]
        r%   /trainrN   ru   rP   rQ   rR   r*   r+   Nr/     r,   r4   r5   r2   )r   r6   r7   r
   rT   r3   r	   r   r<   r4   r8   r9   Anyr   r;   r   r   r=   r   rX   ru   r"   r?   rA   s         r   trainzRawMlClient.train  sA   < ((55==&r*+62"$4  2 , > 
		ti++1c1#YTBB$$+) !2!2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                    | 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                         }t        |j                  t        |j                        |	      # t        $ r6 t        |j                  t        |j                        |j                  	      w xY w)
aP  
        Get available versions of the model.

        Parameters
        ----------
        id : int

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

        Returns
        -------
        HttpResponse[ListModelVersionsMlResponse]
            List of available versions.
        r%   	/versionsr&   rZ   r*   r+   r,   r/   r2   )r   r6   r7   r
   r3   r8   r9   r   r   r;   r	   r   r   r<   r4   r=   r[   s         r   list_model_versionszRawMlClient.list_model_versions  s    $ ((55==&r*+95+ > 
	
	ti++1c1/"9 ) 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)__name__
__module____qualname__r   r   r8   Optionalintr   r	   r:   r   rB   rT   r   strDictrz   boolrV   r\   ra   r   re   rm   rs   r|   r   r    r   r   r   r      st   .*; . 26jn-p //#.-pHNXfHg-p	fkk),	--pd CG0404,0FJ04(,(,&*$(;?bp __%>?bp  -	bp
  -bp __S)bp oofkk#vzz/&BCbp -bp %bp %bp s#bp __S!bp  8bp 
i	 bpH RV 'pc 'pv~/N 'pZfgpZq 'pR UY p p&//.2Q p]ijn]o pJ CG0404,0FJ04(,(,&*$(;?dpdp __%>?	dp
  -dp  -dp __S)dp oofkk#vzz/&BCdp -dp %dp %dp s#dp __S!dp  8dp 
i	 dpV 04;?4p4p 	4p
 ,4p  84p 
d	4pt ,0;?3p3p OOC(	3p
  83p 
d	3pr 37;?;p;p !//$/	;p
  8;p 
d	;p| NR$p$p+1??>+J$p	1	2$pr   r   c                      e Zd ZdefdZddddej                  e   dej                  e   de	ej                  e      fdZ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j                   eej"                  f      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dddedej                  e   de	e   fdZdddedej                  e   de	d   fdZeeeeeeeeeedd	ded
ej                  e   dej                  e   dej                  e   dej                  e   dej                  ej                   eej"                  f      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dddededej                  ej"                     dej                  e   de	d   f
dZddddedej                  e   dej                  e   de	d   fdZedd ded!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y)$AsyncRawMlClientr   c                    || _         y r   r   r   s     r   r   zAsyncRawMlClient.__init__-  r   r   Nr    r!   r"   r#   c                l  K   | j                   j                  j                  ddd|i|       d{   }	 d|j                  cxk  rdk  rin nft	        j
                  t        j                  t           t        t        j                  t           |j                                     }t        ||	      S |j                         }t        |j                  t        |j                        |
      7 # t        $ r6 t        |j                  t        |j                        |j                  
      w xY ww)a  

            List all configured ML backends for a specific project by ID.
            Use the following cURL command:
            ```bash
            curl http://localhost:8000/api/ml?project={project_id} -H 'Authorization: Token abc123'


        Parameters
        ----------
        project : typing.Optional[int]
            Project ID

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

        Returns
        -------
        AsyncHttpResponse[typing.List[MlBackend]]

        r%   r&   r!   r'   Nr*   r+   r,   r/   r2   )r   r6   r7   r3   r8   r9   r:   r   r   r;   r   r   r   r<   r4   r=   r>   s         r   rB   zAsyncRawMlClient.list0  s    0 ..;;CC7 , D 
 
		ti++1c1KK	*"$kk)4 ) 0 ))%HH&^^-N 9#8#8$yGXGXBY`noo+
&  	ty'<'<d9K\K\F]dmdrdrss	ts3   /D4C0D4A=C2 4D45C2 ,D42?D11D4rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   c                J  K   | j                   j                  j                  dd|||||||||	|
d
ddi|t               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)a  
        
            Add an ML backend to a project using the Label Studio UI or by sending a POST request using the following cURL 
            command:
            ```bash
            curl -X POST -H 'Content-type: application/json' http://localhost:8000/api/ml -H 'Authorization: Token abc123'\
            --data '{"url": "http://localhost:9090", "project": {project_id}}' 
            
        
        Parameters
        ----------
        auth_method : typing.Optional[CreateMlRequestAuthMethod]
            Auth method
        
        basic_auth_pass : typing.Optional[str]
            Basic auth password
        
        basic_auth_user : typing.Optional[str]
            Basic auth user
        
        description : typing.Optional[str]
            Description
        
        extra_params : typing.Optional[typing.Dict[str, typing.Any]]
            Extra parameters
        
        is_interactive : typing.Optional[bool]
            Is interactive
        
        project : typing.Optional[int]
            Project ID
        
        timeout : typing.Optional[int]
            Response model timeout
        
        title : typing.Optional[str]
            Title
        
        url : typing.Optional[str]
            ML backend URL
        
        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.
        
        Returns
        -------
        AsyncHttpResponse[MlBackend]
            
        r%   rN   rO   rP   rQ   rR   Nr*   r+   r,   r/   r2   )r   r6   r7   rT   r3   r8   r9   r   r   r;   r   r   r   r<   r4   r=   rU   s                  r   rV   zAsyncRawMlClient.create_  s+    @ ..;;CC*#2#2* ,"0""  2 ,' D 
 
	*	ti++1c1"' ) 0 ))%HH&^^-N 9#8#8$yGXGXBY`nooE
@  	ty'<'<d9K\K\F]dmdrdrss	ts7   A D#CD#AC! #D#$C! 4,D#!?D  D#rW   rX   c                :  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                         }t        |j                  t        |j                        |	      7 # t        $ r6 t        |j                  t        |j                        |j                  	      w xY ww)
a  

            Get details about a specific ML backend connection by ID. For example, make a GET request using the
            following cURL command:
            ```bash
            curl http://localhost:8000/api/ml/{ml_backend_ID} -H 'Authorization: Token abc123'


        Parameters
        ----------
        id : int

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

        Returns
        -------
        AsyncHttpResponse[MlBackend]

        r%   r&   rZ   Nr*   r+   r,   r/   r2   )r   r6   r7   r
   r3   r8   r9   r   r   r;   r   r   r   r<   r4   r=   r[   s         r   r\   zAsyncRawMlClient.get  s    . ..;;CC&r*+,+ D 
 
	
	ti++1c1"' ) 0 ))%HH&^^-N 9#8#8$yGXGXBY`noo%
   	ty'<'<d9K\K\F]dmdrdrss	ts4   8DCD AC DC ,,D?DDc                  K   | j                   j                  j                  dt        |       d|       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  

            Remove an existing ML backend connection by ID. For example, use the
            following cURL command:
            ```bash
            curl -X DELETE http://localhost:8000/api/ml/{ml_backend_ID} -H 'Authorization: Token abc123'


        Parameters
        ----------
        id : int

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

        Returns
        -------
        AsyncHttpResponse[None]
        r%   r^   rZ   Nr*   r+   r/   r2   r   r6   r7   r
   r3   r   r;   r   r   r<   r4   r=   r`   s        r   ra   zAsyncRawMlClient.delete  s     , ..;;CC&r*+,+ D 
 
	
	ti++1c1()$GG&^^-N 9#8#8$yGXGXBY`noo
  	ty'<'<d9K\K\F]dmdrdrss	ts3   8C$B C$ $B" $C$%B" 5,C$"?C!!C$c                b  K   | j                   j                  j                  dt        |       d||||||||	|
|d
ddi|t               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)a  
        
            Update ML backend parameters using the Label Studio UI or by sending a PATCH request using the following cURL command:
            ```bash
            curl -X PATCH -H 'Content-type: application/json' http://localhost:8000/api/ml/{ml_backend_ID} -H 'Authorization: Token abc123'\
            --data '{"url": "http://localhost:9091"}' 
            
        
        Parameters
        ----------
        id : int
        
        auth_method : typing.Optional[UpdateMlRequestAuthMethod]
            Auth method
        
        basic_auth_pass : typing.Optional[str]
            Basic auth password
        
        basic_auth_user : typing.Optional[str]
            Basic auth user
        
        description : typing.Optional[str]
            Description
        
        extra_params : typing.Optional[typing.Dict[str, typing.Any]]
            Extra parameters
        
        is_interactive : typing.Optional[bool]
            Is interactive
        
        project : typing.Optional[int]
            Project ID
        
        timeout : typing.Optional[int]
            Response model timeout
        
        title : typing.Optional[str]
            Title
        
        url : typing.Optional[str]
            ML backend URL
        
        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.
        
        Returns
        -------
        AsyncHttpResponse[MlBackend]
            
        r%   rc   rO   rP   rQ   rR   Nr*   r+   r,   r/   r2   )r   r6   r7   r
   rT   r3   r8   r9   r   r   r;   r   r   r   r<   r4   r=   rd   s                   r   re   zAsyncRawMlClient.update  s9    D ..;;CC&r*+,*#2#2* ,"0""  2 ,' D 
 
	*	ti++1c1"' ) 0 ))%HH&^^-N 9#8#8$yGXGXBY`nooE
@  	ty'<'<d9K\K\F]dmdrdrss	ts7   AD/C+D/AC- /D/0C-  ,D/-?D,,D/rf   rh   rg   c                  K   | j                   j                  j                  dt        |       d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  

                Send a request to the machine learning backend set up to be used for interactive preannotations to retrieve a
                predicted region based on annotator input.
                See [set up machine learning](https://labelstud.io/guide/ml.html#Get-interactive-preannotations) for more.


        Parameters
        ----------
        id : int
            A unique integer value identifying this ML backend.

        task : int
            ID of task to annotate

        context : typing.Optional[typing.Any]
            Context for ML model

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

        Returns
        -------
        AsyncHttpResponse[None]
        r%   rj   rN   rk   rP   rQ   rR   Nr*   r+   r/   r2   )r   r6   r7   r
   rT   r3   r   r;   r   r   r<   r4   r=   rl   s          r   rm   z$AsyncRawMlClient.predict_interactivew  s     B ..;;CC&r*++BC"
  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C1B-C1$B/ 1C12B/ ,C1/?C..C1rn   ro   c                  K   | j                   j                  j                  dt        |       ddd|i|       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  
        <Card href="https://humansignal.com/goenterprise">
                <img style="pointer-events: none; margin-left: 0px; margin-right: 0px;" src="https://docs.humansignal.com/images/badge.svg" alt="Label Studio Enterprise badge"/>
                <p style="margin-top: 10px; font-size: 14px;">
                    This endpoint is not available in Label Studio Community Edition. [Learn more about Label Studio Enterprise](https://humansignal.com/goenterprise)
                </p>
            </Card>


        Create predictions for all tasks using a specific ML backend so that you can set up an active learning strategy based on the confidence or uncertainty scores associated with the predictions. Creating predictions requires a Label Studio ML backend set up and configured for your project.

        See [Set up machine learning](https://labelstud.io/guide/ml.html) for more details about a Label Studio ML backend.

        Reference the ML backend ID in the path of this API call. Get the ML backend ID by [listing the ML backends for a project](https://labelstud.io/api/#operation/api_ml_list).

        Parameters
        ----------
        id : int
            A unique integer value identifying this ML backend.

        batch_size : typing.Optional[int]
            Computed number of tasks without predictions that the ML backend needs to predict.

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

        Returns
        -------
        AsyncHttpResponse[None]
        r%   rq   rN   ro   r'   Nr*   r+   r/   r2   r   rr   s         r   rs   z"AsyncRawMlClient.predict_all_tasks  s     J ..;;CC&r*+84j , D 
 
		ti++1c1()$GG&^^-N 9#8#8$yGXGXBY`noo
  	ty'<'<d9K\K\F]dmdrdrss	ts3   <C(B$C($B& (C()B& 9,C(&?C%%C(rt   ru   c                  K   | j                   j                  j                  dt        |       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(  rit        t        |j                        t        j                  t        j                  t        t        j                  |j                                           |j                         }t!        |j
                  t        |j                        |      7 # t        $ r6 t!        |j
                  t        |j                        |j"                        w xY ww)a  

                After you add an ML backend, call this API with the ML backend ID to start training with
                already-labeled tasks.

                Get the ML backend ID by [listing the ML backends for a project](https://labelstud.io/api/#operation/api_ml_list).


        Parameters
        ----------
        id : int
            A unique integer value identifying this ML backend.

        use_ground_truth : typing.Optional[bool]
            Whether to include ground truth annotations in training

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

        Returns
        -------
        AsyncHttpResponse[None]
        r%   rw   rN   ru   rP   rQ   rR   Nr*   r+   r/   rx   r,   ry   r2   )r   r6   r7   r
   rT   r3   r   r   r<   r4   r8   r9   rz   r   r;   r   r   r=   r{   s         r   r|   zAsyncRawMlClient.train  sO    < ..;;CC&r*+62"$4  2 , D 
 
		ti++1c1()$GG$$+) !2!23

&"(**$-NN$4	 	 '^^-N 9#8#8$yGXGXBY`noo;
6  	ty'<'<d9K\K\F]dmdrdrss	ts7   AE(D$E($D& 0E(1BD& 9,E(&?E%%E(c                <  K   | j                   j                  j                  dt        |       dd|       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)aU  
        Get available versions of the model.

        Parameters
        ----------
        id : int

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

        Returns
        -------
        AsyncHttpResponse[ListModelVersionsMlResponse]
            List of available versions.
        r%   r~   r&   rZ   Nr*   r+   r,   r/   r2   )r   r6   r7   r
   r3   r8   r9   r   r   r;   r   r   r   r<   r4   r=   r[   s         r   r   z$AsyncRawMlClient.list_model_versions  s    $ ..;;CC&r*+95+ D 
 
	
	ti++1c1/"9 ) 0 ))%HH&^^-N 9#8#8$yGXGXBY`noo%
   	ty'<'<d9K\K\F]dmdrdrss	ts4   9DCDAC DC -,D?DD)r   r   r   r   r   r8   r   r   r   r   r:   r   rB   rT   r   r   r   rz   r   rV   r\   ra   r   re   rm   rs   r|   r   r   r   r   r   r   r   ,  sv   .*< . 26jn-p //#.-pHNXfHg-p	6;;y1	2-pd CG0404,0FJ04(,(,&*$(;?bp __%>?bp  -	bp
  -bp __S)bp oofkk#vzz/&BCbp -bp %bp %bp s#bp __S!bp  8bp 
9	%bpJ NR)p)p+1??>+J)p	9	%)pX NR!p!p+1??>+J!p	4	 !pN CG0404,0FJ04(,(,&*$(;?dpdp __%>?	dp
  -dp  -dp __S)dp oofkk#vzz/&BCdp -dp %dp %dp s#dp __S!dp  8dp 
9	%dpV 04;?4p4p 	4p
 ,4p  84p 
4	 4pt ,0;?3p3p OOC(	3p
  83p 
4	 3pr 37;?;p;p !//$/	;p
  8;p 
4	 ;p| NR$p$p+1??>+J$p	6	7$pr   r   ) r8   json.decoderr   core.api_errorr   core.client_wrapperr   r   core.http_responser   r	   core.jsonable_encoderr
   core.request_optionsr   core.unchecked_base_modelr   errors.internal_server_errorr   types.ml_backendr   #types.create_ml_request_auth_methodr   %types.list_model_versions_ml_responser   #types.update_ml_request_auth_methodr   r9   rz   rT   r   r   r   r   r   <module>r      sc     ( % G @ 4 1 6 > ( J N J v{{6::s#Sp SplWp Wpr   