o
    $i                     @  s  d dl mZ d dlmZ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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l0m1Z1 ddl2m3Z3 ddl4m5Z5 ddgZ6G dd de!Z7G dd de"Z8G dd dZ9G dd dZ:G dd dZ;G dd dZ<dS )     )annotations)DictUnionIterableOptional)LiteralN   )_legacy_response)BodyOmitQueryHeadersNotGivenomit	not_given)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)Metadata)FineTuningJob)FineTuningJobEventJobs	AsyncJobsc                   @     e Zd Zed@ddZedAddZedBd	d
ZeeeeeeedddeddCd'd(Z	ddded)dDd+d,Z
eeeddded-dEd4d5Zddded)dDd6d7Zeeddded8dFd:d;Zddded)dDd<d=Zddded)dDd>d?ZdS )Gr)   returnr   c                 C  
   t | jS N)r   _clientself r2   f/var/www/html/flask_server/venv/lib/python3.10/site-packages/openai/resources/fine_tuning/jobs/jobs.pycheckpoints&      
zJobs.checkpointsJobsWithRawResponsec                 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
        )r6   r0   r2   r2   r3   with_raw_response*      zJobs.with_raw_responseJobsWithStreamingResponsec                 C  r7   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;   r0   r2   r2   r3   with_streaming_response4      zJobs.with_streaming_responseNhyperparametersintegrationsmetadatamethod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strr@   (job_create_params.Hyperparameters | OmitrA   8Optional[Iterable[job_create_params.Integration]] | OmitrB   Optional[Metadata] | OmitrC   job_create_params.Method | OmitrD   Optional[int] | OmitrE   Optional[str] | OmitrF   rG   Headers | NonerH   Query | NonerI   Body | NonerJ   'float | httpx.Timeout | None | NotGivenr'   c                C  s:   | 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/model-optimization)

        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),
              [completions](https://platform.openai.com/docs/api-reference/fine-tuning/completions-input)
              format, or if the fine-tuning method uses the
              [preference](https://platform.openai.com/docs/api-reference/fine-tuning/preference-input)
              format.

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

          hyperparameters: The hyperparameters used for the fine-tuning job. This value is now deprecated
              in favor of `method`, and should be passed in under the `method` parameter.

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

          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.

          method: The method used for fine-tuning.

          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 64 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/model-optimization)
              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	rK   rM   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   bodyoptionscast_to)_postr   r$   JobCreateParamsr"   r'   r1   rK   rM   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   r2   r2   r3   create=   s(   azJobs.creater\   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/model-optimization)

        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/r\   r_   r`   
ValueError_getr"   r'   r1   re   rG   rH   rI   rJ   r2   r2   r3   retrieve   s   zJobs.retrieveafterlimitrB   rG   rH   rI   rJ   rp   
str | Omitrq   
int | OmitOptional[Dict[str, str]] | OmitSyncCursorPage[FineTuningJob]c                C  4   | 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.

          metadata: Optional metadata filter. To filter, use the syntax `metadata[k]=v`.
              Alternatively, set `metadata=null` to indicate no metadata.

          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
        rZ   )rp   rq   rB   rG   rH   rI   rJ   querypager_   rK   )_get_api_listr   r'   r"   r   r#   JobListParamsr1   rp   rq   rB   rG   rH   rI   rJ   r2   r2   r3   list   $    z	Jobs.listc                C  6   |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
        rg   rh   /cancelr\   ri   rk   ra   r"   r'   rm   r2   r2   r3   cancel     
zJobs.cancelrp   rq   rG   rH   rI   rJ   "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
        rg   rh   z/events)rp   rq   rx   rz   )rk   r|   r   r(   r"   r   r%   JobListEventsParamsr1   re   rp   rq   rG   rH   rI   rJ   r2   r2   r3   list_events,  &   
zJobs.list_eventsc                C  r   )J  
        Pause 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
        rg   rh   /pauser\   ri   r   rm   r2   r2   r3   pause^  r   z
Jobs.pausec                C  r   )K  
        Resume 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
        rg   rh   /resumer\   ri   r   rm   r2   r2   r3   resume  r   zJobs.resume)r,   r   )r,   r6   )r,   r;   rK   rL   rM   rN   r@   rO   rA   rP   rB   rQ   rC   rR   rD   rS   rE   rT   rF   rT   rG   rU   rH   rV   rI   rW   rJ   rX   r,   r'   re   rN   rG   rU   rH   rV   rI   rW   rJ   rX   r,   r'   )rp   rr   rq   rs   rB   rt   rG   rU   rH   rV   rI   rW   rJ   rX   r,   ru   )re   rN   rp   rr   rq   rs   rG   rU   rH   rV   rI   rW   rJ   rX   r,   r   __name__
__module____qualname__r   r4   r9   r=   r   r   rd   rn   r   r   r   r   r   r2   r2   r2   r3   r)   %   l    	}&:%8'c                   @  r+   )Gr*   r,   r   c                 C  r-   r.   )r   r/   r0   r2   r2   r3   r4     r5   zAsyncJobs.checkpointsAsyncJobsWithRawResponsec                 C  r7   r8   )r   r0   r2   r2   r3   r9     r:   zAsyncJobs.with_raw_responseAsyncJobsWithStreamingResponsec                 C  r7   r<   )r   r0   r2   r2   r3   r=     r>   z!AsyncJobs.with_streaming_responseNr?   rK   rL   rM   rN   r@   rO   rA   rP   rB   rQ   rC   rR   rD   rS   rE   rT   rF   rG   rU   rH   rV   rI   rW   rJ   rX   r'   c                  sH   | j dt|||||||||	d	tjI dH t|
|||dtdI dH S )rY   rZ   r[   Nr\   r]   )ra   r   r$   rb   r"   r'   rc   r2   r2   r3   rd     s*   azAsyncJobs.creater\   re   c                  s<   |s
t d|| jd| t||||dtdI dH S )rf   rg   rh   r\   ri   Nrj   rm   r2   r2   r3   rn   0  s   zAsyncJobs.retrievero   rp   rr   rq   rs   rt   =AsyncPaginator[FineTuningJob, AsyncCursorPage[FineTuningJob]]c                C  rv   rw   )r|   r    r'   r"   r   r#   r}   r~   r2   r2   r3   r   S  r   zAsyncJobs.listc                  >   |s
t d|| jd| dt||||dtdI dH S )r   rg   rh   r   r\   ri   Nr   rm   r2   r2   r3   r        
zAsyncJobs.cancelr   GAsyncPaginator[FineTuningJobEvent, AsyncCursorPage[FineTuningJobEvent]]c                C  r   r   )rk   r|   r    r(   r"   r   r%   r   r   r2   r2   r3   r     r   zAsyncJobs.list_eventsc                  r   )r   rg   rh   r   r\   ri   Nr   rm   r2   r2   r3   r     r   zAsyncJobs.pausec                  r   )r   rg   rh   r   r\   ri   Nr   rm   r2   r2   r3   r     r   zAsyncJobs.resume)r,   r   )r,   r   )r,   r   r   r   )rp   rr   rq   rs   rB   rt   rG   rU   rH   rV   rI   rW   rJ   rX   r,   r   )re   rN   rp   rr   rq   rs   rG   rU   rH   rV   rI   rW   rJ   rX   r,   r   r   r2   r2   r2   r3   r*     r   c                   @  $   e Zd ZdddZeddd	Zd
S )r6   jobsr)   r,   Nonec                 C  l   || _ t|j| _t|j| _t|j| _t|j| _t|j| _t|j| _t|j	| _	d S r.   )
_jobsr	   to_raw_response_wrapperrd   rn   r   r   r   r   r   r1   r   r2   r2   r3   __init__  ,   
zJobsWithRawResponse.__init__r   c                 C     t | jjS r.   )r   r   r4   r0   r2   r2   r3   r4   7     zJobsWithRawResponse.checkpointsNr   r)   r,   r   )r,   r   r   r   r   r   r   r4   r2   r2   r2   r3   r6         
r6   c                   @  r   )r   r   r*   r,   r   c                 C  r   r.   )
r   r	   async_to_raw_response_wrapperrd   rn   r   r   r   r   r   r   r2   r2   r3   r   =  r   z!AsyncJobsWithRawResponse.__init__r   c                 C  r   r.   )r   r   r4   r0   r2   r2   r3   r4   V  r   z$AsyncJobsWithRawResponse.checkpointsNr   r*   r,   r   )r,   r   r   r2   r2   r2   r3   r   <  r   r   c                   @  r   )r;   r   r)   r,   r   c                 C  ^   || _ t|j| _t|j| _t|j| _t|j| _t|j| _t|j| _t|j| _d S r.   )	r   r   rd   rn   r   r   r   r   r   r   r2   r2   r3   r   \  ,   
z"JobsWithStreamingResponse.__init__r   c                 C  r   r.   )r   r   r4   r0   r2   r2   r3   r4   u  r   z%JobsWithStreamingResponse.checkpointsNr   )r,   r   r   r2   r2   r2   r3   r;   [  r   r;   c                   @  r   )r   r   r*   r,   r   c                 C  r   r.   )	r   r   rd   rn   r   r   r   r   r   r   r2   r2   r3   r   {  r   z'AsyncJobsWithStreamingResponse.__init__r   c                 C  r   r.   )r   r   r4   r0   r2   r2   r3   r4     r   z*AsyncJobsWithStreamingResponse.checkpointsNr   )r,   r   r   r2   r2   r2   r3   r   z  r   r   )=
__future__r   typingr   r   r   r   typing_extensionsr   httpx r	   _typesr
   r   r   r   r   r   r   _utilsr   r   _compatr   r4   r   r   r   r   r   r   	_resourcer   r   	_responser   r   
paginationr   r    _base_clientr!   r"   types.fine_tuningr#   r$   r%   types.shared_params.metadatar&   !types.fine_tuning.fine_tuning_jobr'   'types.fine_tuning.fine_tuning_job_eventr(   __all__r)   r*   r6   r   r;   r   r2   r2   r2   r3   <module>   s8   $   ~  ~