
    gi,                       d dl Z ddlmZ d dlZddlmZ ddlmZ ddl	m
Z
 ddlmZ 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/m0Z0 ddl1m2Z2 ddl3m4Z4 ddl5m6Z6 ddlm7Z7  e jp                  e jr                  d      Z: G d  d!      Z; G d" d#      Z<y)$    N   )SyncClientWrapper)DatasetValidationStatus)RequestOptions   )DatasetsListResponse)serialize_datetime)construct_type)BadRequestError)UnauthorizedError)ForbiddenError)NotFoundError)UnprocessableEntityError)TooManyRequestsError)InvalidTokenError)ClientClosedRequestError)InternalServerError)NotImplementedError)ServiceUnavailableError)GatewayTimeoutError)JSONDecodeError)ApiError)DatasetType)core)DatasetsCreateResponse)DatasetsGetUsageResponse)DatasetsGetResponse)jsonable_encoder)AsyncClientWrapper.c                      e Zd ZdefdZdddddddddej                  e   dej                  ej                     dej                  ej                     dej                  e
   d	ej                  e
   d
ej                  e   dej                  e   defdZdddddddedd	dededej$                  dej                  e   dej                  e   dej                  ej(                  eej*                  e   f      dej                  ej(                  eej*                  e   f      dej                  e   dej                  e   dej                  e   dej                  ej$                     dej                  e   defdZdddej                  e   defdZdddedej                  e   defdZdddedej                  e   dej8                  eej                  ej:                     f   fdZy) DatasetsClientclient_wrapperc                    || _         y N_client_wrapperselfr"   s     K/var/www/openai/venv/lib/python3.12/site-packages/cohere/datasets/client.py__init__zDatasetsClient.__init__&   
    -    Ndataset_typebeforeafterlimitoffsetvalidation_statusrequest_optionsr.   r/   r0   r1   r2   r3   r4   returnc                X   | j                   j                  j                  dd||t        |      nd|t        |      nd|||d|      }	 d|j                  cxk  rdk  r:n n7t        j                  t        t        t        |j                                     S |j                  d	k(  rvt        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  d
k(  rvt        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt!        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt#        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt%        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt'        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt)        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt+        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt-        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt/        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                         }	t3        |j                  |	      # t0        $ r" t3        |j                  |j4                        w xY w)a*  
        List datasets that have been created.

        Parameters
        ----------
        dataset_type : typing.Optional[str]
            optional filter by dataset type

        before : typing.Optional[dt.datetime]
            optional filter before a date

        after : typing.Optional[dt.datetime]
            optional filter after a date

        limit : typing.Optional[float]
            optional limit to number of results

        offset : typing.Optional[float]
            optional offset to start of results

        validation_status : typing.Optional[DatasetValidationStatus]
            optional filter by validation status

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

        Returns
        -------
        DatasetsListResponse
            A successful response.

        Examples
        --------
        from cohere import Client

        client = Client(
            client_name="YOUR_CLIENT_NAME",
            token="YOUR_TOKEN",
        )
        client.datasets.list()
        v1/datasetsGETNdatasetTyper/   r0   r1   r2   validationStatusmethodparamsr4      ,  type_object_                        status_codebodyr&   httpx_clientrequestr	   rQ   typingcastr   r
   jsonr   OptionalAnyr   r   r   r   r   r   r   r   r   r   r   r   r   text
r(   r.   r/   r0   r1   r2   r3   r4   	_response_response_jsons
             r)   listzDatasetsClient.list)   s7   h ((55==+8>8J,V4PT6;6G+E2T $5 , > 
	C	Si++1c1{{("2 ) 0  $$+%KK

3&"(//&**"=$-NN$4  $$+'KK

3&"(//&**"=$-NN$4  $$+$KK

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

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

3&"(//&**"=$-NN$4  $$+*KK

3&"(//&**"=$-NN$4  $$+'KK

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

3&"(//&**"=$-NN$4  $$+)KK

3&"(//&**"=$-NN$4  $$+)KK

3&"(//&**"=$-NN$4  $$+-KK

3&"(//&**"=$-NN$4  $$+)KK

3&"(//&**"=$-NN$4  '^^-N 9#8#8~NN  	Sy'<'<9>>RR	Ss   A[> Y[> >+\)	keep_original_fileskip_malformed_inputkeep_fieldsoptional_fieldstext_separatorcsv_delimiterdry_run	eval_datar4   nametypedatara   rb   rc   rd   re   rf   rg   rh   c                >   | j                   j                  j                  dd||||||||	|
d	i ||d|t              }	 d|j                  cxk  rdk  r:n n7t        j                  t        t        t        |j                                     S |j                  d	k(  rvt        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  d
k(  rvt        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt!        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt#        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt%        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt'        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt)        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt+        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt-        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt/        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                         }t3        |j                  |      # t0        $ r" t3        |j                  |j4                        w xY w)ad  
        Create a dataset by uploading a file. See ['Dataset Creation'](https://docs.cohere.com/docs/datasets#dataset-creation) for more information.

        Parameters
        ----------
        name : str
            The name of the uploaded dataset.

        type : DatasetType
            The dataset type, which is used to validate the data. Valid types are `embed-input`, `reranker-finetune-input`, `single-label-classification-finetune-input`, `chat-finetune-input`, and `multi-label-classification-finetune-input`.

        data : core.File
            See core.File for more documentation

        keep_original_file : typing.Optional[bool]
            Indicates if the original file should be stored.

        skip_malformed_input : typing.Optional[bool]
            Indicates whether rows with malformed input should be dropped (instead of failing the validation check). Dropped rows will be returned in the warnings field.

        keep_fields : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            List of names of fields that will be persisted in the Dataset. By default the Dataset will retain only the required fields indicated in the [schema for the corresponding Dataset type](https://docs.cohere.com/docs/datasets#dataset-types). For example, datasets of type `embed-input` will drop all fields other than the required `text` field. If any of the fields in `keep_fields` are missing from the uploaded file, Dataset validation will fail.

        optional_fields : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            List of names of fields that will be persisted in the Dataset. By default the Dataset will retain only the required fields indicated in the [schema for the corresponding Dataset type](https://docs.cohere.com/docs/datasets#dataset-types). For example, Datasets of type `embed-input` will drop all fields other than the required `text` field. If any of the fields in `optional_fields` are missing from the uploaded file, Dataset validation will pass.

        text_separator : typing.Optional[str]
            Raw .txt uploads will be split into entries using the text_separator value.

        csv_delimiter : typing.Optional[str]
            The delimiter used for .csv uploads.

        dry_run : typing.Optional[bool]
            flag to enable dry_run mode

        eval_data : typing.Optional[core.File]
            See core.File for more documentation

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

        Returns
        -------
        DatasetsCreateResponse
            A successful response.

        Examples
        --------
        from cohere import Client

        client = Client(
            client_name="YOUR_CLIENT_NAME",
            token="YOUR_TOKEN",
        )
        client.datasets.create(
            name="name",
            type="embed-input",
        )
        r7   POST	ri   rj   ra   rb   rc   rd   re   rf   rg   rk   rh   r=   r>   rk   filesr4   omitr?   r@   rA   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   r&   rT   rU   OMITrQ   rV   rW   r   r
   rX   r   rY   rZ   r   r   r   r   r   r   r   r   r   r   r   r   r   r[   r(   ri   rj   rk   ra   rb   rc   rd   re   rf   rg   rh   r4   r]   r^   s                  r)   createzDatasetsClient.create   s8   V ((55==&8(<*#2"0!."
 & ,) > 
	,C	Si++1c1{{*"4 ) 0  $$+%KK

3&"(//&**"=$-NN$4  $$+'KK

3&"(//&**"=$-NN$4  $$+$KK

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

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

3&"(//&**"=$-NN$4  $$+*KK

3&"(//&**"=$-NN$4  $$+'KK

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

3&"(//&**"=$-NN$4  $$+)KK

3&"(//&**"=$-NN$4  $$+)KK

3&"(//&**"=$-NN$4  $$+-KK

3&"(//&**"=$-NN$4  $$+)KK

3&"(//&**"=$-NN$4  '^^-N 9#8#8~NN  	Sy'<'<9>>RR	Ss   A[1 Y[1 1+\r4   c          
         | j                   j                  j                  dd|      }	 d|j                  cxk  rdk  r:n n7t	        j
                  t        t        t        |j                                     S |j                  dk(  rvt        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  dk(  rvt        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  d	k(  rvt        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  d
k(  rvt        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  dk(  rvt        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  dk(  rvt!        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  dk(  rvt#        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  dk(  rvt%        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  dk(  rvt'        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  dk(  rvt)        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  dk(  rvt+        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  dk(  rvt-        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                         }t1        |j                  |      # t.        $ r" t1        |j                  |j2                        w xY w)a[  
        View the dataset storage usage for your Organization. Each Organization can have up to 10GB of storage across all their users.

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

        Returns
        -------
        DatasetsGetUsageResponse
            A successful response.

        Examples
        --------
        from cohere import Client

        client = Client(
            client_name="YOUR_CLIENT_NAME",
            token="YOUR_TOKEN",
        )
        client.datasets.get_usage()
        v1/datasets/usager8   r=   r4   r?   r@   rA   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   r&   rT   rU   rQ   rV   rW   r   r
   rX   r   rY   rZ   r   r   r   r   r   r   r   r   r   r   r   r   r   r[   r(   r4   r]   r^   s       r)   	get_usagezDatasetsClient.get_usage  s   0 ((55==+ > 
	
C	Si++1c1{{,"6 ) 0  $$+%KK

3&"(//&**"=$-NN$4  $$+'KK

3&"(//&**"=$-NN$4  $$+$KK

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

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

3&"(//&**"=$-NN$4  $$+*KK

3&"(//&**"=$-NN$4  $$+'KK

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

3&"(//&**"=$-NN$4  $$+)KK

3&"(//&**"=$-NN$4  $$+)KK

3&"(//&**"=$-NN$4  $$+-KK

3&"(//&**"=$-NN$4  $$+)KK

3&"(//&**"=$-NN$4  '^^-N 9#8#8~NN  	Sy'<'<9>>RR	Ss   A[ 9Y[ +\idc          
      ,   | j                   j                  j                  dt        |       d|      }	 d|j                  cxk  rdk  r:n n7t        j                  t        t        t        |j                                     S |j                  dk(  rvt        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  d	k(  rvt        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  d
k(  rvt        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt!        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt#        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt%        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt'        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt)        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt+        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt-        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt/        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                         }t3        |j                  |      # t0        $ r" t3        |j                  |j4                        w xY w)ai  
        Retrieve a dataset by ID. See ['Datasets'](https://docs.cohere.com/docs/datasets) for more information.

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

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

        Returns
        -------
        DatasetsGetResponse
            A successful response.

        Examples
        --------
        from cohere import Client

        client = Client(
            client_name="YOUR_CLIENT_NAME",
            token="YOUR_TOKEN",
        )
        client.datasets.get(
            id="id",
        )
        v1/datasets/r8   rz   r?   r@   rA   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   r&   rT   rU   r   rQ   rV   rW   r   r
   rX   r   rY   rZ   r   r   r   r   r   r   r   r   r   r   r   r   r   r[   r(   r~   r4   r]   r^   s        r)   getzDatasetsClient.getz  s   8 ((55==+B/01+ > 
	
C	Si++1c1{{'"1 ) 0  $$+%KK

3&"(//&**"=$-NN$4  $$+'KK

3&"(//&**"=$-NN$4  $$+$KK

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

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

3&"(//&**"=$-NN$4  $$+*KK

3&"(//&**"=$-NN$4  $$+'KK

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

3&"(//&**"=$-NN$4  $$+)KK

3&"(//&**"=$-NN$4  $$+)KK

3&"(//&**"=$-NN$4  $$+-KK

3&"(//&**"=$-NN$4  $$+)KK

3&"(//&**"=$-NN$4  '^^-N 9#8#8~NN  	Sy'<'<9>>RR	Ss   A[( Y[( (+\c          
         | j                   j                  j                  dt        |       d|      }	 d|j                  cxk  rdk  rn nt        j                  t
        j                  t        t
        j                  t
        j                     f   t        t
        j                  t        t
        j                  t
        j                     f   |j                                     S |j                  dk(  rvt        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  d	k(  rvt        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  d
k(  rvt!        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt#        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt%        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt'        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt)        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt+        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt-        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt/        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt1        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                         }t5        |j                  |      # t2        $ r" t5        |j                  |j6                        w xY w)a  
        Delete a dataset by ID. Datasets are automatically deleted after 30 days, but they can also be deleted manually.

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

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

        Returns
        -------
        typing.Dict[str, typing.Optional[typing.Any]]
            A successful response.

        Examples
        --------
        from cohere import Client

        client = Client(
            client_name="YOUR_CLIENT_NAME",
            token="YOUR_TOKEN",
        )
        client.datasets.delete(
            id="id",
        )
        r   DELETErz   r?   r@   rA   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   r&   rT   rU   r   rQ   rV   rW   DictstrrY   rZ   r
   rX   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r[   r   s        r)   deletezDatasetsClient.delete!  sF   < ((55==+B/01+ > 
	
C	Si++1c1{{KKV__VZZ%@ @A"$kk#vvzz/J*JK ) 0  $$+%KK

3&"(//&**"=$-NN$4  $$+'KK

3&"(//&**"=$-NN$4  $$+$KK

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

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

3&"(//&**"=$-NN$4  $$+*KK

3&"(//&**"=$-NN$4  $$+'KK

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

3&"(//&**"=$-NN$4  $$+)KK

3&"(//&**"=$-NN$4  $$+)KK

3&"(//&**"=$-NN$4  $$+-KK

3&"(//&**"=$-NN$4  $$+)KK

3&"(//&**"=$-NN$4  '^^-N 9#8#8~NN  	Sy'<'<9>>RR	Ss   B2] )Y] +]7)__name__
__module____qualname__r   r*   rV   rY   r   dtdatetimefloatr   r   r   r_   rt   r   r   FileboolUnionSequencer   rv   r   r}   r   r   r   rZ   r    r,   r)   r!   r!   %   s   .*; . .2/3.2(,)-FJ;?EO ooc*EO ,	EO
 r{{+EO u%EO &EO "??+BCEO  8EO 
EOZ 596:PTTX/3.2)-04;?eO eO 	eO
 iieO #OOD1eO %ood3eO __V\\#vs7K2K%LMeO  c6??3;O6O)PQeO ,eO s+eO &eO ??499-eO  8eO 
 eON OS aOFOON,K aOWo aOF RV eOc eOv~/N eOZm eOP NRgOgO+1??>+JgO	S&//&**55	6gOr,   r!   c                      e Zd ZdefdZdddddddddej                  e   dej                  ej                     dej                  ej                     dej                  e
   d	ej                  e
   d
ej                  e   dej                  e   defdZdddddddedd	dededej$                  dej                  e   dej                  e   dej                  ej(                  eej*                  e   f      dej                  ej(                  eej*                  e   f      dej                  e   dej                  e   dej                  e   dej                  ej$                     dej                  e   defdZdddej                  e   defdZdddedej                  e   defdZdddedej                  e   dej8                  eej                  ej:                     f   fdZy) AsyncDatasetsClientr"   c                    || _         y r$   r%   r'   s     r)   r*   zAsyncDatasetsClient.__init__  r+   r,   Nr-   r.   r/   r0   r1   r2   r3   r4   r5   c                v  K   | j                   j                  j                  dd||t        |      nd|t        |      nd|||d|       d{   }	 d|j                  cxk  rdk  r:n n7t        j                  t        t        t        |j                                     S |j                  d	k(  rvt        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  d
k(  rvt        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt!        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt#        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt%        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt'        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt)        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt+        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt-        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt/        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                         }	t3        |j                  |	      7 # t0        $ r" t3        |j                  |j4                        w xY ww)a  
        List datasets that have been created.

        Parameters
        ----------
        dataset_type : typing.Optional[str]
            optional filter by dataset type

        before : typing.Optional[dt.datetime]
            optional filter before a date

        after : typing.Optional[dt.datetime]
            optional filter after a date

        limit : typing.Optional[float]
            optional limit to number of results

        offset : typing.Optional[float]
            optional offset to start of results

        validation_status : typing.Optional[DatasetValidationStatus]
            optional filter by validation status

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

        Returns
        -------
        DatasetsListResponse
            A successful response.

        Examples
        --------
        import asyncio

        from cohere import AsyncClient

        client = AsyncClient(
            client_name="YOUR_CLIENT_NAME",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.datasets.list()


        asyncio.run(main())
        r7   r8   Nr9   r<   r?   r@   rA   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rS   r\   s
             r)   r_   zAsyncDatasetsClient.list  sG    x ..;;CC+8>8J,V4PT6;6G+E2T $5 , D 
 
	C	Si++1c1{{("2 ) 0  $$+%KK

3&"(//&**"=$-NN$4  $$+'KK

3&"(//&**"=$-NN$4  $$+$KK

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

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

3&"(//&**"=$-NN$4  $$+*KK

3&"(//&**"=$-NN$4  $$+'KK

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

3&"(//&**"=$-NN$4  $$+)KK

3&"(//&**"=$-NN$4  $$+)KK

3&"(//&**"=$-NN$4  $$+-KK

3&"(//&**"=$-NN$4  $$+)KK

3&"(//&**"=$-NN$4  '^^-N 9#8#8~NNc
^  	Sy'<'<9>>RR	Ss8   A\9\\9A\ $\9%Y\ 1\9+\66\9r`   ri   rj   rk   ra   rb   rc   rd   re   rf   rg   rh   c                \  K   | j                   j                  j                  dd||||||||	|
d	i ||d|t               d{   }	 d|j                  cxk  rdk  r:n n7t        j                  t        t        t        |j                         	            S |j                  d
k(  rvt        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                         	                  |j                  dk(  rvt        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                         	                  |j                  dk(  rvt        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                         	                  |j                  dk(  rvt        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                         	                  |j                  dk(  rvt!        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                         	                  |j                  dk(  rvt#        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                         	                  |j                  dk(  rvt%        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                         	                  |j                  dk(  rvt'        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                         	                  |j                  dk(  rvt)        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                         	                  |j                  dk(  rvt+        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                         	                  |j                  dk(  rvt-        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                         	                  |j                  dk(  rvt/        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                         	                  |j                         }t3        |j                  |      7 # t0        $ r" t3        |j                  |j4                        w xY ww)a  
        Create a dataset by uploading a file. See ['Dataset Creation'](https://docs.cohere.com/docs/datasets#dataset-creation) for more information.

        Parameters
        ----------
        name : str
            The name of the uploaded dataset.

        type : DatasetType
            The dataset type, which is used to validate the data. Valid types are `embed-input`, `reranker-finetune-input`, `single-label-classification-finetune-input`, `chat-finetune-input`, and `multi-label-classification-finetune-input`.

        data : core.File
            See core.File for more documentation

        keep_original_file : typing.Optional[bool]
            Indicates if the original file should be stored.

        skip_malformed_input : typing.Optional[bool]
            Indicates whether rows with malformed input should be dropped (instead of failing the validation check). Dropped rows will be returned in the warnings field.

        keep_fields : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            List of names of fields that will be persisted in the Dataset. By default the Dataset will retain only the required fields indicated in the [schema for the corresponding Dataset type](https://docs.cohere.com/docs/datasets#dataset-types). For example, datasets of type `embed-input` will drop all fields other than the required `text` field. If any of the fields in `keep_fields` are missing from the uploaded file, Dataset validation will fail.

        optional_fields : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            List of names of fields that will be persisted in the Dataset. By default the Dataset will retain only the required fields indicated in the [schema for the corresponding Dataset type](https://docs.cohere.com/docs/datasets#dataset-types). For example, Datasets of type `embed-input` will drop all fields other than the required `text` field. If any of the fields in `optional_fields` are missing from the uploaded file, Dataset validation will pass.

        text_separator : typing.Optional[str]
            Raw .txt uploads will be split into entries using the text_separator value.

        csv_delimiter : typing.Optional[str]
            The delimiter used for .csv uploads.

        dry_run : typing.Optional[bool]
            flag to enable dry_run mode

        eval_data : typing.Optional[core.File]
            See core.File for more documentation

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

        Returns
        -------
        DatasetsCreateResponse
            A successful response.

        Examples
        --------
        import asyncio

        from cohere import AsyncClient

        client = AsyncClient(
            client_name="YOUR_CLIENT_NAME",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.datasets.create(
                name="name",
                type="embed-input",
            )


        asyncio.run(main())
        r7   rm   rn   ro   rp   Nr?   r@   rA   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rs   ru   s                  r)   rv   zAsyncDatasetsClient.create  sH    f ..;;CC&8(<*#2"0!."
 & ,) D 
 
	,C	Si++1c1{{*"4 ) 0  $$+%KK

3&"(//&**"=$-NN$4  $$+'KK

3&"(//&**"=$-NN$4  $$+$KK

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

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

3&"(//&**"=$-NN$4  $$+*KK

3&"(//&**"=$-NN$4  $$+'KK

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

3&"(//&**"=$-NN$4  $$+)KK

3&"(//&**"=$-NN$4  $$+)KK

3&"(//&**"=$-NN$4  $$+-KK

3&"(//&**"=$-NN$4  $$+)KK

3&"(//&**"=$-NN$4  '^^-N 9#8#8~NNu
p  	Sy'<'<9>>RR	Ss8   A\,[;\,	A[> \,Y[> $\,>+\))\,rw   c          
      2  K   | j                   j                  j                  dd|       d{   }	 d|j                  cxk  rdk  r:n n7t	        j
                  t        t        t        |j                                     S |j                  dk(  rvt        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  d	k(  rvt        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  d
k(  rvt        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  dk(  rvt        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  dk(  rvt        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  dk(  rvt!        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  dk(  rvt#        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  dk(  rvt%        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  dk(  rvt'        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  dk(  rvt)        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  dk(  rvt+        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                  dk(  rvt-        t	        j
                  t        j                  t        j                     t        t        j                  t        j                     |j                                           |j                         }t1        |j                  |      7 # t.        $ r" t1        |j                  |j2                        w xY ww)a  
        View the dataset storage usage for your Organization. Each Organization can have up to 10GB of storage across all their users.

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

        Returns
        -------
        DatasetsGetUsageResponse
            A successful response.

        Examples
        --------
        import asyncio

        from cohere import AsyncClient

        client = AsyncClient(
            client_name="YOUR_CLIENT_NAME",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.datasets.get_usage()


        asyncio.run(main())
        ry   r8   rz   Nr?   r@   rA   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   r{   r|   s       r)   r}   zAsyncDatasetsClient.get_usage  s    @ ..;;CC+ D 
 
	
C	Si++1c1{{,"6 ) 0  $$+%KK

3&"(//&**"=$-NN$4  $$+'KK

3&"(//&**"=$-NN$4  $$+$KK

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

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

3&"(//&**"=$-NN$4  $$+*KK

3&"(//&**"=$-NN$4  $$+'KK

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

3&"(//&**"=$-NN$4  $$+)KK

3&"(//&**"=$-NN$4  $$+)KK

3&"(//&**"=$-NN$4  $$+-KK

3&"(//&**"=$-NN$4  $$+)KK

3&"(//&**"=$-NN$4  '^^-N 9#8#8~NNS
N  	Sy'<'<9>>RR	Ss4   ,\[&\A[) \Y[) \)+\\r~   c          
      J  K   | j                   j                  j                  dt        |       d|       d{   }	 d|j                  cxk  rdk  r:n n7t        j                  t        t        t        |j                                     S |j                  dk(  rvt        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  d	k(  rvt        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  d
k(  rvt        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt!        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt#        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt%        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt'        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt)        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt+        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt-        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt/        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                         }t3        |j                  |      7 # t0        $ r" t3        |j                  |j4                        w xY ww)a  
        Retrieve a dataset by ID. See ['Datasets'](https://docs.cohere.com/docs/datasets) for more information.

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

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

        Returns
        -------
        DatasetsGetResponse
            A successful response.

        Examples
        --------
        import asyncio

        from cohere import AsyncClient

        client = AsyncClient(
            client_name="YOUR_CLIENT_NAME",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.datasets.get(
                id="id",
            )


        asyncio.run(main())
        r   r8   rz   Nr?   r@   rA   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   r   r   s        r)   r   zAsyncDatasetsClient.get8  s!    H ..;;CC+B/01+ D 
 
	
C	Si++1c1{{'"1 ) 0  $$+%KK

3&"(//&**"=$-NN$4  $$+'KK

3&"(//&**"=$-NN$4  $$+$KK

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

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

3&"(//&**"=$-NN$4  $$+*KK

3&"(//&**"=$-NN$4  $$+'KK

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

3&"(//&**"=$-NN$4  $$+)KK

3&"(//&**"=$-NN$4  $$+)KK

3&"(//&**"=$-NN$4  $$+-KK

3&"(//&**"=$-NN$4  $$+)KK

3&"(//&**"=$-NN$4  '^^-N 9#8#8~NNS
N  	Sy'<'<9>>RR	Ss5   8\#[2\# A[5 \#Y[5 \#5+\  \#c          
        K   | j                   j                  j                  dt        |       d|       d{   }	 d|j                  cxk  rdk  rn nt        j                  t
        j                  t        t
        j                  t
        j                     f   t        t
        j                  t        t
        j                  t
        j                     f   |j                                     S |j                  dk(  rvt        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  d	k(  rvt        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  d
k(  rvt        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt!        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt#        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt%        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt'        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt)        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt+        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt-        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt/        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                  dk(  rvt1        t        j                  t
        j                  t
        j                     t        t
        j                  t
        j                     |j                                           |j                         }t5        |j                  |      7 # t2        $ r" t5        |j                  |j6                        w xY ww)a  
        Delete a dataset by ID. Datasets are automatically deleted after 30 days, but they can also be deleted manually.

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

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

        Returns
        -------
        typing.Dict[str, typing.Optional[typing.Any]]
            A successful response.

        Examples
        --------
        import asyncio

        from cohere import AsyncClient

        client = AsyncClient(
            client_name="YOUR_CLIENT_NAME",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.datasets.delete(
                id="id",
            )


        asyncio.run(main())
        r   r   rz   Nr?   r@   rA   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   r   r   s        r)   r   zAsyncDatasetsClient.delete  sW    L ..;;CC+B/01+ D 
 
	
C	Si++1c1{{KKV__VZZ%@ @A"$kk#vvzz/J*JK ) 0  $$+%KK

3&"(//&**"=$-NN$4  $$+'KK

3&"(//&**"=$-NN$4  $$+$KK

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

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

3&"(//&**"=$-NN$4  $$+*KK

3&"(//&**"=$-NN$4  $$+'KK

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

3&"(//&**"=$-NN$4  $$+)KK

3&"(//&**"=$-NN$4  $$+)KK

3&"(//&**"=$-NN$4  $$+-KK

3&"(//&**"=$-NN$4  $$+)KK

3&"(//&**"=$-NN$4  '^^-N 9#8#8~NNS
N  	Sy'<'<9>>RR	Ss5   8^]^ B2] 2^3Y] ?^+^^)r   r   r   r   r*   rV   rY   r   r   r   r   r   r   r   r_   rt   r   r   r   r   r   r   r   rv   r   r}   r   r   r   rZ   r   r   r,   r)   r   r     s   .*< . .2/3.2(,)-FJ;?MO ooc*MO ,	MO
 r{{+MO u%MO &MO "??+BCMO  8MO 
MOj 596:PTTX/3.2)-04;?mO mO 	mO
 iimO #OOD1mO %ood3mO __V\\#vs7K2K%LMmO  c6??3;O6O)PQmO ,mO s+mO &mO ??499-mO  8mO 
 mO^ UY iO&//.2Q iO]u iOV X\ mOC mOV__^5T mO`s mO` NRoOoO+1??>+JoO	S&//&**55	6oOr,   r   )=rV   core.client_wrapperr   r   r   types.dataset_validation_statusr   core.request_optionsr   types.datasets_list_responser   core.datetime_utilsr	   core.unchecked_base_modelr
   errors.bad_request_errorr   errors.unauthorized_errorr   errors.forbidden_errorr   errors.not_found_errorr   !errors.unprocessable_entity_errorr   errors.too_many_requests_errorr   errors.invalid_token_errorr   "errors.client_closed_request_errorr   errors.internal_server_errorr   errors.not_implemented_errorr    errors.service_unavailable_errorr   errors.gateway_timeout_errorr   json.decoderr   core.api_errorr   types.dataset_typer    r   types.datasets_create_responser   !types.datasets_get_usage_responser   types.datasets_get_responser   core.jsonable_encoderr   r   rW   rZ   rt   r!   r   r   r,   r)   <module>r      s     3  E 1 > 4 6 6 9 3 2 H A : I > > F > ( % ,  B G < 4 4 v{{6::s#cO cOLKO KOr,   