o
    ¨Ýj5ž  ã                   @  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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/m0Z0 ddl1m2Z2 ddl3m4Z4 ddl5m6Z6 ddgZ7G dd„ de"ƒZ8G dd„ de#ƒZ9G dd„ dƒZ:G 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)Úpath_templateÚ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dZedAdd„ƒZedBdd„ƒZedCd
d„ƒZeeeeeeeddde	dœdDd(d)„Z
ddde	d*œdEd,d-„Zeeeddde	d.œdFd5d6„Zddde	d*œdEd7d8„Zeeddde	d9œdGd;d<„Zddde	d*œdEd=d>„Zddde	d*œdEd?d@„ZdS )Hr*   úIManage fine-tuning jobs to tailor a model to your specific training data.Úreturnr   c                 C  ó
   t | jƒS ©r-   )r   Ú_client©Úself© r4   úa/var/www/html/chatgpt/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
        )r8   r2   r4   r4   r5   Úwith_raw_response*   ó   zJobs.with_raw_responseÚJobsWithStreamingResponsec                 C  r9   ©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=   r2   r4   r4   r5   Úwith_streaming_response4   ó   zJobs.with_streaming_responseN©ÚhyperparametersÚintegrationsÚmetadataÚmethodÚseedÚsuffixÚvalidation_fileÚextra_headersÚextra_queryÚ
extra_bodyÚtimeoutÚmodelúQUnion[str, Literal['babbage-002', 'davinci-002', 'gpt-3.5-turbo', 'gpt-4o-mini']]Útraining_fileÚstrrB   ú(job_create_params.Hyperparameters | OmitrC   ú8Optional[Iterable[job_create_params.Integration]] | OmitrD   úOptional[Metadata] | OmitrE   újob_create_params.Method | OmitrF   úOptional[int] | OmitrG   úOptional[str] | OmitrH   rI   úHeaders | NonerJ   úQuery | NonerK   úBody | NonerL   ú(float | httpx2.Timeout | None | NotGivenr(   c                C  s@   | j dt|||||||||	dœ	tjƒt|
|||ddi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://developers.openai.com/api/docs/guides/model-optimization)

        Args:
          model: The name of the model to fine-tune. You can select one of the
              [supported models](https://developers.openai.com/api/docs/guides/model-optimization#fine-tuning-methods).

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

              See
              [upload file](https://developers.openai.com/api/reference/resources/files/methods/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://developers.openai.com/api/docs/guides/supervised-fine-tuning#formatting-your-data),
              [completions](https://developers.openai.com/api/docs/guides/supervised-fine-tuning#formatting-your-data)
              format, or if the fine-tuning method uses the
              [preference](https://developers.openai.com/api/docs/guides/direct-preference-optimization)
              format.

              See the
              [fine-tuning guide](https://developers.openai.com/api/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://developers.openai.com/api/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©	rM   rO   rB   rC   rD   rE   rF   rG   rH   Úbearer_authT©rI   rJ   rK   rL   Úsecurity©ÚbodyÚoptionsÚcast_to)Ú_postr   r%   ÚJobCreateParamsr#   r(   ©r3   rM   rO   rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   r4   r4   r5   Úcreate=   s0   b÷ôûézJobs.create©rI   rJ   rK   rL   Úfine_tuning_job_idc             	   C  ó<   |s	t d|›�ƒ‚| jtd|d�t||||ddid�td�S )á¿  
        Get info about a fine-tuning job.

        [Learn more about fine-tuning](https://developers.openai.com/api/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/{fine_tuning_job_id}©rj   r^   Tr_   ©rc   rd   ©Ú
ValueErrorÚ_getr   r#   r(   ©r3   rj   rI   rJ   rK   rL   r4   r4   r5   Úretrieve¹   s   
û÷zJobs.retrieve©ÚafterÚlimitrD   rI   rJ   rK   rL   rw   ú
str | Omitrx   ú
int | OmitúOptional[Dict[str, str]] | OmitúSyncCursorPage[FineTuningJob]c                C  ó:   | j dtt t||||t|||dœtjƒddid�td�S ©aI  
        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`. Omitting
              the parameter or passing an empty object applies no metadata filter. An empty
              value, such as `metadata[k]=`, filters for that key with an empty string value.
              To select jobs with null metadata, send the literal query string
              `metadata=null`. Nullable caller types do not specify how a client serializes
              null for a deep-object parameter. Use a raw query parameter if the client omits
              null. Do not combine the two query forms.

          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\   )rw   rx   rD   r^   T©rI   rJ   rK   rL   Úqueryr`   ©Úpagerc   rM   )Ú_get_api_listr    r(   r#   r   r$   ÚJobListParams©r3   rw   rx   rD   rI   rJ   rK   rL   r4   r4   r5   Úlistà   ó&   %ýúóîz	Jobs.listc             	   C  rk   )á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
        rm   ú-/fine_tuning/jobs/{fine_tuning_job_id}/cancelro   r^   Tr_   rp   ©rr   re   r   r#   r(   rt   r4   r4   r5   Úcancel  ó   
û÷zJobs.cancel©rw   rx   rI   rJ   rK   rL   ú"SyncCursorPage[FineTuningJobEvent]c                C  óR   |s	t d|›�ƒ‚| jtd|d�tt t||||t||dœtjƒddi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
        rm   z-/fine_tuning/jobs/{fine_tuning_job_id}/eventsro   )rw   rx   r^   Tr   r�   )	rr   rƒ   r   r    r)   r#   r   r&   ÚJobListEventsParams©r3   rj   rw   rx   rI   rJ   rK   rL   r4   r4   r5   Úlist_events?  ó(   
þûôïzJobs.list_eventsc             	   C  rk   )á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
        rm   ú,/fine_tuning/jobs/{fine_tuning_job_id}/pausero   r^   Tr_   rp   rŠ   rt   r4   r4   r5   Úpauser  rŒ   z
Jobs.pausec             	   C  rk   )á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
        rm   ú-/fine_tuning/jobs/{fine_tuning_job_id}/resumero   r^   Tr_   rp   rŠ   rt   r4   r4   r5   Úresume—  rŒ   zJobs.resume)r.   r   )r.   r8   )r.   r=   ©rM   rN   rO   rP   rB   rQ   rC   rR   rD   rS   rE   rT   rF   rU   rG   rV   rH   rV   rI   rW   rJ   rX   rK   rY   rL   rZ   r.   r(   ©rj   rP   rI   rW   rJ   rX   rK   rY   rL   rZ   r.   r(   )rw   ry   rx   rz   rD   r{   rI   rW   rJ   rX   rK   rY   rL   rZ   r.   r|   )rj   rP   rw   ry   rx   rz   rI   rW   rJ   rX   rK   rY   rL   rZ   r.   rŽ   ©Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r6   r;   r?   r   r   rh   ru   r†   r‹   r“   r—   rš   r4   r4   r4   r5   r*   "   óp    	ï ÷*õ@÷)õ9÷+÷c                   @  r,   )Hr+   r-   r.   r   c                 C  r/   r0   )r   r1   r2   r4   r4   r5   r6   À  r7   zAsyncJobs.checkpointsÚAsyncJobsWithRawResponsec                 C  r9   r:   )r£   r2   r4   r4   r5   r;   Å  r<   zAsyncJobs.with_raw_responseÚAsyncJobsWithStreamingResponsec                 C  r9   r>   )r¤   r2   r4   r4   r5   r?   Ï  r@   z!AsyncJobs.with_streaming_responseNrA   rM   rN   rO   rP   rB   rQ   rC   rR   rD   rS   rE   rT   rF   rU   rG   rV   rH   rI   rW   rJ   rX   rK   rY   rL   rZ   r(   c                Ã  sN   �| j dt|||||||||	dœ	tjƒI dH t|
|||ddid�td�I dH S )r[   r\   r]   Nr^   Tr_   ra   )re   r   r%   rf   r#   r(   rg   r4   r4   r5   rh   Ø  s2   €b÷ôûézAsyncJobs.createri   rj   c             	   Ã  óD   �|s
t d|›�ƒ‚| jtd|d�t||||ddid�td�I dH S )	rl   rm   rn   ro   r^   Tr_   rp   Nrq   rt   r4   r4   r5   ru   T  s   €
û÷zAsyncJobs.retrieverv   rw   ry   rx   rz   r{   ú=AsyncPaginator[FineTuningJob, AsyncCursorPage[FineTuningJob]]c                C  r}   r~   )rƒ   r!   r(   r#   r   r$   r„   r…   r4   r4   r5   r†   {  r‡   zAsyncJobs.listc             	   Ã  r¥   )	rˆ   rm   r‰   ro   r^   Tr_   rp   NrŠ   rt   r4   r4   r5   r‹   µ  ó   €
û÷zAsyncJobs.cancelr�   úGAsyncPaginator[FineTuningJobEvent, AsyncCursorPage[FineTuningJobEvent]]c                C  r�   r�   )	rr   rƒ   r   r!   r)   r#   r   r&   r‘   r’   r4   r4   r5   r“   Ú  r”   zAsyncJobs.list_eventsc             	   Ã  r¥   )	r•   rm   r–   ro   r^   Tr_   rp   NrŠ   rt   r4   r4   r5   r—     r§   zAsyncJobs.pausec             	   Ã  r¥   )	r˜   rm   r™   ro   r^   Tr_   rp   NrŠ   rt   r4   r4   r5   rš   2  r§   zAsyncJobs.resume)r.   r   )r.   r£   )r.   r¤   r›   rœ   )rw   ry   rx   rz   rD   r{   rI   rW   rJ   rX   rK   rY   rL   rZ   r.   r¦   )rj   rP   rw   ry   rx   rz   rI   rW   rJ   rX   rK   rY   rL   rZ   r.   r¨   r�   r4   r4   r4   r5   r+   ½  r¢   c                   @  ó$   e Zd Zddd„Zeddd	„ƒZd
S )r8   Újobsr*   r.   ÚNonec                 C  ól   || _ t |j¡| _t |j¡| _t |j¡| _t |j¡| _t |j¡| _t |j¡| _t |j	¡| _	d S ©N)
Ú_jobsr	   Zto_raw_response_wrapperrh   ru   r†   r‹   r“   r—   rš   ©r3   rª   r4   r4   r5   Ú__init__Y  ó,   ÿÿÿÿÿÿ
ÿzJobsWithRawResponse.__init__r   c                 C  ó   t | jjƒS r0   )r   r®   r6   r2   r4   r4   r5   r6   r  ó   zJobsWithRawResponse.checkpointsN©rª   r*   r.   r«   )r.   r   ©rž   rŸ   r    r°   r   r6   r4   r4   r4   r5   r8   X  ó    
r8   c                   @  r©   )r£   rª   r+   r.   r«   c                 C  r¬   r­   )
r®   r	   Zasync_to_raw_response_wrapperrh   ru   r†   r‹   r“   r—   rš   r¯   r4   r4   r5   r°   y  r±   z!AsyncJobsWithRawResponse.__init__r   c                 C  r²   r0   )r   r®   r6   r2   r4   r4   r5   r6   ’  r³   z$AsyncJobsWithRawResponse.checkpointsN©rª   r+   r.   r«   )r.   r   rµ   r4   r4   r4   r5   r£   x  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   rh   ru   r†   r‹   r“   r—   rš   r¯   r4   r4   r5   r°   ™  ó,   ÿÿÿÿÿÿ
ÿz"JobsWithStreamingResponse.__init__r   c                 C  r²   r0   )r   r®   r6   r2   r4   r4   r5   r6   ²  r³   z%JobsWithStreamingResponse.checkpointsNr´   )r.   r   rµ   r4   r4   r4   r5   r=   ˜  r¶   r=   c                   @  r©   )r¤   rª   r+   r.   r«   c                 C  r¸   r­   )	r®   r   rh   ru   r†   r‹   r“   r—   rš   r¯   r4   r4   r5   r°   ¹  r¹   z'AsyncJobsWithStreamingResponse.__init__r   c                 C  r²   r0   )r   r®   r6   r2   r4   r4   r5   r6   Ò  r³   z*AsyncJobsWithStreamingResponse.checkpointsNr·   )r.   r   rµ   r4   r4   r4   r5   r¤   ¸  r¶   r¤   )>Ú
__future__r   Útypingr   r   r   r   Ztyping_extensionsr   Zhttpx2Ú r	   Ú_typesr
   r   r   r   r   r   r   Z_utilsr   r   r   Z_compatr   r6   r   r   r   r   r   r   Z	_resourcer   r   Ú	_responser   r   Z
paginationr    r!   Z_base_clientr"   r#   Ztypes.fine_tuningr$   r%   r&   Ztypes.shared_params.metadatar'   Z!types.fine_tuning.fine_tuning_jobr(   Z'types.fine_tuning.fine_tuning_job_eventr)   Ú__all__r*   r+   r8   r£   r=   r¤   r4   r4   r4   r5   Ú<module>   s<   $          