o
    ?HhuO                     @  s<  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 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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Z-dS )    )annotations)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)MetadataBatchesAsyncBatchesc                   @     e Zd Zed+ddZed,ddZeddded	d-ddZdddedd.dd Zeeddded!d/d'd(Z	dddedd.d)d*Z
dS )0r   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$   X/home/air/sanwanet/gpt-api/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extra_headersextra_query
extra_bodytimeoutcompletion_windowLiteral['24h']endpointULiteral['/v1/responses', '/v1/chat/completions', '/v1/embeddings', '/v1/completions']input_file_idstrr-   Optional[Metadata] | NotGivenr.   Headers | Noner/   Query | Noner0   Body | Noner1   'float | httpx.Timeout | None | NotGivenr   c          	   	   C  s0   | j dt||||dtjt||||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`, 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: 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.

          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r2   r4   r6   r-   r.   r/   r0   r1   bodyoptionscast_to)_postr   r   BatchCreateParamsr   r   	r#   r2   r4   r6   r-   r.   r/   r0   r1   r$   r$   r%   create0   s   3	zBatches.creater@   batch_idc                C  s4   |s	t d|| jd| t||||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/r@   rC   rD   
ValueError_getr   r   r#   rI   r.   r/   r0   r1   r$   r$   r%   retrievet   s   zBatches.retrieveafterlimitr.   r/   r0   r1   rT   str | NotGivenrU   int | NotGivenSyncCursorPage[Batch]c                C  2   | j dtt t||||t||dtj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
        r>   )rT   rU   )r.   r/   r0   r1   query)pagerC   model)_get_api_listr   r   r   r   r   BatchListParamsr#   rT   rU   r.   r/   r0   r1   r$   r$   r%   list   "   !zBatches.listc                C  s6   |s	t d|| jd| dt||||dtd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
        rK   rL   /cancelr@   rM   rO   rE   r   r   rQ   r$   r$   r%   cancel   s   
zBatches.cancel)r   r   )r   r(   r2   r3   r4   r5   r6   r7   r-   r8   r.   r9   r/   r:   r0   r;   r1   r<   r   r   rI   r7   r.   r9   r/   r:   r0   r;   r1   r<   r   r   )rT   rV   rU   rW   r.   r9   r/   r:   r0   r;   r1   r<   r   rX   __name__
__module____qualname__r   r&   r*   r	   rH   rR   ra   rf   r$   r$   r$   r%   r      8    	J$:c                   @  r   )0r   r   AsyncBatchesWithRawResponsec                 C  r    r!   )rn   r"   r$   r$   r%   r&      r'   zAsyncBatches.with_raw_response!AsyncBatchesWithStreamingResponsec                 C  r    r)   )ro   r"   r$   r$   r%   r*      r+   z$AsyncBatches.with_streaming_responseNr,   r2   r3   r4   r5   r6   r7   r-   r8   r.   r9   r/   r:   r0   r;   r1   r<   r   c          	   	     s>   | j dt||||dtjI dH t||||dtdI dH S )r=   r>   r?   Nr@   rA   )rE   r   r   rF   r   r   rG   r$   r$   r%   rH     s    3	zAsyncBatches.creater@   rI   c                  s<   |s
t d|| jd| t||||dtdI dH S )rJ   rK   rL   r@   rM   NrN   rQ   r$   r$   r%   rR   F  s   zAsyncBatches.retrieverS   rT   rV   rU   rW   -AsyncPaginator[Batch, AsyncCursorPage[Batch]]c                C  rY   rZ   )r^   r   r   r   r   r   r_   r`   r$   r$   r%   ra   g  rb   zAsyncBatches.listc                  s>   |s
t d|| jd| dt||||dtdI dH S )rc   rK   rL   rd   r@   rM   Nre   rQ   r$   r$   r%   rf     s   
zAsyncBatches.cancel)r   rn   )r   ro   rg   rh   )rT   rV   rU   rW   r.   r9   r/   r:   r0   r;   r1   r<   r   rp   ri   r$   r$   r$   r%   r      rm   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_wrapperrH   rR   ra   rf   r#   rr   r$   r$   r%   __init__     
zBatchesWithRawResponse.__init__Nrr   r   r   rs   rj   rk   rl   ry   r$   r$   r$   r%   r         r   c                   @  rq   )	rn   rr   r   r   rs   c                 C  rt   ru   )rv   r   async_to_raw_response_wrapperrH   rR   ra   rf   rx   r$   r$   r%   ry     rz   z$AsyncBatchesWithRawResponse.__init__Nrr   r   r   rs   r|   r$   r$   r$   r%   rn     r}   rn   c                   @  rq   )	r(   rr   r   r   rs   c                 C  :   || _ t|j| _t|j| _t|j| _t|j| _d S ru   )rv   r   rH   rR   ra   rf   rx   r$   r$   r%   ry        
z%BatchesWithStreamingResponse.__init__Nr{   r|   r$   r$   r$   r%   r(     r}   r(   c                   @  rq   )	ro   rr   r   r   rs   c                 C  r   ru   )rv   r   rH   rR   ra   rf   rx   r$   r$   r%   ry     r   z*AsyncBatchesWithStreamingResponse.__init__Nr   r|   r$   r$   r$   r%   ro     r}   ro   ).
__future__r   typingr   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   types.shared_params.metadatar   __all__r   r   r   rn   r(   ro   r$   r$   r$   r%   <module>   s0    S S