
    qi`                       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Z8 G d de      Z9 G d de      Z: G d d      Z; G d d      Z< G d d       Z= G d! d"      Z>y)#    )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            	      L   e Zd ZdZedd       Zedd       Zedd       Zeeddde	d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ
ddde	d	 	 	 	 	 	 	 	 	 	 	 	 	 dd	Zeeeeddde	d
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZddde	d	 	 	 	 	 	 	 	 	 	 	 	 	 ddZddde	d	 	 	 	 	 	 	 	 	 	 	 	 	 ddZy)r)   ,Manage and run evals in the OpenAI platform.c                ,    t        | j                        S r,   )r   _clientselfs    R/opt/pipecat/venv/lib/python3.12/site-packages/openai/resources/evals/runs/runs.pyoutput_itemszRuns.output_items(   s     4<<((    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
        )RunsWithRawResponser0   s    r2   with_raw_responsezRuns.with_raw_response-   s     #4((r4   c                    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
        )RunsWithStreamingResponser0   s    r2   with_streaming_responsezRuns.with_streaming_response7   s     )..r4   Nmetadatanameextra_headersextra_query
extra_bodytimeoutc          
         |st        d|      | j                  d| dt        |||dt        j                        t        ||||      t              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data_sourcer>   r?   r@   rA   rB   rC   bodyoptionscast_to)
ValueError_postr   r    RunCreateParamsr"   r&   	r1   eval_idrJ   r>   r?   r@   rA   rB   rC   s	            r2   createzRuns.create@   sz    N UV]U`abbzzgYe$ #. ( 
 "11 )+Q[el &  
 	
r4   rK   c          	         |st        d|      |st        d|      | j                  d| d| t        ||||      t              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
        rF   5Expected a non-empty value for `run_id` but received rG   /runs/rK   rN   rO   rP   _getr"   r(   r1   run_idrT   r@   rA   rB   rC   s          r2   retrievezRuns.retrievey   sr    0 UV]U`abbTU[T^_``yygYfVH-(+Q[el (  
 	
r4   afterlimitorderstatusr@   rA   rB   rC   c                   |st        d|      | j                  d| dt        t           t	        ||||	t        ||||dt        j                              t              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
        rF   rG   rH   )ra   rb   rc   rd   )r@   rA   rB   rC   query)pagerN   model)rP   _get_api_listr   r$   r"   r   r   RunListParams
r1   rT   ra   rb   rc   rd   r@   rA   rB   rC   s
             r2   listz	Runs.list   s    J UV]U`abb!!gYe$0(+'%%!&!&!&"(	 $11 "% " 
 	
r4   c          	         |st        d|      |st        d|      | j                  d| d| t        ||||      t              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
        rF   rX   rG   rY   rK   rZ   rP   _deleter"   r'   r]   s          r2   deletezRuns.delete   sr    0 UV]U`abbTU[T^_``||gYfVH-(+Q[el &  
 	
r4   c          	         |st        d|      |st        d|      | j                  d| d| t        ||||      t              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
        rF   rX   rG   rY   rK   rZ   rP   rQ   r"   r%   r]   s          r2   cancelzRuns.cancel   sr    0 UV]U`abbTU[T^_``zzgYfVH-(+Q[el &  
 	
r4   )returnr   )rw   r7   )rw   r;   rT   strrJ   zrun_create_params.DataSourcer>   zOptional[Metadata] | Omitr?   
str | Omitr@   Headers | NonerA   Query | NonerB   Body | NonerC   'float | httpx.Timeout | None | NotGivenrw   r&   r^   ry   rT   ry   r@   r{   rA   r|   rB   r}   rC   r~   rw   r(   )rT   ry   ra   rz   rb   
int | Omitrc   Literal['asc', 'desc'] | Omitrd   JLiteral['queued', 'in_progress', 'completed', 'canceled', 'failed'] | Omitr@   r{   rA   r|   rB   r}   rC   r~   rw   zSyncCursorPage[RunListResponse]r^   ry   rT   ry   r@   r{   rA   r|   rB   r}   rC   r~   rw   r'   r^   ry   rT   ry   r@   r{   rA   r|   rB   r}   rC   r~   rw   r%   __name__
__module____qualname____doc__r   r3   r8   r<   r   r   rU   r_   rm   rr   rv    r4   r2   r)   r)   %   s?   6) ) ) ) / / /3 )-$("&;D7
7
 2	7

 ,7
 7
 &7
 "7
  7
 97
 
7
@ )-$("&;D"
"
 	"
 &"
 ""
  "
 9"
 
"
P ! /3]a )-$("&;D:
:
 	:

 :
 -:
 [:
 &:
 ":
  :
 9:
 
):
F )-$("&;D"
"
 	"
 &"
 ""
  "
 9"
 
"
V )-$("&;D"
"
 	"
 &"
 ""
  "
 9"
 
"
r4   c            	      L   e Zd ZdZedd       Zedd       Zedd       Zeeddde	d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ
ddde	d	 	 	 	 	 	 	 	 	 	 	 	 	 dd	Zeeeeddde	d
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZddde	d	 	 	 	 	 	 	 	 	 	 	 	 	 ddZddde	d	 	 	 	 	 	 	 	 	 	 	 	 	 ddZy)r*   r,   c                ,    t        | j                        S r.   )r   r/   r0   s    r2   r3   zAsyncRuns.output_items%  s      --r4   c                    t        |       S r6   )AsyncRunsWithRawResponser0   s    r2   r8   zAsyncRuns.with_raw_response*  s     (--r4   c                    t        |       S r:   )AsyncRunsWithStreamingResponser0   s    r2   r<   z!AsyncRuns.with_streaming_response4  s     .d33r4   Nr=   c          
        K   |st        d|      | j                  d| dt        |||dt        j                         d{   t        ||||      t               d{   S 7 $7 w)rE   rF   rG   rH   rI   NrK   rL   )rP   rQ   r   r    rR   r"   r&   rS   s	            r2   rU   zAsyncRuns.create=  s     N UV]U`abbZZgYe$,#. ( 
 "11  )+Q[el &   
 
 	

s$   AA-A)
A-$A+%A-+A-rK   c          	        K   |st        d|      |st        d|      | j                  d| d| t        ||||      t               d{   S 7 w)rW   rF   rX   rG   rY   rK   rZ   Nr[   r]   s          r2   r_   zAsyncRuns.retrievev  s     0 UV]U`abbTU[T^_``YYgYfVH-(+Q[el (  
 
 	
 
   AAAAr`   c                   |st        d|      | j                  d| dt        t           t	        ||||	t        ||||dt        j                              t              S rf   )rP   rj   r   r$   r"   r   r   rk   rl   s
             r2   rm   zAsyncRuns.list  s    J UV]U`abb!!gYe$ 1(+'%%!&!&!&"(	 $11 "% " 
 	
r4   c          	        K   |st        d|      |st        d|      | j                  d| d| t        ||||      t               d{   S 7 w)ro   rF   rX   rG   rY   rK   rZ   Nrp   r]   s          r2   rr   zAsyncRuns.delete  s     0 UV]U`abbTU[T^_``\\gYfVH-(+Q[el & " 
 
 	
 
r   c          	        K   |st        d|      |st        d|      | j                  d| d| t        ||||      t               d{   S 7 w)rt   rF   rX   rG   rY   rK   rZ   Nru   r]   s          r2   rv   zAsyncRuns.cancel  s     0 UV]U`abbTU[T^_``ZZgYfVH-(+Q[el &   
 
 	
 
r   )rw   r   )rw   r   )rw   r   rx   r   )rT   ry   ra   rz   rb   r   rc   r   rd   r   r@   r{   rA   r|   rB   r}   rC   r~   rw   zAAsyncPaginator[RunListResponse, AsyncCursorPage[RunListResponse]]r   r   r   r   r4   r2   r*   r*   "  s@   6. . . . 4 4 /3 )-$("&;D7
7
 2	7

 ,7
 7
 &7
 "7
  7
 97
 
7
@ )-$("&;D"
"
 	"
 &"
 ""
  "
 9"
 
"
P ! /3]a )-$("&;D:
:
 	:

 :
 -:
 [:
 &:
 ":
  :
 9:
 
K:
F )-$("&;D"
"
 	"
 &"
 ""
  "
 9"
 
"
V )-$("&;D"
"
 	"
 &"
 ""
  "
 9"
 
"
r4   c                  &    e Zd ZddZedd       Zy)r7   c                z   || _         t        j                  |j                        | _        t        j                  |j                        | _        t        j                  |j
                        | _        t        j                  |j                        | _        t        j                  |j                        | _        y N)_runsr   to_raw_response_wrapperrU   r_   rm   rr   rv   r1   runss     r2   __init__zRunsWithRawResponse.__init__   s    
&>>KK
 )@@MM
 %<<II
	 '>>KK
 '>>KK
r4   c                @    t        | j                  j                        S r.   )r   r   r3   r0   s    r2   r3   z RunsWithRawResponse.output_items3  s     *$***A*ABBr4   Nr   r)   rw   None)rw   r   r   r   r   r   r   r3   r   r4   r2   r7   r7     s    
& C Cr4   r7   c                  &    e Zd ZddZedd       Zy)r   c                z   || _         t        j                  |j                        | _        t        j                  |j                        | _        t        j                  |j
                        | _        t        j                  |j                        | _        t        j                  |j                        | _        y r   )r   r   async_to_raw_response_wrapperrU   r_   rm   rr   rv   r   s     r2   r   z!AsyncRunsWithRawResponse.__init__:  s    
&DDKK
 )FFMM
 %BBII
	 'DDKK
 'DDKK
r4   c                @    t        | j                  j                        S r.   )r   r   r3   r0   s    r2   r3   z%AsyncRunsWithRawResponse.output_itemsM  s     /tzz/F/FGGr4   Nr   r*   rw   r   )rw   r   r   r   r4   r2   r   r   9  s    
& H Hr4   r   c                  &    e Zd ZddZedd       Zy)r;   c                   || _         t        |j                        | _        t        |j                        | _        t        |j                        | _        t        |j
                        | _        t        |j                        | _        y r   )r   r   rU   r_   rm   rr   rv   r   s     r2   r   z"RunsWithStreamingResponse.__init__T  sp    
2KK
 5MM
 1II
	 3KK
 3KK
r4   c                @    t        | j                  j                        S r.   )r   r   r3   r0   s    r2   r3   z&RunsWithStreamingResponse.output_itemsg  s     0

0G0GHHr4   Nr   )rw   r   r   r   r4   r2   r;   r;   S  s    
& I Ir4   r;   c                  &    e Zd ZddZedd       Zy)r   c                   || _         t        |j                        | _        t        |j                        | _        t        |j                        | _        t        |j
                        | _        t        |j                        | _        y r   )r   r   rU   r_   rm   rr   rv   r   s     r2   r   z'AsyncRunsWithStreamingResponse.__init__n  sp    
8KK
 ;MM
 7II
	 9KK
 9KK
r4   c                @    t        | j                  j                        S r.   )r   r   r3   r0   s    r2   r3   z+AsyncRunsWithStreamingResponse.output_items  s     5TZZ5L5LMMr4   Nr   )rw   r   r   r   r4   r2   r   r   m  s    
& N Nr4   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*   r7   r   r;   r   r   r4   r2   <module>r      s    #  %  ! L L L = ' ; Z  ; > A 5 = A A A E;
z
? z
zz
  z
zC C4H H4I I4N Nr4   