
    gzL                    X   d dl mZ d dlmZ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 dd	l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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      Z,y)    )annotations)DictOptional)LiteralN   )_legacy_response)batch_list_paramsbatch_create_params)	NOT_GIVENBodyQueryHeadersNotGiven)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BatchesAsyncBatchesc                      e Zd Zedd       Zedd       Z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
y)r   c                    t        |       S a  
        This property can be used as a prefix for any HTTP method call to return the
        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
        )BatchesWithRawResponseselfs    M/var/www/openai/venv/lib/python3.12/site-packages/openai/resources/batches.pywith_raw_responsezBatches.with_raw_response   s     &d++    c                    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
        )BatchesWithStreamingResponser"   s    r$   with_streaming_responsezBatches.with_streaming_response)   s     ,D11r&   Nmetadataextra_headersextra_query
extra_bodytimeoutc          
         | j                  dt        ||||dt        j                        t	        ||||      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/chat/completions`, `/v1/embeddings`, and `/v1/completions` 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: Optional custom metadata for the 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completion_windowendpointinput_file_idr,   r-   r.   r/   r0   bodyoptionscast_to)_postr   r
   BatchCreateParamsr   r   	r#   r5   r6   r7   r,   r-   r.   r/   r0   s	            r$   createzBatches.create2   s\    \ zz ): (%2 (	 $55 )+Q[el   
 	
r&   r8   c          	     r    |st        d|      | j                  d| t        ||||      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/r8   r;   r<   
ValueError_getr   r   r#   batch_idr-   r.   r/   r0   s         r$   retrievezBatches.retrieveq   sT    . VW_Vbcddyyz"(+Q[el   
 	
r&   afterlimitr-   r.   r/   r0   c                   | j                  dt        t           t        ||||t	        ||dt
        j                              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
        r3   )rM   rN   )r-   r.   r/   r0   query)pager;   model)_get_api_listr   r   r   r   r	   BatchListParamsr#   rM   rN   r-   r.   r/   r0   s          r$   listzBatches.list   s_    B !!&(+'%%!&!& &55 ! " 
 	
r&   c          	     t    |st        d|      | j                  d| dt        ||||      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
        rC   rD   /cancelr8   rE   rG   r=   r   r   rI   s         r$   cancelzBatches.cancel   sV    4 VW_Vbcddzzz)(+Q[el   
 	
r&   )returnr!   )r]   r)   r5   zLiteral['24h']r6   zDLiteral['/v1/chat/completions', '/v1/embeddings', '/v1/completions']r7   strr,   z#Optional[Dict[str, str]] | NotGivenr-   Headers | Noner.   Query | Noner/   Body | Noner0   'float | httpx.Timeout | None | NotGivenr]   r   rJ   r_   r-   r`   r.   ra   r/   rb   r0   rc   r]   r   )rM   str | NotGivenrN   int | NotGivenr-   r`   r.   ra   r/   rb   r0   rc   r]   zSyncCursorPage[Batch]__name__
__module____qualname__r   r%   r*   r   r@   rK   rW   r\    r&   r$   r   r      s   , , 2 2 9B )-$("&;D=
 *=
 W	=

 =
 6=
 &=
 "=
  =
 9=
 
=
J )-$("&;D

 &
 "
  
 9
 

H !* ) )-$("&;D2
 2
 	2
 &2
 "2
  2
 92
 
2
t )-$("&;D"
"
 &"
 ""
  "
 9"
 
"
r&   c                      e Zd Zedd       Zedd       Z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
y)r   c                    t        |       S r    )AsyncBatchesWithRawResponser"   s    r$   r%   zAsyncBatches.with_raw_response   s     +400r&   c                    t        |       S r(   )!AsyncBatchesWithStreamingResponser"   s    r$   r*   z$AsyncBatches.with_streaming_response   s     166r&   Nr+   c          
        K   | j                  dt        ||||dt        j                         d{   t	        ||||      t
               d{   S 7 $7 w)r2   r3   r4   Nr8   r9   )r=   r   r
   r>   r   r   r?   s	            r$   r@   zAsyncBatches.create   su     \ ZZ,): (%2 (	 $55  )+Q[el    
 
 	

s!   /AA
AAAAr8   c          	        K   |st        d|      | j                  d| t        ||||      t               d{   S 7 w)rB   rC   rD   r8   rE   NrF   rI   s         r$   rK   zAsyncBatches.retrieve>  sb     . VW_VbcddYYz"(+Q[el   
 
 	
 
s   <AAArL   c                   | j                  dt        t           t        ||||t	        ||dt
        j                              t              S rP   )rT   r   r   r   r   r	   rU   rV   s          r$   rW   zAsyncBatches.list_  s_    B !! '(+'%%!&!& &55 ! " 
 	
r&   c          	        K   |st        d|      | j                  d| dt        ||||      t               d{   S 7 w)rY   rC   rD   rZ   r8   rE   Nr[   rI   s         r$   r\   zAsyncBatches.cancel  sd     4 VW_VbcddZZz)(+Q[el    
 
 	
 
s   =AA A)r]   rn   )r]   rp   r^   rd   )rM   re   rN   rf   r-   r`   r.   ra   r/   rb   r0   rc   r]   z-AsyncPaginator[Batch, AsyncCursorPage[Batch]]rg   rk   r&   r$   r   r      s   1 1 7 7 9B )-$("&;D=
 *=
 W	=

 =
 6=
 &=
 "=
  =
 9=
 
=
J )-$("&;D

 &
 "
  
 9
 

H !* ) )-$("&;D2
 2
 	2
 &2
 "2
  2
 92
 
72
t )-$("&;D"
"
 &"
 ""
  "
 9"
 
"
r&   c                      e Zd ZddZy)r!   c                2   || _         t        j                  |j                        | _        t        j                  |j                        | _        t        j                  |j
                        | _        t        j                  |j                        | _        y N)_batchesr   to_raw_response_wrapperr@   rK   rW   r\   r#   batchess     r$   __init__zBatchesWithRawResponse.__init__  su    &>>NN
 )@@
 %<<LL
	 '>>NN
r&   Nr{   r   r]   Nonerh   ri   rj   r|   rk   r&   r$   r!   r!         
r&   r!   c                      e Zd ZddZy)rn   c                2   || _         t        j                  |j                        | _        t        j                  |j                        | _        t        j                  |j
                        | _        t        j                  |j                        | _        y rw   )rx   r   async_to_raw_response_wrapperr@   rK   rW   r\   rz   s     r$   r|   z$AsyncBatchesWithRawResponse.__init__  su    &DDNN
 )FF
 %BBLL
	 'DDNN
r&   Nr{   r   r]   r~   r   rk   r&   r$   rn   rn     r   r&   rn   c                      e Zd ZddZy)r)   c                    || _         t        |j                        | _        t        |j                        | _        t        |j                        | _        t        |j
                        | _        y rw   )rx   r   r@   rK   rW   r\   rz   s     r$   r|   z%BatchesWithStreamingResponse.__init__  s]    2NN
 5
 1LL
	 3NN
r&   Nr}   r   rk   r&   r$   r)   r)     r   r&   r)   c                      e Zd ZddZy)rp   c                    || _         t        |j                        | _        t        |j                        | _        t        |j                        | _        t        |j
                        | _        y rw   )rx   r   r@   rK   rW   r\   rz   s     r$   r|   z*AsyncBatchesWithStreamingResponse.__init__  s]    8NN
 ;
 7LL
	 9NN
r&   Nr   r   rk   r&   r$   rp   rp     r   r&   rp   )-
__future__r   typingr   r   typing_extensionsr   httpx r   typesr	   r
   _typesr   r   r   r   r   _utilsr   r   _compatr   	_resourcer   r   	_responser   r   
paginationr   r   types.batchr   _base_clientr   r   __all__r   r   r!   rn   r)   rp   rk   r&   r$   <module>r      s    # ! %   : > > & 9 X 8 
 n
%J
o J
ZJ
# J
Z
 
$
 
$
 
$
 
r&   