a
    fH                     @  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                   @  s   e Zd ZeddddZeddddZeddded	d
ddddddddd	ddZdddeddddddddddZeedddeddddddddddd Z	dddeddddddddd!d"Z
dS )#r   BatchesWithRawResponsereturnc                 C  s   t | S N)r   self r#   Q/var/www/ai-form-bot/venv/lib/python3.9/site-packages/openai/resources/batches.pywith_raw_response   s    zBatches.with_raw_responseBatchesWithStreamingResponsec                 C  s   t | S r    )r&   r!   r#   r#   r$   with_streaming_response#   s    zBatches.with_streaming_responseNmetadataextra_headersextra_query
extra_bodytimeoutLiteral['24h']DLiteral['/v1/chat/completions', '/v1/embeddings', '/v1/completions']str#Optional[Dict[str, str]] | NotGivenHeaders | NoneQuery | NoneBody | None'float | httpx.Timeout | None | NotGivenr   	completion_windowendpointinput_file_idr)   r*   r+   r,   r-   r   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r7   r8   r9   r)   r*   r+   r,   r-   bodyoptionscast_to)_postr   r	   BatchCreateParamsr   r   	r"   r7   r8   r9   r)   r*   r+   r,   r-   r#   r#   r$   create'   s    .	zBatches.creater=   batch_idr*   r+   r,   r-   r   c                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=   r@   rA   
ValueError_getr   r   r"   rG   r*   r+   r,   r-   r#   r#   r$   retrievef   s    zBatches.retrieveafterlimitr*   r+   r,   r-   str | NotGivenint | NotGivenzSyncCursorPage[Batch]rR   rS   r*   r+   r,   r-   r   c                C  s2   | 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)pager@   model)_get_api_listr   r   r   r   r   BatchListParamsr"   rR   rS   r*   r+   r,   r-   r#   r#   r$   list   s"    !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   rB   r   r   rO   r#   r#   r$   cancel   s    
zBatches.cancel__name__
__module____qualname__r   r%   r'   r
   rE   rP   r^   rb   r#   r#   r#   r$   r      s6   	"E$:c                   @  s   e Zd ZeddddZeddddZeddded	d
ddddddddd	ddZdddeddddddddddZeedddeddddddddddd Z	dddeddddddddd!d"Z
dS )#r   AsyncBatchesWithRawResponser   c                 C  s   t | S r    )rg   r!   r#   r#   r$   r%      s    zAsyncBatches.with_raw_response!AsyncBatchesWithStreamingResponsec                 C  s   t | S r    )rh   r!   r#   r#   r$   r'      s    z$AsyncBatches.with_streaming_responseNr(   r.   r/   r0   r1   r2   r3   r4   r5   r   r6   c          	   	     s<   | j dt||||dtjI dH t||||dtdI dH S )r:   r;   r<   Nr=   r>   )rB   r   r	   rC   r   r   rD   r#   r#   r$   rE      s    .	zAsyncBatches.creater=   rF   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   rT   rU   z-AsyncPaginator[Batch, AsyncCursorPage[Batch]]rV   c                C  s2   | j dtt t||||t||dtjdtdS rW   )r[   r   r   r   r   r   r\   r]   r#   r#   r$   r^   I  s"    !zAsyncBatches.listc                  s<   |st d|| jd| dt||||dtdI dH S )r_   rI   rJ   r`   r=   rK   Nra   rO   r#   r#   r$   rb   }  s    
zAsyncBatches.cancelrc   r#   r#   r#   r$   r      s6   	"E$:c                   @  s   e Zd ZdddddZdS )r   r   Nonebatchesr   c                 C  sB   || _ t|j| _t|j| _t|j| _t|j| _d S r    )_batchesr   Zto_raw_response_wrapperrE   rP   r^   rb   r"   rk   r#   r#   r$   __init__  s    zBatchesWithRawResponse.__init__Nrd   re   rf   rn   r#   r#   r#   r$   r     s   r   c                   @  s   e Zd ZdddddZdS )rg   r   ri   rj   c                 C  sB   || _ t|j| _t|j| _t|j| _t|j| _d S r    )rl   r   Zasync_to_raw_response_wrapperrE   rP   r^   rb   rm   r#   r#   r$   rn     s    z$AsyncBatchesWithRawResponse.__init__Nro   r#   r#   r#   r$   rg     s   rg   c                   @  s   e Zd ZdddddZdS )r&   r   ri   rj   c                 C  s:   || _ t|j| _t|j| _t|j| _t|j| _d S r    )rl   r   rE   rP   r^   rb   rm   r#   r#   r$   rn     s    z%BatchesWithStreamingResponse.__init__Nro   r#   r#   r#   r$   r&     s   r&   c                   @  s   e Zd ZdddddZdS )rh   r   ri   rj   c                 C  s:   || _ t|j| _t|j| _t|j| _t|j| _d S r    )rl   r   rE   rP   r^   rb   rm   r#   r#   r$   rn     s    z*AsyncBatchesWithStreamingResponse.__init__Nro   r#   r#   r#   r$   rh     s   rh   )-
__future__r   typingr   r   typing_extensionsr   Zhttpx r   typesr   r	   _typesr
   r   r   r   r   Z_utilsr   r   _compatr   Z	_resourcer   r   	_responser   r   Z
paginationr   r   Ztypes.batchr   Z_base_clientr   r   __all__r   r   r   rg   r&   rh   r#   r#   r#   r$   <module>   s,    C C