o
    j_                     @  s4  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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 ddlmZm Z  ddl!m"Z"m#Z#m$Z$m%Z%m&Z& ddgZ'G 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)UnionOptional)LiteralN   )_legacy_response)	NOT_GIVENBodyQueryHeadersNotGiven)maybe_transformasync_maybe_transform)cached_property)SyncAPIResourceAsyncAPIResource)to_streamed_response_wrapper"async_to_streamed_response_wrapper)SyncCursorPageAsyncCursorPage)AsyncPaginatormake_request_options)FineTuningJobFineTuningJobEventjob_list_paramsjob_create_paramsjob_list_events_paramsJobs	AsyncJobsc                   @     e Zd Zed/ddZed0ddZeeeddded	d1ddZdddedd2d d!Zeeddded"d3d(d)Z	dddedd2d*d+Z
eeddded"d4d-d.ZdS )5r   returnJobsWithRawResponsec                 C     t | S N)r!   self r&   g/var/www/html/fyndo/pharma/fyndo/venv/lib/python3.10/site-packages/openai/resources/fine_tuning/jobs.pywith_raw_response$      zJobs.with_raw_responseJobsWithStreamingResponsec                 C  r"   r#   )r*   r$   r&   r&   r'   with_streaming_response(   r)   zJobs.with_streaming_responseNhyperparameterssuffixvalidation_fileextra_headersextra_query
extra_bodytimeoutmodelBUnion[str, Literal['babbage-002', 'davinci-002', 'gpt-3.5-turbo']]training_filestrr-   ,job_create_params.Hyperparameters | NotGivenr.   Optional[str] | NotGivenr/   r0   Headers | Noner1   Query | Noner2   Body | Noner3   'float | httpx.Timeout | None | NotGivenr   c       	   
   	   C  s2   | j dt|||||dtjt||||	dtdS )	  
        Creates a fine-tuning job which begins the process of creating a new model from
        a given dataset.

        Response includes details of the enqueued job including job status and the name
        of the fine-tuned models once complete.

        [Learn more about fine-tuning](https://platform.openai.com/docs/guides/fine-tuning)

        Args:
          model: The name of the model to fine-tune. You can select one of the
              [supported models](https://platform.openai.com/docs/guides/fine-tuning/what-models-can-be-fine-tuned).

          training_file: The ID of an uploaded file that contains training data.

              See [upload file](https://platform.openai.com/docs/api-reference/files/upload)
              for how to upload a file.

              Your dataset must be formatted as a JSONL file. Additionally, you must upload
              your file with the purpose `fine-tune`.

              See the [fine-tuning guide](https://platform.openai.com/docs/guides/fine-tuning)
              for more details.

          hyperparameters: The hyperparameters used for the fine-tuning job.

          suffix: A string of up to 18 characters that will be added to your fine-tuned model
              name.

              For example, a `suffix` of "custom-model-name" would produce a model name like
              `ft:gpt-3.5-turbo:openai:custom-model-name:7p4lURel`.

          validation_file: The ID of an uploaded file that contains validation data.

              If you provide this file, the data is used to generate validation metrics
              periodically during fine-tuning. These metrics can be viewed in the fine-tuning
              results file. The same data should not be present in both train and validation
              files.

              Your dataset must be formatted as a JSONL file. You must upload your file with
              the purpose `fine-tune`.

              See the [fine-tuning guide](https://platform.openai.com/docs/guides/fine-tuning)
              for more details.

          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
        /fine_tuning/jobsr4   r6   r-   r.   r/   r0   r1   r2   r3   bodyoptionscast_to)_postr   r   JobCreateParamsr   r   
r%   r4   r6   r-   r.   r/   r0   r1   r2   r3   r&   r&   r'   create,   s    D
zJobs.createrA   fine_tuning_job_idc                C  s4   |s	t d|| jd| t||||dtdS )  
        Get info about a fine-tuning job.

        [Learn more about fine-tuning](https://platform.openai.com/docs/guides/fine-tuning)

        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
        AExpected a non-empty value for `fine_tuning_job_id` but received /fine_tuning/jobs/rA   rD   rE   
ValueError_getr   r   r%   rJ   r0   r1   r2   r3   r&   r&   r'   retrieve   s   zJobs.retrieveafterlimitr0   r1   r2   r3   rU   str | NotGivenrV   int | NotGivenSyncCursorPage[FineTuningJob]c                C  2   | j dtt t||||t||dtjdtdS a  
        List your organization's fine-tuning jobs

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

          limit: Number of fine-tuning jobs to retrieve.

          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?   rU   rV   r0   r1   r2   r3   querypagerD   r4   )_get_api_listr   r   r   r   r   JobListParamsr%   rU   rV   r0   r1   r2   r3   r&   r&   r'   list   "   z	Jobs.listc                C  s6   |s	t d|| jd| dt||||dtdS )W  
        Immediately cancel a fine-tune job.

        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
        rL   rM   /cancelrA   rN   rP   rF   r   r   rR   r&   r&   r'   cancel   s   
zJobs.cancel"SyncCursorPage[FineTuningJobEvent]c                C  L   |s	t d|| jd| dtt t||||t||dtjdtdS a  
        Get status updates for a fine-tuning job.

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

          limit: Number of events to retrieve.

          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
        rL   rM   z/eventsr\   r]   r_   )rP   ra   r   r   r   r   r   JobListEventsParamsr%   rJ   rU   rV   r0   r1   r2   r3   r&   r&   r'   list_events   &   
zJobs.list_events)r    r!   )r    r*   r4   r5   r6   r7   r-   r8   r.   r9   r/   r9   r0   r:   r1   r;   r2   r<   r3   r=   r    r   rJ   r7   r0   r:   r1   r;   r2   r<   r3   r=   r    r   )rU   rW   rV   rX   r0   r:   r1   r;   r2   r<   r3   r=   r    rY   )rJ   r7   rU   rW   rV   rX   r0   r:   r1   r;   r2   r<   r3   r=   r    rj   __name__
__module____qualname__r   r(   r+   r   rI   rS   rd   ri   ro   r&   r&   r&   r'   r   #   J    \&5%c                   @  r   )5r   r    AsyncJobsWithRawResponsec                 C  r"   r#   )rx   r$   r&   r&   r'   r(   )  r)   zAsyncJobs.with_raw_responseAsyncJobsWithStreamingResponsec                 C  r"   r#   )ry   r$   r&   r&   r'   r+   -  r)   z!AsyncJobs.with_streaming_responseNr,   r4   r5   r6   r7   r-   r8   r.   r9   r/   r0   r:   r1   r;   r2   r<   r3   r=   r   c       	   
   	     s@   | j dt|||||dtjI dH t||||	dtdI dH S )r>   r?   r@   NrA   rB   )rF   r   r   rG   r   r   rH   r&   r&   r'   rI   1  s"   D
zAsyncJobs.createrA   rJ   c                  s<   |s
t d|| jd| t||||dtdI dH S )rK   rL   rM   rA   rN   NrO   rR   r&   r&   r'   rS     s   zAsyncJobs.retrieverT   rU   rW   rV   rX   =AsyncPaginator[FineTuningJob, AsyncCursorPage[FineTuningJob]]c                C  rZ   r[   )ra   r   r   r   r   r   rb   rc   r&   r&   r'   rd     re   zAsyncJobs.listc                  s>   |s
t d|| jd| dt||||dtdI dH S )rf   rL   rM   rg   rA   rN   Nrh   rR   r&   r&   r'   ri     s   
zAsyncJobs.cancelGAsyncPaginator[FineTuningJobEvent, AsyncCursorPage[FineTuningJobEvent]]c                C  rk   rl   )rP   ra   r   r   r   r   r   rm   rn   r&   r&   r'   ro     rp   zAsyncJobs.list_events)r    rx   )r    ry   rq   rr   )rU   rW   rV   rX   r0   r:   r1   r;   r2   r<   r3   r=   r    rz   )rJ   r7   rU   rW   rV   rX   r0   r:   r1   r;   r2   r<   r3   r=   r    r{   rs   r&   r&   r&   r'   r   (  rw   c                   @     e Zd ZdddZdS )	r!   jobsr   r    Nonec                 C  P   || _ t|j| _t|j| _t|j| _t|j| _t|j| _d S r#   )_jobsr   to_raw_response_wrapperrI   rS   rd   ri   ro   r%   r}   r&   r&   r'   __init__.      
zJobsWithRawResponse.__init__Nr}   r   r    r~   rt   ru   rv   r   r&   r&   r&   r'   r!   -      r!   c                   @  r|   )	rx   r}   r   r    r~   c                 C  r   r#   )r   r   async_to_raw_response_wrapperrI   rS   rd   ri   ro   r   r&   r&   r'   r   C  r   z!AsyncJobsWithRawResponse.__init__Nr}   r   r    r~   r   r&   r&   r&   r'   rx   B  r   rx   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   rI   rS   rd   ri   ro   r   r&   r&   r'   r   X      
z"JobsWithStreamingResponse.__init__Nr   r   r&   r&   r&   r'   r*   W  r   r*   c                   @  r|   )	ry   r}   r   r    r~   c                 C  r   r#   )r   r   rI   rS   rd   ri   ro   r   r&   r&   r'   r   m  r   z'AsyncJobsWithStreamingResponse.__init__Nr   r   r&   r&   r&   r'   ry   l  r   ry   ).
__future__r   typingr   r   typing_extensionsr   httpx r   _typesr   r	   r
   r   r   _utilsr   r   _compatr   	_resourcer   r   	_responser   r   
paginationr   r   _base_clientr   r   types.fine_tuningr   r   r   r   r   __all__r   r   r!   rx   r*   ry   r&   r&   r&   r'   <module>   s0       