U
    ·ÜŸj%d  ã                   @  s”  d dl mZ d dlmZ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 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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*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)ÚIterableÚOptional)ÚLiteralNé   )Ú_legacy_response)Úeval_list_paramsÚeval_create_paramsÚeval_update_params)Ú	NOT_GIVENÚBodyÚQueryÚHeadersÚNotGiven)Úmaybe_transformÚasync_maybe_transform)Úcached_propertyé   )ÚRunsÚ	AsyncRunsÚRunsWithRawResponseÚAsyncRunsWithRawResponseÚRunsWithStreamingResponseÚAsyncRunsWithStreamingResponse)ÚSyncAPIResourceÚAsyncAPIResource)Úto_streamed_response_wrapperÚ"async_to_streamed_response_wrapper)ÚSyncCursorPageÚAsyncCursorPage)ÚAsyncPaginatorÚmake_request_options)ÚEvalListResponse)ÚEvalCreateResponse)ÚEvalDeleteResponse)ÚEvalUpdateResponse)ÚEvalRetrieveResponse)ÚMetadataÚEvalsÚ
AsyncEvalsc                   @  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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„Z	eeddded œ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,„Zdddedœdddddd-dœd.d/„ZdS )0r(   r   ©Úreturnc                 C  s
   t | jƒS ©N)r   Ú_client©Úself© r0   ú@/tmp/pip-unpacked-wheel-2qj3ofc_/openai/resources/evals/evals.pyÚruns)   s    z
Evals.runsÚEvalsWithRawResponsec                 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
        )r3   r.   r0   r0   r1   Úwith_raw_response-   s    zEvals.with_raw_responseÚEvalsWithStreamingResponsec                 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
        )r6   r.   r0   r0   r1   Úwith_streaming_response7   s    zEvals.with_streaming_responseN©ÚmetadataÚnameÚshare_with_openaiÚextra_headersÚextra_queryÚ
extra_bodyÚtimeoutú#eval_create_params.DataSourceConfigú-Iterable[eval_create_params.TestingCriterion]úOptional[Metadata] | NotGivenústr | NotGivenúbool | NotGivenúHeaders | NoneúQuery | NoneúBody | Noneú'float | httpx.Timeout | None | NotGivenr#   ©
Údata_source_configÚtesting_criteriar:   r;   r<   r=   r>   r?   r@   r+   c       	   
   	   C  s2   | j dt|||||dœtjƒt||||	d�td�S )á–  
        Create the structure of an evaluation that can be used to test a model's
        performance. An evaluation is a set of testing criteria and a datasource. After
        creating an evaluation, you can run it on different models and model parameters.
        We support several types of graders and datasources. For more information, see
        the [Evals guide](https://platform.openai.com/docs/guides/evals).

        Args:
          data_source_config: The configuration for the data source used for the evaluation runs.

          testing_criteria: A list of graders for all eval runs in this group.

          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 evaluation.

          share_with_openai: Indicates whether the evaluation is shared with OpenAI.

          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
        ú/evals©rK   rL   r:   r;   r<   ©r=   r>   r?   r@   ©ÚbodyÚoptionsÚcast_to)Ú_postr   r	   ÚEvalCreateParamsr!   r#   ©
r/   rK   rL   r:   r;   r<   r=   r>   r?   r@   r0   r0   r1   Úcreate@   s&    .ûø
   ÿñzEvals.createrP   Ústrr&   ©Úeval_idr=   r>   r?   r@   r+   c                C  s4   |st d|›�ƒ‚| jd|› �t||||d�td�S )áL  
        Get an evaluation 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
        ú6Expected a non-empty value for `eval_id` but received ú/evals/rP   ©rS   rT   ©Ú
ValueErrorÚ_getr!   r&   ©r/   r[   r=   r>   r?   r@   r0   r0   r1   Úretrieve€   s       ÿûzEvals.retrieve©r:   r;   r=   r>   r?   r@   r%   ©r[   r:   r;   r=   r>   r?   r@   r+   c             	   C  sD   |st d|›�ƒ‚| jd|› �t||dœtjƒt||||d�td�S )á  
        Update certain properties of an evaluation.

        Args:
          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: Rename the evaluation.

          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
        r]   r^   ©r:   r;   rP   rQ   )ra   rU   r   r
   ÚEvalUpdateParamsr!   r%   ©r/   r[   r:   r;   r=   r>   r?   r@   r0   r0   r1   Úupdate¡   s$    "þû   ÿôzEvals.update©ÚafterÚlimitÚorderÚorder_byr=   r>   r?   r@   úint | NotGivenú#Literal[('asc', 'desc')] | NotGivenú0Literal[('created_at', 'updated_at')] | NotGivenz SyncCursorPage[EvalListResponse]©	rm   rn   ro   rp   r=   r>   r?   r@   r+   c          	      C  s6   | j dtt t||||t||||dœtjƒd�td�S ©a  
        List evaluations for a project.

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

          limit: Number of evals to retrieve.

          order: Sort order for evals by timestamp. Use `asc` for ascending order or `desc` for
              descending order.

          order_by: Evals can be ordered by creation time or last updated time. Use `created_at` for
              creation time or `updated_at` for last updated time.

          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
        rN   )rm   rn   ro   rp   )r=   r>   r?   r@   Úquery)ÚpagerS   Úmodel)Ú_get_api_listr   r"   r!   r   r   ÚEvalListParams©	r/   rm   rn   ro   rp   r=   r>   r?   r@   r0   r0   r1   ÚlistÔ   s&    $üùûîz
Evals.listr$   c                C  s4   |st d|›�ƒ‚| jd|› �t||||d�td�S )áI  
        Delete an evaluation.

        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
        r]   r^   rP   r_   ©ra   Ú_deleter!   r$   rc   r0   r0   r1   Údelete  s       ÿûzEvals.delete©Ú__name__Ú
__module__Ú__qualname__r   r2   r5   r8   r   rX   rd   rk   r|   r€   r0   r0   r0   r1   r(   (   sP   	ó$F÷%õ 6ô"?÷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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„Z	eeddded œ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,„Zdddedœdddddd-dœd.d/„ZdS )0r)   r   r*   c                 C  s
   t | jƒS r,   )r   r-   r.   r0   r0   r1   r2   0  s    zAsyncEvals.runsÚAsyncEvalsWithRawResponsec                 C  s   t | ƒS r4   )r…   r.   r0   r0   r1   r5   4  s    zAsyncEvals.with_raw_responseÚAsyncEvalsWithStreamingResponsec                 C  s   t | ƒS r7   )r†   r.   r0   r0   r1   r8   >  s    z"AsyncEvals.with_streaming_responseNr9   rA   rB   rC   rD   rE   rF   rG   rH   rI   r#   rJ   c       	   
   	   Ã  s>   | j dt|||||dœtjƒI dH t||||	d�td�I dH S )rM   rN   rO   NrP   rQ   )rU   r   r	   rV   r!   r#   rW   r0   r0   r1   rX   G  s&    .ûø
   ÿñzAsyncEvals.createrP   rY   r&   rZ   c                Ã  s:   |st d|›�ƒ‚| jd|› �t||||d�td�I dH S )r\   r]   r^   rP   r_   Nr`   rc   r0   r0   r1   rd   ‡  s       ÿûzAsyncEvals.retrievere   r%   rf   c             	   Ã  sP   |st d|›�ƒ‚| jd|› �t||dœtjƒI dH t||||d�td�I dH S )rg   r]   r^   rh   NrP   rQ   )ra   rU   r   r
   ri   r!   r%   rj   r0   r0   r1   rk   ¨  s$    "þû   ÿôzAsyncEvals.updaterl   rq   rr   rs   zCAsyncPaginator[EvalListResponse, AsyncCursorPage[EvalListResponse]]rt   c          	      C  s6   | j dtt t||||t||||dœtjƒd�td�S ru   )ry   r   r"   r!   r   r   rz   r{   r0   r0   r1   r|   Û  s&    $üùûîzAsyncEvals.listr$   c                Ã  s:   |st d|›�ƒ‚| jd|› �t||||d�td�I dH S )r}   r]   r^   rP   r_   Nr~   rc   r0   r0   r1   r€     s       ÿûzAsyncEvals.deleter�   r0   r0   r0   r1   r)   /  sP   	ó$F÷%õ 6ô"?÷c                   @  s.   e Zd Zdddœdd„Zeddœdd	„ƒZd
S )r3   r(   ÚNone©Úevalsr+   c                 C  sP   || _ t |j¡| _t |j¡| _t |j¡| _t |j¡| _t |j¡| _d S r,   )Ú_evalsr   Zto_raw_response_wrapperrX   rd   rk   r|   r€   ©r/   r‰   r0   r0   r1   Ú__init__7  s     ÿÿÿÿÿzEvalsWithRawResponse.__init__r   r*   c                 C  s   t | jjƒS r,   )r   rŠ   r2   r.   r0   r0   r1   r2   J  s    zEvalsWithRawResponse.runsN©r‚   rƒ   r„   rŒ   r   r2   r0   r0   r0   r1   r3   6  s   r3   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_wrapperrX   rd   rk   r|   r€   r‹   r0   r0   r1   rŒ   P  s     ÿÿÿÿÿz"AsyncEvalsWithRawResponse.__init__r   r*   c                 C  s   t | jjƒS r,   )r   rŠ   r2   r.   r0   r0   r1   r2   c  s    zAsyncEvalsWithRawResponse.runsNr�   r0   r0   r0   r1   r…   O  s   r…   c                   @  s.   e Zd Zdddœdd„Zeddœdd	„ƒZd
S )r6   r(   r‡   rˆ   c                 C  sF   || _ t|jƒ| _t|jƒ| _t|jƒ| _t|jƒ| _t|jƒ| _d S r,   )rŠ   r   rX   rd   rk   r|   r€   r‹   r0   r0   r1   rŒ   i  s     ÿÿÿÿÿz#EvalsWithStreamingResponse.__init__r   r*   c                 C  s   t | jjƒS r,   )r   rŠ   r2   r.   r0   r0   r1   r2   |  s    zEvalsWithStreamingResponse.runsNr�   r0   r0   r0   r1   r6   h  s   r6   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   rX   rd   rk   r|   r€   r‹   r0   r0   r1   rŒ   ‚  s     ÿÿÿÿÿz(AsyncEvalsWithStreamingResponse.__init__r   r*   c                 C  s   t | jjƒS r,   )r   rŠ   r2   r.   r0   r0   r1   r2   •  s    z$AsyncEvalsWithStreamingResponse.runsNr�   r0   r0   r0   r1   r†   �  s   r†   )?Ú
__future__r   Útypingr   r   Útyping_extensionsr   ZhttpxÚ r   Útypesr   r	   r
   Ú_typesr   r   r   r   r   Ú_utilsr   r   Ú_compatr   Z	runs.runsr   r   r   r   r   r   Z	_resourcer   r   Ú	_responser   r   Z
paginationr   r   Z_base_clientr    r!   Ztypes.eval_list_responser"   Ztypes.eval_create_responser#   Ztypes.eval_delete_responser$   Ztypes.eval_update_responser%   Ztypes.eval_retrieve_responser&   Ztypes.shared_params.metadatar'   Ú__all__r(   r)   r3   r…   r6   r†   r0   r0   r0   r1   Ú<module>   s<      	  	