
    iW                       d dl mZ d dlmZ d dlmZ d dlZddlmZ ddl	m
Z
mZ ddlmZmZmZmZmZmZmZ dd	lmZmZ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!m"Z" ddl#m$Z$ ddl%m&Z&m'Z' ddl(m)Z) ddgZ* G d de          Z+ G d de          Z, G d d          Z- G d d          Z. G d d          Z/ G d d          Z0dS )    )annotations)Optional)LiteralN   )_legacy_response)batch_list_paramsbatch_create_params)BodyOmitQueryHeadersNotGivenomit	not_given)path_templatemaybe_transformasync_maybe_transform)cached_property)SyncAPIResourceAsyncAPIResource)to_streamed_response_wrapper"async_to_streamed_response_wrapper)SyncCursorPageAsyncCursorPage)Batch)AsyncPaginatormake_request_options)MetadataBatchesAsyncBatchesc                      e Zd ZdZed(d            Zed)d            Zeedddedd*dZ	dddedd+dZ
eeddded d,d&Zdddedd+d'ZdS )-r   ;Create large batches of API requests to run asynchronously.returnBatchesWithRawResponsec                     t          |           S a  
        This property can be used as a prefix for any HTTP method call to return
        the raw response object instead of the parsed content.

        For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
        )r$   selfs    _/home/piyush/.hermes/hermes-agent/venv/lib/python3.11/site-packages/openai/resources/batches.pywith_raw_responsezBatches.with_raw_response   s     &d+++    BatchesWithStreamingResponsec                     t          |           S z
        An alternative to `.with_raw_response` that doesn't eagerly read the response body.

        For more information, see https://www.github.com/openai/openai-python#with_streaming_response
        )r,   r'   s    r)   with_streaming_responsezBatches.with_streaming_response&   s     ,D111r+   Nmetadataoutput_expires_afterextra_headersextra_query
extra_bodytimeoutcompletion_windowLiteral['24h']endpointLiteral['/v1/responses', '/v1/chat/completions', '/v1/embeddings', '/v1/completions', '/v1/moderations', '/v1/images/generations', '/v1/images/edits', '/v1/videos']input_file_idstrr1   Optional[Metadata] | Omitr2   -batch_create_params.OutputExpiresAfter | Omitr3   Headers | Noner4   Query | Noner5   Body | Noner6   'float | httpx.Timeout | None | NotGivenr   c       	            |                      dt          |||||dt          j                  t	          ||||	ddi          t
                    S )  
        Creates and executes a batch from an uploaded file of requests

        Args:
          completion_window: The time frame within which the batch should be processed. Currently only `24h`
              is supported.

          endpoint: The endpoint to be used for all requests in the batch. Currently
              `/v1/responses`, `/v1/chat/completions`, `/v1/embeddings`, `/v1/completions`,
              `/v1/moderations`, `/v1/images/generations`, `/v1/images/edits`, and
              `/v1/videos` are supported. Note that `/v1/embeddings` batches are also
              restricted to a maximum of 50,000 embedding inputs across all requests in the
              batch.

          input_file_id: The ID of an uploaded file that contains requests for the new batch.

              See [upload file](https://platform.openai.com/docs/api-reference/files/create)
              for how to upload a file.

              Your input file must be formatted as a
              [JSONL file](https://platform.openai.com/docs/api-reference/batch/request-input),
              and must be uploaded with the purpose `batch`. The file can contain up to 50,000
              requests, and can be up to 200 MB in size.

          metadata: Set of 16 key-value pairs that can be attached to an object. This can be useful
              for storing additional information about the object in a structured format, and
              querying for objects via API or the dashboard.

              Keys are strings with a maximum length of 64 characters. Values are strings with
              a maximum length of 512 characters.

          output_expires_after: The expiration policy for the output and/or error file that are generated for a
              batch.

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        /batchesr7   r9   r;   r1   r2   bearer_authTr3   r4   r5   r6   securitybodyoptionscast_to)_postr   r	   BatchCreateParamsr   r   
r(   r7   r9   r;   r1   r2   r3   r4   r5   r6   s
             r)   createzBatches.create/   s~    D zz ): (%2 (,@  $5	 	 )+'%'.   '  
 
 	
r+   r3   r4   r5   r6   batch_idc                   |st          d|          |                     t          d|          t          ||||ddi          t                    S )F  
        Retrieves a batch.

        Args:
          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        7Expected a non-empty value for `batch_id` but received /batches/{batch_id}rS   rG   TrH   rL   rM   
ValueError_getr   r   r   r(   rS   r3   r4   r5   r6   s         r)   retrievezBatches.retrieve   s|    .  	ecW_ccdddyy/(CCC(+'%'.     

 

 
	
r+   afterlimitr3   r4   r5   r6   r`   
str | Omitra   
int | OmitSyncCursorPage[Batch]c                   |                      dt          t                   t          ||||t	          ||dt
          j                  ddi          t                    S a,  List your organization's batches.

        Args:
          after: A cursor for use in pagination.

        `after` is an object ID that defines your place
              in the list. For instance, if you make a list request and receive 100 objects,
              ending with obj_foo, your subsequent call can include after=obj_foo in order to
              fetch the next page of the list.

          limit: A limit on the number of objects to be returned. Limit can range between 1 and
              100, and the default is 20.

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        rE   )r`   ra   rG   T)r3   r4   r5   r6   queryrI   )pagerL   model)_get_api_listr   r   r   r   r   BatchListParamsr(   r`   ra   r3   r4   r5   r6   s          r)   listzBatches.list   s    B !!&(+'%%!&!&  &5  (.   # " 
 
 	
r+   c                   |st          d|          |                     t          d|          t          ||||ddi          t                    S )
  Cancels an in-progress batch.

        The batch will be in status `cancelling` for up to
        10 minutes, before changing to `cancelled`, where it will have partial results
        (if any) available in the output file.

        Args:
          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        rV   /batches/{batch_id}/cancelrX   rG   TrH   rY   r[   rN   r   r   r   r]   s         r)   cancelzBatches.cancel   s|    4  	ecW_ccdddzz6JJJ(+'%'.     

 

 
	
r+   )r#   r$   )r#   r,   r7   r8   r9   r:   r;   r<   r1   r=   r2   r>   r3   r?   r4   r@   r5   rA   r6   rB   r#   r   rS   r<   r3   r?   r4   r@   r5   rA   r6   rB   r#   r   )r`   rb   ra   rc   r3   r?   r4   r@   r5   rA   r6   rB   r#   rd   __name__
__module____qualname____doc__r   r*   r/   r   r   rQ   r^   rm   rr    r+   r)   r   r      s!       EE, , , _, 2 2 2 _2. /3NR )-$("&;D-V
 V
 V
 V
 V
 V
| )-$("&;D#
 #
 #
 #
 #
 #
P !  )-$("&;D3
 3
 3
 3
 3
 3
v )-$("&;D&
 &
 &
 &
 &
 &
 &
 &
r+   c                      e Zd ZdZed(d            Zed)d            Zeedddedd*dZ	dddedd+dZ
eeddded d,d&Zdddedd+d'ZdS )-r    r"   r#   AsyncBatchesWithRawResponsec                     t          |           S r&   )r|   r'   s    r)   r*   zAsyncBatches.with_raw_response  s     +4000r+   !AsyncBatchesWithStreamingResponsec                     t          |           S r.   )r~   r'   s    r)   r/   z$AsyncBatches.with_streaming_response  s     1666r+   Nr0   r7   r8   r9   r:   r;   r<   r1   r=   r2   r>   r3   r?   r4   r@   r5   rA   r6   rB   r   c       	           K   |                      dt          |||||dt          j                   d{V t	          ||||	ddi          t
                     d{V S )rD   rE   rF   NrG   TrH   rJ   )rN   r   r	   rO   r   r   rP   s
             r)   rQ   zAsyncBatches.create   s      D ZZ,): (%2 (,@  $5	 	 	 	 	 	 	 	 )+'%'.   '   
 
 
 
 
 
 
 
 	
r+   rR   rS   c                  K   |st          d|          |                     t          d|          t          ||||ddi          t                     d{V S )	rU   rV   rW   rX   rG   TrH   rY   NrZ   r]   s         r)   r^   zAsyncBatches.retrievex  s      .  	ecW_ccdddYY/(CCC(+'%'.     

 

 

 

 

 

 

 

 
	
r+   r_   r`   rb   ra   rc   -AsyncPaginator[Batch, AsyncCursorPage[Batch]]c                   |                      dt          t                   t          ||||t	          ||dt
          j                  ddi          t                    S rf   )rj   r   r   r   r   r   rk   rl   s          r)   rm   zAsyncBatches.list  s    B !! '(+'%%!&!&  &5  (.   # " 
 
 	
r+   c                  K   |st          d|          |                     t          d|          t          ||||ddi          t                     d{V S )	ro   rV   rp   rX   rG   TrH   rY   Nrq   r]   s         r)   rr   zAsyncBatches.cancel  s      4  	ecW_ccdddZZ6JJJ(+'%'.      

 

 

 

 

 

 

 

 
	
r+   )r#   r|   )r#   r~   rs   rt   )r`   rb   ra   rc   r3   r?   r4   r@   r5   rA   r6   rB   r#   r   ru   rz   r+   r)   r    r    
  s!       EE1 1 1 _1 7 7 7 _7. /3NR )-$("&;D-V
 V
 V
 V
 V
 V
| )-$("&;D#
 #
 #
 #
 #
 #
P !  )-$("&;D3
 3
 3
 3
 3
 3
v )-$("&;D&
 &
 &
 &
 &
 &
 &
 &
r+   c                      e Zd ZddZdS )r$   batchesr   r#   Nonec                   || _         t          j        |j                  | _        t          j        |j                  | _        t          j        |j                  | _        t          j        |j                  | _        d S N)_batchesr   to_raw_response_wrapperrQ   r^   rm   rr   r(   r   s     r)   __init__zBatchesWithRawResponse.__init__  sx    &>N
 
 )@
 
 %<L
 
	 '>N
 
r+   Nr   r   r#   r   rv   rw   rx   r   rz   r+   r)   r$   r$     (        
 
 
 
 
 
r+   r$   c                      e Zd ZddZdS )r|   r   r    r#   r   c                   || _         t          j        |j                  | _        t          j        |j                  | _        t          j        |j                  | _        t          j        |j                  | _        d S r   )r   r   async_to_raw_response_wrapperrQ   r^   rm   rr   r   s     r)   r   z$AsyncBatchesWithRawResponse.__init__  sx    &DN
 
 )F
 
 %BL
 
	 'DN
 
r+   Nr   r    r#   r   r   rz   r+   r)   r|   r|     r   r+   r|   c                      e Zd ZddZdS )r,   r   r   r#   r   c                    || _         t          |j                  | _        t          |j                  | _        t          |j                  | _        t          |j                  | _        d S r   )r   r   rQ   r^   rm   rr   r   s     r)   r   z%BatchesWithStreamingResponse.__init__   sl    2N
 
 5
 
 1L
 
	 3N
 
r+   Nr   r   rz   r+   r)   r,   r,     r   r+   r,   c                      e Zd ZddZdS )r~   r   r    r#   r   c                    || _         t          |j                  | _        t          |j                  | _        t          |j                  | _        t          |j                  | _        d S r   )r   r   rQ   r^   rm   rr   r   s     r)   r   z*AsyncBatchesWithStreamingResponse.__init__2  sl    8N
 
 ;
 
 7L
 
	 9N
 
r+   Nr   r   rz   r+   r)   r~   r~   1  r   r+   r~   )1
__future__r   typingr   typing_extensionsr   httpx r   typesr   r	   _typesr
   r   r   r   r   r   r   _utilsr   r   r   _compatr   	_resourcer   r   	_responser   r   
paginationr   r   types.batchr   _base_clientr   r   types.shared_params.metadatar   __all__r   r    r$   r|   r,   r~   rz   r+   r)   <module>r      su   # " " " " "       % % % % % %        : : : : : : : : J J J J J J J J J J J J J J J J J J J J J J J J J J J J % % % % % % 9 9 9 9 9 9 9 9 X X X X X X X X 8 8 8 8 8 8 8 8       ? ? ? ? ? ? ? ? 3 3 3 3 3 3n
%n
 n
 n
 n
 n
o n
 n
 n
bn
 n
 n
 n
 n
# n
 n
 n
b
 
 
 
 
 
 
 
$
 
 
 
 
 
 
 
$
 
 
 
 
 
 
 
$
 
 
 
 
 
 
 
 
 
r+   