o
    {$fnk                     @  sh  d dl mZ d dlmZ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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*m+Z+m,Z, ddl-m.Z. ddl/m0Z0 ddgZ1G dd deZ2G dd deZ3G dd dZ4G dd dZ5G dd dZ6G dd dZ7dS )    )annotations)UnionIterableOptional)LiteralN   )_legacy_response)	NOT_GIVENBodyQueryHeadersNotGiven)maybe_transformasync_maybe_transform)cached_property   )CheckpointsAsyncCheckpointsCheckpointsWithRawResponseAsyncCheckpointsWithRawResponse CheckpointsWithStreamingResponse%AsyncCheckpointsWithStreamingResponse)SyncAPIResourceAsyncAPIResource)to_streamed_response_wrapper"async_to_streamed_response_wrapper)SyncCursorPageAsyncCursorPage)AsyncPaginatormake_request_options)job_list_paramsjob_create_paramsjob_list_events_params)FineTuningJob)FineTuningJobEventJobs	AsyncJobsc                
   @     e Zd Zed6ddZed7ddZed8d	d
Zeeeeeddded	d9d#d$Zddded%d:d'd(Z	eeddded)d;d/d0Z
ddded%d:d1d2Zeeddded)d<d4d5ZdS )=r%   returnr   c                 C  
   t | jS N)r   _clientself r.   \/var/www/html/dev/env/lib/python3.10/site-packages/openai/resources/fine_tuning/jobs/jobs.pycheckpoints(      
zJobs.checkpointsJobsWithRawResponsec                 C     t | S r*   )r2   r,   r.   r.   r/   with_raw_response,      zJobs.with_raw_responseJobsWithStreamingResponsec                 C  r3   r*   )r6   r,   r.   r.   r/   with_streaming_response0   r5   zJobs.with_streaming_responseN	hyperparametersintegrationsseedsuffixvalidation_fileextra_headersextra_query
extra_bodytimeoutmodelQUnion[str, Literal['babbage-002', 'davinci-002', 'gpt-3.5-turbo', 'gpt-4o-mini']]training_filestrr9   ,job_create_params.Hyperparameters | NotGivenr:   <Optional[Iterable[job_create_params.Integration]] | NotGivenr;   Optional[int] | NotGivenr<   Optional[str] | NotGivenr=   r>   Headers | Noner?   Query | Noner@   Body | NonerA   'float | httpx.Timeout | None | NotGivenr#   c                C  s6   | 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/which-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/create)
              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`.

              The contents of the file should differ depending on if the model uses the
              [chat](https://platform.openai.com/docs/api-reference/fine-tuning/chat-input) or
              [completions](https://platform.openai.com/docs/api-reference/fine-tuning/completions-input)
              format.

              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.

          integrations: A list of integrations to enable for your fine-tuning job.

          seed: The seed controls the reproducibility of the job. Passing in the same seed and
              job parameters should produce the same results, but may differ in rare cases. If
              a seed is not specified, one will be generated for you.

          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-4o-mini: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rB   rD   r9   r:   r;   r<   r=   r>   r?   r@   rA   bodyoptionscast_to)_postr   r!   JobCreateParamsr   r#   r-   rB   rD   r9   r:   r;   r<   r=   r>   r?   r@   rA   r.   r.   r/   create4   s$   Q	zJobs.createrQ   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/rQ   rT   rU   
ValueError_getr   r#   r-   rZ   r>   r?   r@   rA   r.   r.   r/   retrieve   s   zJobs.retrieveafterlimitr>   r?   r@   rA   re   str | NotGivenrf   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
        rO   re   rf   r>   r?   r@   rA   querypagerT   rB   )_get_api_listr   r#   r   r   r    JobListParamsr-   re   rf   r>   r?   r@   rA   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
        r\   r]   /cancelrQ   r^   r`   rV   r   r#   rb   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
        r\   r]   z/eventsrl   rm   ro   )r`   rq   r   r$   r   r   r"   JobListEventsParamsr-   rZ   re   rf   r>   r?   r@   rA   r.   r.   r/   list_events  &   
zJobs.list_events)r(   r   )r(   r2   )r(   r6   rB   rC   rD   rE   r9   rF   r:   rG   r;   rH   r<   rI   r=   rI   r>   rJ   r?   rK   r@   rL   rA   rM   r(   r#   rZ   rE   r>   rJ   r?   rK   r@   rL   rA   rM   r(   r#   )re   rg   rf   rh   r>   rJ   r?   rK   r@   rL   rA   rM   r(   ri   )rZ   rE   re   rg   rf   rh   r>   rJ   r?   rK   r@   rL   rA   rM   r(   rz   __name__
__module____qualname__r   r0   r4   r7   r	   rY   rc   rt   ry   r   r.   r.   r.   r/   r%   '   R    k&5%c                
   @  r'   )=r&   r(   r   c                 C  r)   r*   )r   r+   r,   r.   r.   r/   r0   @  r1   zAsyncJobs.checkpointsAsyncJobsWithRawResponsec                 C  r3   r*   )r   r,   r.   r.   r/   r4   D  r5   zAsyncJobs.with_raw_responseAsyncJobsWithStreamingResponsec                 C  r3   r*   )r   r,   r.   r.   r/   r7   H  r5   z!AsyncJobs.with_streaming_responseNr8   rB   rC   rD   rE   r9   rF   r:   rG   r;   rH   r<   rI   r=   r>   rJ   r?   rK   r@   rL   rA   rM   r#   c                  sD   | j dt|||||||dtjI dH t||	|
|dtdI dH S )rN   rO   rP   NrQ   rR   )rV   r   r!   rW   r   r#   rX   r.   r.   r/   rY   L  s&   Q	zAsyncJobs.createrQ   rZ   c                  s<   |s
t d|| jd| t||||dtdI dH S )r[   r\   r]   rQ   r^   Nr_   rb   r.   r.   r/   rc     s   zAsyncJobs.retrieverd   re   rg   rf   rh   =AsyncPaginator[FineTuningJob, AsyncCursorPage[FineTuningJob]]c                C  rj   rk   )rq   r   r#   r   r   r    rr   rs   r.   r.   r/   rt     ru   zAsyncJobs.listc                  s>   |s
t d|| jd| dt||||dtdI dH S )rv   r\   r]   rw   rQ   r^   Nrx   rb   r.   r.   r/   ry     s   
zAsyncJobs.cancelGAsyncPaginator[FineTuningJobEvent, AsyncCursorPage[FineTuningJobEvent]]c                C  r{   r|   )r`   rq   r   r$   r   r   r"   r}   r~   r.   r.   r/   r   $  r   zAsyncJobs.list_events)r(   r   )r(   r   )r(   r   r   r   )re   rg   rf   rh   r>   rJ   r?   rK   r@   rL   rA   rM   r(   r   )rZ   rE   re   rg   rf   rh   r>   rJ   r?   rK   r@   rL   rA   rM   r(   r   r   r.   r.   r.   r/   r&   ?  r   c                   @  $   e Zd ZdddZeddd	Zd
S )r2   jobsr%   r(   Nonec                 C  P   || _ t|j| _t|j| _t|j| _t|j| _t|j| _d S r*   )_jobsr   to_raw_response_wrapperrY   rc   rt   ry   r   r-   r   r.   r.   r/   __init__X      
zJobsWithRawResponse.__init__r   c                 C     t | jjS r*   )r   r   r0   r,   r.   r.   r/   r0   k     zJobsWithRawResponse.checkpointsNr   r%   r(   r   )r(   r   r   r   r   r   r   r0   r.   r.   r.   r/   r2   W      
r2   c                   @  r   )r   r   r&   r(   r   c                 C  r   r*   )r   r   async_to_raw_response_wrapperrY   rc   rt   ry   r   r   r.   r.   r/   r   q  r   z!AsyncJobsWithRawResponse.__init__r   c                 C  r   r*   )r   r   r0   r,   r.   r.   r/   r0     r   z$AsyncJobsWithRawResponse.checkpointsNr   r&   r(   r   )r(   r   r   r.   r.   r.   r/   r   p  r   r   c                   @  r   )r6   r   r%   r(   r   c                 C  F   || _ t|j| _t|j| _t|j| _t|j| _t|j| _d S r*   )r   r   rY   rc   rt   ry   r   r   r.   r.   r/   r         
z"JobsWithStreamingResponse.__init__r   c                 C  r   r*   )r   r   r0   r,   r.   r.   r/   r0     r   z%JobsWithStreamingResponse.checkpointsNr   )r(   r   r   r.   r.   r.   r/   r6     r   r6   c                   @  r   )r   r   r&   r(   r   c                 C  r   r*   )r   r   rY   rc   rt   ry   r   r   r.   r.   r/   r     r   z'AsyncJobsWithStreamingResponse.__init__r   c                 C  r   r*   )r   r   r0   r,   r.   r.   r/   r0     r   z*AsyncJobsWithStreamingResponse.checkpointsNr   )r(   r   r   r.   r.   r.   r/   r     r   r   )8
__future__r   typingr   r   r   typing_extensionsr   httpx r   _typesr	   r
   r   r   r   _utilsr   r   _compatr   r0   r   r   r   r   r   r   	_resourcer   r   	_responser   r   
paginationr   r   _base_clientr   r   types.fine_tuningr    r!   r"   !types.fine_tuning.fine_tuning_jobr#   'types.fine_tuning.fine_tuning_job_eventr$   __all__r%   r&   r2   r   r6   r   r.   r.   r.   r/   <module>   s6        