o
    $i'_                     @  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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l0m1Z1 ddl2m3Z3 ddl4m5Z5 ddl6m7Z7 ddgZ8G dd deZ9G 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)BodyOmitQueryHeadersNotGivenomit	not_given)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                	   @     e Zd Zed6ddZed7ddZed8d	d
Zeedddedd9ddZ	ddded d:d#d$Z
eeeeddded%d;d.d/Zddded d<d1d2Zddded d=d4d5ZdS )>r(   returnr   c                 C  
   t | jS N)r   _clientself r1   `/var/www/html/flask_server/venv/lib/python3.10/site-packages/openai/resources/evals/runs/runs.pyoutput_items&      
zRuns.output_itemsRunsWithRawResponsec                 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
        )r5   r/   r1   r1   r2   with_raw_response*      zRuns.with_raw_responseRunsWithStreamingResponsec                 C  r6   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/   r1   r1   r2   with_streaming_response4      zRuns.with_streaming_responseNmetadatanameextra_headersextra_query
extra_bodytimeouteval_idstrdata_sourcerun_create_params.DataSourcer?   Optional[Metadata] | Omitr@   
str | OmitrA   Headers | NonerB   Query | NonerC   Body | NonerD   'float | httpx.Timeout | None | NotGivenr%   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rG   r?   r@   rA   rB   rC   rD   bodyoptionscast_to)
ValueError_postr   r   RunCreateParamsr!   r%   	r0   rE   rG   r?   r@   rA   rB   rC   rD   r1   r1   r2   create=   s    '
zRuns.createrT   run_idr'   c                C  L   |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
        rP   5Expected a non-empty value for `run_id` but received rQ   /runs/rT   rW   rX   rY   _getr!   r'   r0   r^   rE   rA   rB   rC   rD   r1   r1   r2   retrievev      zRuns.retrieveafterlimitorderstatusrA   rB   rC   rD   rj   rk   
int | Omitrl   Literal['asc', 'desc'] | Omitrm   JLiteral['queued', 'in_progress', 'completed', 'canceled', 'failed'] | OmitSyncCursorPage[RunListResponse]c          
      C  P   |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
        rP   rQ   rR   )rj   rk   rl   rm   )rA   rB   rC   rD   query)pagerW   model)rY   _get_api_listr   r#   r!   r   r   RunListParams
r0   rE   rj   rk   rl   rm   rA   rB   rC   rD   r1   r1   r2   list   *   %
z	Runs.listr&   c                C  r_   )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
        rP   ra   rQ   rb   rT   rc   rY   _deleter!   r&   rf   r1   r1   r2   delete   rh   zRuns.deleter$   c                C  r_   )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
        rP   ra   rQ   rb   rT   rc   rY   rZ   r!   r$   rf   r1   r1   r2   cancel   rh   zRuns.cancel)r+   r   )r+   r5   )r+   r:   rE   rF   rG   rH   r?   rI   r@   rJ   rA   rK   rB   rL   rC   rM   rD   rN   r+   r%   r^   rF   rE   rF   rA   rK   rB   rL   rC   rM   rD   rN   r+   r'   )rE   rF   rj   rJ   rk   rn   rl   ro   rm   rp   rA   rK   rB   rL   rC   rM   rD   rN   r+   rq   r^   rF   rE   rF   rA   rK   rB   rL   rC   rM   rD   rN   r+   r&   r^   rF   rE   rF   rA   rK   rB   rL   rC   rM   rD   rN   r+   r$   __name__
__module____qualname__r   r3   r8   r<   r   r   r]   rg   rz   r   r   r1   r1   r1   r2   r(   %   L    	@(C+c                	   @  r*   )>r)   r+   r   c                 C  r,   r-   )r   r.   r/   r1   r1   r2   r3      r4   zAsyncRuns.output_itemsAsyncRunsWithRawResponsec                 C  r6   r7   )r   r/   r1   r1   r2   r8   $  r9   zAsyncRuns.with_raw_responseAsyncRunsWithStreamingResponsec                 C  r6   r;   )r   r/   r1   r1   r2   r<   .  r=   z!AsyncRuns.with_streaming_responseNr>   rE   rF   rG   rH   r?   rI   r@   rJ   rA   rK   rB   rL   rC   rM   rD   rN   r%   c          	   	     sV   |s
t d|| jd| dt|||dtjI dH t||||dtdI dH S )rO   rP   rQ   rR   rS   NrT   rU   )rY   rZ   r   r   r[   r!   r%   r\   r1   r1   r2   r]   7  s"   '
zAsyncRuns.createrT   r^   r'   c                  T   |s
t d||st d|| jd| d| t||||dtdI dH S )r`   rP   ra   rQ   rb   rT   rc   Nrd   rf   r1   r1   r2   rg   p     zAsyncRuns.retrieveri   rj   rk   rn   rl   ro   rm   rp   AAsyncPaginator[RunListResponse, AsyncCursorPage[RunListResponse]]c          
      C  rr   rs   )rY   rw   r   r#   r!   r   r   rx   ry   r1   r1   r2   rz     r{   zAsyncRuns.listr&   c                  r   )r|   rP   ra   rQ   rb   rT   rc   Nr}   rf   r1   r1   r2   r     r   zAsyncRuns.deleter$   c                  r   )r   rP   ra   rQ   rb   rT   rc   Nr   rf   r1   r1   r2   r     r   zAsyncRuns.cancel)r+   r   )r+   r   )r+   r   r   r   )rE   rF   rj   rJ   rk   rn   rl   ro   rm   rp   rA   rK   rB   rL   rC   rM   rD   rN   r+   r   r   r   r   r1   r1   r1   r2   r)     r   c                   @  $   e Zd ZdddZeddd	Zd
S )r5   runsr(   r+   Nonec                 C  P   || _ t|j| _t|j| _t|j| _t|j| _t|j| _d S r-   )_runsr   to_raw_response_wrapperr]   rg   rz   r   r   r0   r   r1   r1   r2   __init__      
zRunsWithRawResponse.__init__r   c                 C     t | jjS r-   )r   r   r3   r/   r1   r1   r2   r3   -     z RunsWithRawResponse.output_itemsNr   r(   r+   r   )r+   r   r   r   r   r   r   r3   r1   r1   r1   r2   r5         
r5   c                   @  r   )r   r   r)   r+   r   c                 C  r   r-   )r   r   async_to_raw_response_wrapperr]   rg   rz   r   r   r   r1   r1   r2   r   3  r   z!AsyncRunsWithRawResponse.__init__r   c                 C  r   r-   )r   r   r3   r/   r1   r1   r2   r3   F  r   z%AsyncRunsWithRawResponse.output_itemsNr   r)   r+   r   )r+   r   r   r1   r1   r1   r2   r   2  r   r   c                   @  r   )r:   r   r(   r+   r   c                 C  F   || _ t|j| _t|j| _t|j| _t|j| _t|j| _d S r-   )r   r   r]   rg   rz   r   r   r   r1   r1   r2   r   L      
z"RunsWithStreamingResponse.__init__r   c                 C  r   r-   )r   r   r3   r/   r1   r1   r2   r3   _  r   z&RunsWithStreamingResponse.output_itemsNr   )r+   r   r   r1   r1   r1   r2   r:   K  r   r:   c                   @  r   )r   r   r)   r+   r   c                 C  r   r-   )r   r   r]   rg   rz   r   r   r   r1   r1   r2   r   e  r   z'AsyncRunsWithStreamingResponse.__init__r   c                 C  r   r-   )r   r   r3   r/   r1   r1   r2   r3   x  r   z+AsyncRunsWithStreamingResponse.output_itemsNr   )r+   r   r   r1   r1   r1   r2   r   d  r   r   )?
__future__r   typingr   typing_extensionsr   httpx r   _typesr   r   r	   r
   r   r   r   _utilsr   r   _compatr   	_resourcer   r   	_responser   r   r3   r   r   r   r   r   r   
paginationr   r   types.evalsr   r   _base_clientr    r!   types.shared_params.metadatar"   types.evals.run_list_responser#   types.evals.run_cancel_responser$   types.evals.run_create_responser%   types.evals.run_delete_responser&   !types.evals.run_retrieve_responser'   __all__r(   r)   r5   r   r:   r   r1   r1   r1   r2   <module>   s:   $  { {