o
    ØRWj f  ã                   @  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   úo/home/esfera/Documents/content_generation/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  sN   |s	t d|›�ƒ‚| jtd|d�t|||dœtjƒt||||ddi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   Úbearer_authT©rC   rD   rE   rF   Úsecurity©Ú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.create©rC   rD   rE   rF   Úrun_idr(   c             	   C  óP   |s	t d|›�ƒ‚|st d|›�ƒ‚| jtd||d�t||||ddi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   rc   rV   TrW   ©r[   r\   ©r]   Ú_getr   r"   r(   ©r2   rc   rG   rC   rD   rE   rF   r3   r3   r4   Úretrieve}   ó   û÷zRuns.retrieve©ÚafterÚlimitÚorderÚstatusrC   rD   rE   rF   rp   rq   ú
int | Omitrr   úLiteral['asc', 'desc'] | Omitrs   úJLiteral['queued', 'in_progress', 'completed', 'canceled', 'failed'] | OmitúSyncCursorPage[RunListResponse]c          
      C  óV   |s	t d|›�ƒ‚| jtd|d�tt t||||	t||||dœtjƒddi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   )rp   rq   rr   rs   rV   T)rC   rD   rE   rF   ÚqueryrX   )Úpager[   Úmodel)	r]   Ú_get_api_listr   r   r$   r"   r   r   ÚRunListParams©
r2   rG   rp   rq   rr   rs   rC   rD   rE   rF   r3   r3   r4   Úlist¥   ó,   %
üù	òíz	Runs.listr'   c             	   C  rd   )	á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   rf   rg   rh   rV   TrW   ri   ©r]   Ú_deleter   r"   r'   rl   r3   r3   r4   Údeleteâ   rn   zRuns.deleter%   c             	   C  rd   )	á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   rf   rg   rh   rV   TrW   ri   ©r]   r^   r   r"   r%   rl   r3   r3   r4   Úcancel
  rn   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&   ©rc   rH   rG   rH   rC   rM   rD   rN   rE   rO   rF   rP   r-   r(   )rG   rH   rp   rL   rq   rt   rr   ru   rs   rv   rC   rM   rD   rN   rE   rO   rF   rP   r-   rw   ©rc   rH   rG   rH   rC   rM   rD   rN   rE   rO   rF   rP   r-   r'   ©rc   rH   rG   rH   rC   rM   rD   rN   rE   rO   rF   rP   r-   r%   ©Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r5   r:   r>   r   r   ra   rm   r€   r…   rˆ   r3   r3   r3   r4   r)   %   óN    	ôDö,óDö/öc                	   @  r+   )?r*   r,   r-   r   c                 C  r.   r/   )r   r0   r1   r3   r3   r4   r5   6  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>   E  r?   z!AsyncRuns.with_streaming_responseNr@   rG   rH   rI   rJ   rA   rK   rB   rL   rC   rM   rD   rN   rE   rO   rF   rP   r&   c          	   
   Ã  s\   �|s
t d|›�ƒ‚| jtd|d�t|||dœtjƒI dH t||||ddid�td	�I dH S )
rQ   rR   rS   rT   rU   NrV   TrW   rY   )r]   r^   r   r   r    r_   r"   r&   r`   r3   r3   r4   ra   N  s*   €'
ýúûïzAsyncRuns.createrb   rc   r(   c             	   Ã  óX   �|s
t d|›�ƒ‚|st d|›�ƒ‚| jtd||d�t||||ddid�td�I d	H S )
re   rR   rf   rg   rh   rV   TrW   ri   Nrj   rl   r3   r3   r4   rm   ‹  ó    €û÷zAsyncRuns.retrievero   rp   rq   rt   rr   ru   rs   rv   úAAsyncPaginator[RunListResponse, AsyncCursorPage[RunListResponse]]c          
      C  rx   ry   )	r]   r}   r   r   r$   r"   r   r   r~   r   r3   r3   r4   r€   ³  r�   zAsyncRuns.listr'   c             	   Ã  r•   )
r‚   rR   rf   rg   rh   rV   TrW   ri   Nrƒ   rl   r3   r3   r4   r…   ð  r–   zAsyncRuns.deleter%   c             	   Ã  r•   )
r†   rR   rf   rg   rh   rV   TrW   ri   Nr‡   rl   r3   r3   r4   rˆ     r–   zAsyncRuns.cancel)r-   r   )r-   r“   )r-   r”   r‰   rŠ   )rG   rH   rp   rL   rq   rt   rr   ru   rs   rv   rC   rM   rD   rN   rE   rO   rF   rP   r-   r—   r‹   rŒ   r�   r3   r3   r3   r4   r*   3  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   Úto_raw_response_wrapperra   rm   r€   r…   rˆ   ©r2   r™   r3   r3   r4   Ú__init__B  ó    ÿÿÿÿ
ÿzRunsWithRawResponse.__init__r   c                 C  ó   t | jjƒS r/   )r   r�   r5   r1   r3   r3   r4   r5   U  ó   z RunsWithRawResponse.output_itemsN©r™   r)   r-   rš   )r-   r   ©rŽ   r�   r�   r    r   r5   r3   r3   r3   r4   r7   A  ó    
r7   c                   @  r˜   )r“   r™   r*   r-   rš   c                 C  r›   rœ   )r�   r   Úasync_to_raw_response_wrapperra   rm   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   o  r£   z%AsyncRunsWithRawResponse.output_itemsN©r™   r*   r-   rš   )r-   r   r¥   r3   r3   r3   r4   r“   [  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   ra   rm   r€   r…   rˆ   rŸ   r3   r3   r4   r    v  ó    ÿÿÿÿ
ÿz"RunsWithStreamingResponse.__init__r   c                 C  r¢   r/   )r   r�   r5   r1   r3   r3   r4   r5   ‰  r£   z&RunsWithStreamingResponse.output_itemsNr¤   )r-   r   r¥   r3   r3   r3   r4   r<   u  r¦   r<   c                   @  r˜   )r”   r™   r*   r-   rš   c                 C  r©   rœ   )r�   r   ra   rm   r€   r…   rˆ   rŸ   r3   r3   r4   r    �  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”   �  r¦   r”   )@Ú
__future__r   Útypingr   Útyping_extensionsr   ÚhttpxÚ r   Ú_typesr   r   r	   r
   r   r   r   Ú_utilsr   r   r   Ú_compatr   Ú	_resourcer   r   Ú	_responser   r   r5   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”   r3   r3   r3   r4   Ú<module>   s>   $     