o
    ØRWj‡W  ã                   @  sH  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„ deƒZ+G dd„ deƒZ,G dd„ dƒZ-G dd„ dƒZ.G dd„ dƒZ/G d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d„ƒZed/dd„ƒZeed	d	d	ed
œd0dd„Z	d	d	d	ed œd1d"d#„Z
eed	d	d	ed$œd2d*d+„Zd	d	d	ed œd1d,d-„Zd	S )3r   ú;Create large batches of API requests to run asynchronously.ÚreturnÚBatchesWithRawResponsec                 C  ó   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#   ©Úself© r(   úg/home/esfera/Documents/content_generation/venv/lib/python3.10/site-packages/openai/resources/batches.pyÚwith_raw_response   ó   zBatches.with_raw_responseÚBatchesWithStreamingResponsec                 C  r$   ©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&   r(   r(   r)   Úwith_streaming_response&   ó   zBatches.with_streaming_responseN©ÚmetadataÚoutput_expires_afterÚextra_headersÚextra_queryÚ
extra_bodyÚtimeoutÚcompletion_windowúLiteral['24h']Úendpointú¤Literal['/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       	   
   
   C  s8   | j dt|||||dœtjƒt||||	ddid�td�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   r(   r(   r)   Úcreate/   s(   Bûø
ûízBatches.create©r3   r4   r5   r6   Úbatch_idc             	   C  ó<   |s	t d|›�ƒ‚| jtd|d�t||||ddid�td�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}©rR   rF   TrG   ©rK   rL   ©Ú
ValueErrorÚ_getr   r   r   ©r'   rR   r3   r4   r5   r6   r(   r(   r)   Úretrieve‡   s   
û÷zBatches.retrieve©ÚafterÚlimitr3   r4   r5   r6   r_   ú
str | Omitr`   ú
int | OmitúSyncCursorPage[Batch]c                C  ó8   | j dtt t||||t||dœtjƒddid�td�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
        rD   )r_   r`   rF   T)r3   r4   r5   r6   ÚqueryrH   )ÚpagerK   Úmodel)Ú_get_api_listr   r   r   r   r   ÚBatchListParams©r'   r_   r`   r3   r4   r5   r6   r(   r(   r)   Úlist¬   ó$   !þûôïzBatches.listc             	   C  rS   )á
  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
        rU   ú/batches/{batch_id}/cancelrW   rF   TrG   rX   ©rZ   rM   r   r   r   r\   r(   r(   r)   Úcancelá   s   
û÷zBatches.cancel)r"   r#   )r"   r,   ©r7   r8   r9   r:   r;   r<   r1   r=   r2   r>   r3   r?   r4   r@   r5   rA   r6   rB   r"   r   ©rR   r<   r3   r?   r4   r@   r5   rA   r6   rB   r"   r   )r_   ra   r`   rb   r3   r?   r4   r@   r5   rA   r6   rB   r"   rc   ©Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r*   r.   r   r   rP   r]   rl   rq   r(   r(   r(   r)   r      ó<    	ê^÷(ö;÷c                   @  r    )3r   r!   r"   ÚAsyncBatchesWithRawResponsec                 C  r$   r%   )rz   r&   r(   r(   r)   r*     r+   zAsyncBatches.with_raw_responseÚ!AsyncBatchesWithStreamingResponsec                 C  r$   r-   )r{   r&   r(   r(   r)   r.     r/   z$AsyncBatches.with_streaming_responseNr0   r7   r8   r9   r:   r;   r<   r1   r=   r2   r>   r3   r?   r4   r@   r5   rA   r6   rB   r   c       	   
   
   Ã  sF   �| j dt|||||dœtjƒI dH t||||	ddid�td�I dH S )rC   rD   rE   NrF   TrG   rI   )rM   r   r   rN   r   r   rO   r(   r(   r)   rP      s*   €Bûø
ûízAsyncBatches.createrQ   rR   c             	   Ã  óD   �|s
t d|›�ƒ‚| jtd|d�t||||ddid�td�I dH S )	rT   rU   rV   rW   rF   TrG   rX   NrY   r\   r(   r(   r)   r]   x  s   €
û÷zAsyncBatches.retriever^   r_   ra   r`   rb   ú-AsyncPaginator[Batch, AsyncCursorPage[Batch]]c                C  rd   re   )ri   r   r   r   r   r   rj   rk   r(   r(   r)   rl   �  rm   zAsyncBatches.listc             	   Ã  r|   )	rn   rU   ro   rW   rF   TrG   rX   Nrp   r\   r(   r(   r)   rq   Ò  s   €
û÷zAsyncBatches.cancel)r"   rz   )r"   r{   rr   rs   )r_   ra   r`   rb   r3   r?   r4   r@   r5   rA   r6   rB   r"   r}   rt   r(   r(   r(   r)   r   
  ry   c                   @  ó   e Zd Zddd„ZdS )	r#   Úbatchesr   r"   ÚNonec                 C  óB   || _ t |j¡| _t |j¡| _t |j¡| _t |j¡| _d S ©N)Ú_batchesr   Úto_raw_response_wrapperrP   r]   rl   rq   ©r'   r   r(   r(   r)   Ú__init__ü  ó   ÿÿÿ
ÿzBatchesWithRawResponse.__init__N©r   r   r"   r€   ©ru   rv   rw   r†   r(   r(   r(   r)   r#   û  ó    r#   c                   @  r~   )	rz   r   r   r"   r€   c                 C  r�   r‚   )rƒ   r   Úasync_to_raw_response_wrapperrP   r]   rl   rq   r…   r(   r(   r)   r†     r‡   z$AsyncBatchesWithRawResponse.__init__N©r   r   r"   r€   r‰   r(   r(   r(   r)   rz     rŠ   rz   c                   @  r~   )	r,   r   r   r"   r€   c                 C  ó:   || _ t|jƒ| _t|jƒ| _t|jƒ| _t|jƒ| _d S r‚   )rƒ   r   rP   r]   rl   rq   r…   r(   r(   r)   r†      ó   ÿÿÿ
ÿz%BatchesWithStreamingResponse.__init__Nrˆ   r‰   r(   r(   r(   r)   r,     rŠ   r,   c                   @  r~   )	r{   r   r   r"   r€   c                 C  r�   r‚   )rƒ   r   rP   r]   rl   rq   r…   r(   r(   r)   r†   2  rŽ   z*AsyncBatchesWithStreamingResponse.__init__NrŒ   r‰   r(   r(   r(   r)   r{   1  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#   rz   r,   r{   r(   r(   r(   r)   Ú<module>   s0   $ r r