o
    ib                     @  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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/m0Z0 ddl1m2Z2 ddl3m4Z4 ddl5m6Z6 ddl7m8Z8 ddgZ9G 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)BodyOmitQueryHeadersNotGivenomit	not_given)path_template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dZed7ddZed8ddZed9d
dZeeddde	dd:dd Z
ddde	d!d;d$d%Zeeeeddde	d&d<d/d0Zddde	d!d=d2d3Zddde	d!d>d5d6ZdS )?r)   ,Manage and run evals in the OpenAI platform.returnr   c                 C  
   t | jS r,   )r   _clientself r3   Z/home/kim/smarthome/.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
        )r7   r1   r3   r3   r4   with_raw_response-      zRuns.with_raw_responseRunsWithStreamingResponsec                 C  r8   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<   r1   r3   r3   r4   with_streaming_response7      zRuns.with_streaming_responseNmetadatanameextra_headersextra_query
extra_bodytimeouteval_idstrdata_sourcerun_create_params.DataSourcerA   Optional[Metadata] | OmitrB   
str | OmitrC   Headers | NonerD   Query | NonerE   Body | NonerF   'float | httpx.Timeout | None | NotGivenr&   c          	   	   C  sH   |s	t d|| jt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/{eval_id}/runsrG   rI   rA   rB   rC   rD   rE   rF   bodyoptionscast_to)
ValueError_postr   r   r    RunCreateParamsr"   r&   	r2   rG   rI   rA   rB   rC   rD   rE   rF   r3   r3   r4   create@   s    '
zRuns.createrV   run_idr(   c                C  J   |s	t d||st d|| jt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
        rR   5Expected a non-empty value for `run_id` but received /evals/{eval_id}/runs/{run_id}rG   r`   rV   rY   rZ   r[   _getr   r"   r(   r2   r`   rG   rC   rD   rE   rF   r3   r3   r4   retrievey      zRuns.retrieveafterlimitorderstatusrC   rD   rE   rF   rm   rn   
int | Omitro   Literal['asc', 'desc'] | Omitrp   JLiteral['queued', 'in_progress', 'completed', 'canceled', 'failed'] | OmitSyncCursorPage[RunListResponse]c          
      C  P   |s	t d|| jt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
        rR   rS   rT   )rm   rn   ro   rp   )rC   rD   rE   rF   query)pagerY   model)	r[   _get_api_listr   r   r$   r"   r   r   RunListParams
r2   rG   rm   rn   ro   rp   rC   rD   rE   rF   r3   r3   r4   list   *   %
z	Runs.listr'   c                C  ra   )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
        rR   rc   rd   re   rV   rf   r[   _deleter   r"   r'   ri   r3   r3   r4   delete   rk   zRuns.deleter%   c                C  ra   )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
        rR   rc   rd   re   rV   rf   r[   r\   r   r"   r%   ri   r3   r3   r4   cancel   rk   zRuns.cancel)r-   r   )r-   r7   )r-   r<   rG   rH   rI   rJ   rA   rK   rB   rL   rC   rM   rD   rN   rE   rO   rF   rP   r-   r&   r`   rH   rG   rH   rC   rM   rD   rN   rE   rO   rF   rP   r-   r(   )rG   rH   rm   rL   rn   rq   ro   rr   rp   rs   rC   rM   rD   rN   rE   rO   rF   rP   r-   rt   r`   rH   rG   rH   rC   rM   rD   rN   rE   rO   rF   rP   r-   r'   r`   rH   rG   rH   rC   rM   rD   rN   rE   rO   rF   rP   r-   r%   __name__
__module____qualname____doc__r   r5   r:   r>   r   r   r_   rj   r}   r   r   r3   r3   r3   r4   r)   %   N    	@(C+c                	   @  r+   )?r*   r,   r-   r   c                 C  r.   r/   )r   r0   r1   r3   r3   r4   r5   %  r6   zAsyncRuns.output_itemsAsyncRunsWithRawResponsec                 C  r8   r9   )r   r1   r3   r3   r4   r:   *  r;   zAsyncRuns.with_raw_responseAsyncRunsWithStreamingResponsec                 C  r8   r=   )r   r1   r3   r3   r4   r>   4  r?   z!AsyncRuns.with_streaming_responseNr@   rG   rH   rI   rJ   rA   rK   rB   rL   rC   rM   rD   rN   rE   rO   rF   rP   r&   c          	   	     sV   |s
t d|| jtd|dt|||dtjI dH t||||dtdI dH S )rQ   rR   rS   rT   rU   NrV   rW   )r[   r\   r   r   r    r]   r"   r&   r^   r3   r3   r4   r_   =  s"   '
zAsyncRuns.createrV   r`   r(   c                  R   |s
t d||st d|| jtd||dt||||dtdI dH S )rb   rR   rc   rd   re   rV   rf   Nrg   ri   r3   r3   r4   rj   v     zAsyncRuns.retrieverl   rm   rn   rq   ro   rr   rp   rs   AAsyncPaginator[RunListResponse, AsyncCursorPage[RunListResponse]]c          
      C  ru   rv   )	r[   rz   r   r   r$   r"   r   r   r{   r|   r3   r3   r4   r}     r~   zAsyncRuns.listr'   c                  r   )r   rR   rc   rd   re   rV   rf   Nr   ri   r3   r3   r4   r     r   zAsyncRuns.deleter%   c                  r   )r   rR   rc   rd   re   rV   rf   Nr   ri   r3   r3   r4   r     r   zAsyncRuns.cancel)r-   r   )r-   r   )r-   r   r   r   )rG   rH   rm   rL   rn   rq   ro   rr   rp   rs   rC   rM   rD   rN   rE   rO   rF   rP   r-   r   r   r   r   r3   r3   r3   r4   r*   "  r   c                   @  $   e Zd ZdddZeddd	Zd
S )r7   runsr)   r-   Nonec                 C  P   || _ t|j| _t|j| _t|j| _t|j| _t|j| _d S N)_runsr   Zto_raw_response_wrapperr_   rj   r}   r   r   r2   r   r3   r3   r4   __init__       
zRunsWithRawResponse.__init__r   c                 C     t | jjS r/   )r   r   r5   r1   r3   r3   r4   r5   3     z RunsWithRawResponse.output_itemsNr   r)   r-   r   )r-   r   r   r   r   r   r   r5   r3   r3   r3   r4   r7         
r7   c                   @  r   )r   r   r*   r-   r   c                 C  r   r   )r   r   Zasync_to_raw_response_wrapperr_   rj   r}   r   r   r   r3   r3   r4   r   :  r   z!AsyncRunsWithRawResponse.__init__r   c                 C  r   r/   )r   r   r5   r1   r3   r3   r4   r5   M  r   z%AsyncRunsWithRawResponse.output_itemsNr   r*   r-   r   )r-   r   r   r3   r3   r3   r4   r   9  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_   rj   r}   r   r   r   r3   r3   r4   r   T      
z"RunsWithStreamingResponse.__init__r   c                 C  r   r/   )r   r   r5   r1   r3   r3   r4   r5   g  r   z&RunsWithStreamingResponse.output_itemsNr   )r-   r   r   r3   r3   r3   r4   r<   S  r   r<   c                   @  r   )r   r   r*   r-   r   c                 C  r   r   )r   r   r_   rj   r}   r   r   r   r3   r3   r4   r   n  r   z'AsyncRunsWithStreamingResponse.__init__r   c                 C  r   r/   )r   r   r5   r1   r3   r3   r4   r5     r   z+AsyncRunsWithStreamingResponse.output_itemsNr   )r-   r   r   r3   r3   r3   r4   r   m  r   r   )@
__future__r   typingr   Ztyping_extensionsr   Zhttpx r   _typesr   r   r	   r
   r   r   r   Z_utilsr   r   r   Z_compatr   Z	_resourcer   r   	_responser   r   r5   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*   r7   r   r<   r   r3   r3   r3   r4   <module>   s:   $  ~ ~