U
    ~fh_                     @  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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mZmZmZ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- ddl.m/Z/ ddl0m1Z1 ddl2m3Z3 ddl4m5Z5 ddgZ6G dd deZ7G dd deZ8G dd dZ9G dd dZ:G dd  d Z;G d!d" d"Z<dS )#    )annotations)Optional)LiteralN   )_legacy_response)	NOT_GIVENBodyQueryHeadersNotGiven)maybe_transformasync_maybe_transform)cached_property)SyncAPIResourceAsyncAPIResource)to_streamed_response_wrapper"async_to_streamed_response_wrapper   )OutputItemsAsyncOutputItemsOutputItemsWithRawResponseAsyncOutputItemsWithRawResponse OutputItemsWithStreamingResponse%AsyncOutputItemsWithStreamingResponse)SyncCursorPageAsyncCursorPage)run_list_paramsrun_create_params)AsyncPaginatormake_request_options)Metadata)RunListResponse)RunCancelResponse)RunCreateResponse)RunDeleteResponse)RunRetrieveResponseRuns	AsyncRunsc                   @  s  e Zd ZeddddZeddddZeddd	d
Ze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dZ	eeeeddded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'd(Zdddedddddddd)dd*d+ZdS ),r&   r   returnc                 C  s
   t | jS N)r   _clientself r.   D/tmp/pip-unpacked-wheel-rjiviquo/openai/resources/evals/runs/runs.pyoutput_items&   s    zRuns.output_itemsRunsWithRawResponsec                 C  s   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
        )r1   r,   r.   r.   r/   with_raw_response*   s    zRuns.with_raw_responseRunsWithStreamingResponsec                 C  s   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
        )r4   r,   r.   r.   r/   with_streaming_response4   s    zRuns.with_streaming_responseNmetadatanameextra_headersextra_query
extra_bodytimeoutstrrun_create_params.DataSourceOptional[Metadata] | NotGivenstr | NotGivenHeaders | NoneQuery | NoneBody | None'float | httpx.Timeout | None | NotGivenr#   	eval_iddata_sourcer8   r9   r:   r;   r<   r=   r)   c          	   	   C  sH   |st d|| jd| dt|||dtjt||||dtdS )  
        Kicks off a new run for a given evaluation, specifying the data source, and what
        model configuration to use to test. The datasource will be validated against the
        schema specified in the config of the evaluation.

        Args:
          data_source: Details about the run's data source.

          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.

          name: The name of the run.

          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
        6Expected a non-empty value for `eval_id` but received /evals//runsrH   r8   r9   r:   r;   r<   r=   bodyoptionscast_to)
ValueError_postr   r   RunCreateParamsr   r#   	r-   rG   rH   r8   r9   r:   r;   r<   r=   r.   r.   r/   create=   s&    '
   zRuns.createrN   r%   run_idrG   r:   r;   r<   r=   r)   c                C  sL   |st d||s$t d|| jd| d| t||||dtdS )P  
        Get an evaluation run by ID.

        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
        rJ   5Expected a non-empty value for `run_id` but received rK   /runs/rN   rQ   rR   rS   _getr   r%   r-   rY   rG   r:   r;   r<   r=   r.   r.   r/   retrievev   s       zRuns.retrieveafterlimitorderstatusr:   r;   r<   r=   int | NotGiven#Literal[('asc', 'desc')] | NotGivenPLiteral[('queued', 'in_progress', 'completed', 'canceled', 'failed')] | NotGivenzSyncCursorPage[RunListResponse]
rG   rc   rd   re   rf   r:   r;   r<   r=   r)   c          
      C  sP   |st d|| jd| dtt t||||	t||||dtjdtdS a  
        Get a list of runs for an evaluation.

        Args:
          after: Identifier for the last run from the previous pagination request.

          limit: Number of runs to retrieve.

          order: Sort order for runs by timestamp. Use `asc` for ascending order or `desc` for
              descending order. Defaults to `asc`.

          status: Filter runs by status. One of `queued` | `in_progress` | `failed` | `completed`
              | `canceled`.

          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
        rJ   rK   rL   )rc   rd   re   rf   )r:   r;   r<   r=   query)pagerQ   model)rS   _get_api_listr   r!   r   r   r   RunListParams
r-   rG   rc   rd   re   rf   r:   r;   r<   r=   r.   r.   r/   list   s*    %
z	Runs.listr$   c                C  sL   |st d||s$t d|| jd| d| t||||dtdS )G  
        Delete an eval run.

        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
        rJ   r[   rK   r\   rN   r]   rS   _deleter   r$   r`   r.   r.   r/   delete   s       zRuns.deleter"   c                C  sL   |st d||s$t d|| jd| d| t||||dtdS )U  
        Cancel an ongoing evaluation run.

        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
        rJ   r[   rK   r\   rN   r]   rS   rT   r   r"   r`   r.   r.   r/   cancel   s       zRuns.cancel__name__
__module____qualname__r   r0   r3   r6   r   rW   ra   rr   rv   ry   r.   r.   r.   r/   r&   %   sJ   	"@($C+c                   @  s  e Zd ZeddddZeddddZeddd	d
Ze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dZ	eeeeddded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'd(Zdddedddddddd)dd*d+ZdS ),r'   r   r(   c                 C  s
   t | jS r*   )r   r+   r,   r.   r.   r/   r0      s    zAsyncRuns.output_itemsAsyncRunsWithRawResponsec                 C  s   t | S r2   )r~   r,   r.   r.   r/   r3   $  s    zAsyncRuns.with_raw_responseAsyncRunsWithStreamingResponsec                 C  s   t | S r5   )r   r,   r.   r.   r/   r6   .  s    z!AsyncRuns.with_streaming_responseNr7   r>   r?   r@   rA   rB   rC   rD   rE   r#   rF   c          	   	     sT   |st d|| jd| dt|||dtjI dH t||||dtdI dH S )rI   rJ   rK   rL   rM   NrN   rO   )rS   rT   r   r   rU   r   r#   rV   r.   r.   r/   rW   7  s&    '
   zAsyncRuns.createrN   r%   rX   c                  sR   |st d||s$t d|| jd| d| t||||dtdI dH S )rZ   rJ   r[   rK   r\   rN   r]   Nr^   r`   r.   r.   r/   ra   p  s       zAsyncRuns.retrieverb   rg   rh   ri   zAAsyncPaginator[RunListResponse, AsyncCursorPage[RunListResponse]]rj   c          
      C  sP   |st d|| jd| dtt t||||	t||||dtjdtdS rk   )rS   ro   r   r!   r   r   r   rp   rq   r.   r.   r/   rr     s*    %
zAsyncRuns.listr$   c                  sR   |st d||s$t d|| jd| d| t||||dtdI dH S )rs   rJ   r[   rK   r\   rN   r]   Nrt   r`   r.   r.   r/   rv     s       zAsyncRuns.deleter"   c                  sR   |st d||s$t d|| jd| d| t||||dtdI dH S )rw   rJ   r[   rK   r\   rN   r]   Nrx   r`   r.   r.   r/   ry     s       zAsyncRuns.cancelrz   r.   r.   r.   r/   r'     sJ   	"@($C+c                   @  s.   e Zd ZdddddZedddd	Zd
S )r1   r&   Nonerunsr)   c                 C  sP   || _ t|j| _t|j| _t|j| _t|j| _t|j| _d S r*   )_runsr   Zto_raw_response_wrapperrW   ra   rr   rv   ry   r-   r   r.   r.   r/   __init__  s     zRunsWithRawResponse.__init__r   r(   c                 C  s   t | jjS r*   )r   r   r0   r,   r.   r.   r/   r0   -  s    z RunsWithRawResponse.output_itemsNr{   r|   r}   r   r   r0   r.   r.   r.   r/   r1     s   r1   c                   @  s.   e Zd ZdddddZedddd	Zd
S )r~   r'   r   r   c                 C  sP   || _ t|j| _t|j| _t|j| _t|j| _t|j| _d S r*   )r   r   Zasync_to_raw_response_wrapperrW   ra   rr   rv   ry   r   r.   r.   r/   r   3  s     z!AsyncRunsWithRawResponse.__init__r   r(   c                 C  s   t | jjS r*   )r   r   r0   r,   r.   r.   r/   r0   F  s    z%AsyncRunsWithRawResponse.output_itemsNr   r.   r.   r.   r/   r~   2  s   r~   c                   @  s.   e Zd ZdddddZedddd	Zd
S )r4   r&   r   r   c                 C  sF   || _ t|j| _t|j| _t|j| _t|j| _t|j| _d S r*   )r   r   rW   ra   rr   rv   ry   r   r.   r.   r/   r   L  s     z"RunsWithStreamingResponse.__init__r   r(   c                 C  s   t | jjS r*   )r   r   r0   r,   r.   r.   r/   r0   _  s    z&RunsWithStreamingResponse.output_itemsNr   r.   r.   r.   r/   r4   K  s   r4   c                   @  s.   e Zd ZdddddZedddd	Zd
S )r   r'   r   r   c                 C  sF   || _ t|j| _t|j| _t|j| _t|j| _t|j| _d S r*   )r   r   rW   ra   rr   rv   ry   r   r.   r.   r/   r   e  s     z'AsyncRunsWithStreamingResponse.__init__r   r(   c                 C  s   t | jjS r*   )r   r   r0   r,   r.   r.   r/   r0   x  s    z+AsyncRunsWithStreamingResponse.output_itemsNr   r.   r.   r.   r/   r   d  s   r   )=
__future__r   typingr   Ztyping_extensionsr   Zhttpx r   _typesr   r   r	   r
   r   _utilsr   r   _compatr   Z	_resourcer   r   	_responser   r   r0   r   r   r   r   r   r   Z
paginationr   r   Ztypes.evalsr   r   Z_base_clientr   r   Ztypes.shared_params.metadatar    Ztypes.evals.run_list_responser!   Ztypes.evals.run_cancel_responser"   Ztypes.evals.run_create_responser#   Ztypes.evals.run_delete_responser$   Z!types.evals.run_retrieve_responser%   __all__r&   r'   r1   r~   r4   r   r.   r.   r.   r/   <module>   s8     { {