o
    +Âif€H  ã                   @  s4  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„ 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)Ú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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 ©N)r   ©Úself© r$   úQ/var/www/html/corbot_env/lib/python3.10/site-packages/openai/resources/batches.pyÚwith_raw_response   ó   zBatches.with_raw_responseÚBatchesWithStreamingResponsec                 C  r    r!   )r(   r"   r$   r$   r%   Úwith_streaming_response#   r'   zBatches.with_streaming_responseN©ÚmetadataÚextra_headersÚextra_queryÚ
extra_bodyÚtimeoutÚcompletion_windowúLiteral['24h']ÚendpointúDLiteral['/v1/chat/completions', '/v1/embeddings', '/v1/completions']Úinput_file_idÚstrr+   ú#Optional[Dict[str, str]] | NotGivenr,   úHeaders | Noner-   úQuery | Noner.   úBody | Noner/   ú'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/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 100 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©r0   r2   r4   r+   ©r,   r-   r.   r/   ©ÚbodyÚoptionsÚcast_to)Ú_postr   r	   ÚBatchCreateParamsr   r   ©	r#   r0   r2   r4   r+   r,   r-   r.   r/   r$   r$   r%   Úcreate'   s   .üù	ÿò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>   ©rA   rB   ©Ú
ValueErrorÚ_getr   r   ©r#   rG   r,   r-   r.   r/   r$   r$   r%   Úretrievef   s   ÿûzBatches.retrieve©ÚafterÚlimitr,   r-   r.   r/   rR   ústr | NotGivenrS   ú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<   )rR   rS   )r,   r-   r.   r/   Úquery)ÚpagerA   Úmodel)Ú_get_api_listr   r   r   r   r   ÚBatchListParams©r#   rR   rS   r,   r-   r.   r/   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
        rI   rJ   ú/cancelr>   rK   ©rM   rC   r   r   rO   r$   r$   r%   Úcancel»   s   
ÿûzBatches.cancel)r   r   )r   r(   ©r0   r1   r2   r3   r4   r5   r+   r6   r,   r7   r-   r8   r.   r9   r/   r:   r   r   ©rG   r5   r,   r7   r-   r8   r.   r9   r/   r:   r   r   )rR   rT   rS   rU   r,   r7   r-   r8   r.   r9   r/   r:   r   rV   ©Ú__name__Ú
__module__Ú__qualname__r   r&   r)   r
   rF   rP   r_   rd   r$   r$   r$   r%   r      ó8    	ôE÷$ö:÷c                   @  r   )0r   r   ÚAsyncBatchesWithRawResponsec                 C  r    r!   )rl   r"   r$   r$   r%   r&   á   r'   zAsyncBatches.with_raw_responseÚ!AsyncBatchesWithStreamingResponsec                 C  r    r!   )rm   r"   r$   r$   r%   r)   å   r'   z$AsyncBatches.with_streaming_responseNr*   r0   r1   r2   r3   r4   r5   r+   r6   r,   r7   r-   r8   r.   r9   r/   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>   r?   )rC   r   r	   rD   r   r   rE   r$   r$   r%   rF   é   s    €.üù	ÿòzAsyncBatches.creater>   rG   c                Ã  s<   �|s
t d|›�ƒ‚| jd|› �t||||d�td�I dH S )rH   rI   rJ   r>   rK   NrL   rO   r$   r$   r%   rP   (  s   €ÿûzAsyncBatches.retrieverQ   rR   rT   rS   rU   ú-AsyncPaginator[Batch, AsyncCursorPage[Batch]]c                C  rW   rX   )r\   r   r   r   r   r   r]   r^   r$   r$   r%   r_   I  r`   zAsyncBatches.listc                Ã  s>   �|s
t d|›�ƒ‚| jd|› d�t||||d�td�I dH S )ra   rI   rJ   rb   r>   rK   Nrc   rO   r$   r$   r%   rd   }  s   €
ÿûzAsyncBatches.cancel)r   rl   )r   rm   re   rf   )rR   rT   rS   rU   r,   r7   r-   r8   r.   r9   r/   r:   r   rn   rg   r$   r$   r$   r%   r   à   rk   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 r!   )Ú_batchesr   Úto_raw_response_wrapperrF   rP   r_   rd   ©r#   rp   r$   r$   r%   Ú__init__£  ó   ÿÿÿ
ÿzBatchesWithRawResponse.__init__N©rp   r   r   rq   ©rh   ri   rj   rv   r$   r$   r$   r%   r   ¢  ó    r   c                   @  ro   )	rl   rp   r   r   rq   c                 C  rr   r!   )rs   r   Úasync_to_raw_response_wrapperrF   rP   r_   rd   ru   r$   r$   r%   rv   µ  rw   z$AsyncBatchesWithRawResponse.__init__N©rp   r   r   rq   ry   r$   r$   r$   r%   rl   ´  rz   rl   c                   @  ro   )	r(   rp   r   r   rq   c                 C  ó:   || _ t|jƒ| _t|jƒ| _t|jƒ| _t|jƒ| _d S r!   )rs   r   rF   rP   r_   rd   ru   r$   r$   r%   rv   Ç  ó   ÿÿÿ
ÿz%BatchesWithStreamingResponse.__init__Nrx   ry   r$   r$   r$   r%   r(   Æ  rz   r(   c                   @  ro   )	rm   rp   r   r   rq   c                 C  r}   r!   )rs   r   rF   rP   r_   rd   ru   r$   r$   r%   rv   Ù  r~   z*AsyncBatchesWithStreamingResponse.__init__Nr|   ry   r$   r$   r$   r%   rm   Ø  rz   rm   )-Ú
__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   rl   r(   rm   r$   r$   r$   r%   Ú<module>   s.    C C