
    +hU                    ,   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
mZmZ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" erddl#m$Z$m%Z% ddgZ& G d de      Z' G d de      Z( G d d      Z) G d d      Z*y)    )annotations)TYPE_CHECKINGUnionOptional)LiteralN   )	NOT_GIVENBodyQueryHeadersNotGiven)maybe_transform)SyncAPIResourceAsyncAPIResource)to_raw_response_wrapperasync_to_raw_response_wrapper)SyncCursorPageAsyncCursorPage)AsyncPaginatormake_request_options)FineTuningJobFineTuningJobEventjob_list_paramsjob_create_paramsjob_list_events_params)OpenAIAsyncOpenAIJobs	AsyncJobsc                  (    e Zd ZU ded<   d fdZeeeddded	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZddded	 	 	 	 	 	 	 	 	 	 	 ddZeeddded		 	 	 	 	 	 	 	 	 	 	 	 	 dd
Zddded	 	 	 	 	 	 	 	 	 	 	 ddZ	eeddded		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ
 xZS )r   JobsWithRawResponsewith_raw_responsec                D    t         |   |       t        |       | _        y N)super__init__r!   r"   selfclient	__class__s     T/var/www/html/venv/lib/python3.12/site-packages/openai/resources/fine_tuning/jobs.pyr&   zJobs.__init__!   s     !4T!:    Nhyperparameterssuffixvalidation_fileextra_headersextra_query
extra_bodytimeoutc       	            | j                  dt        |||||dt        j                        t	        ||||	      t
              S )  
        Creates a job that fine-tunes a specified 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modeltraining_filer.   r/   r0   r1   r2   r3   r4   bodyoptionscast_to_postr   r   JobCreateParamsr   r   
r(   r9   r:   r.   r/   r0   r1   r2   r3   r4   s
             r+   createzJobs.create%   s_    F zz "%2'6$'6 "11	 )+Q[el "  
 	
r,   r;   c          	     R    | j                  d| t        ||||      t              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
        /fine_tuning/jobs/r;   r>   r?   _getr   r   r(   fine_tuning_job_idr1   r2   r3   r4   s         r+   retrievezJobs.retrievez   s>    2 yy !3 45(+Q[el "  
 	
r,   afterlimitr1   r2   r3   r4   c                   | j                  dt        t           t        ||||t	        ||dt
        j                              t              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
        r7   rO   rP   r1   r2   r3   r4   querypager>   r9   )_get_api_listr   r   r   r   r   JobListParamsr(   rO   rP   r1   r2   r3   r4   s          r+   listz	Jobs.list   s^    8 !!.(+'%%!&!& $11  ! " 
 	
r,   c          	     T    | j                  d| dt        ||||      t              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   /cancelr;   rH   rA   r   r   rK   s         r+   cancelzJobs.cancel   s@    . zz !3 4G<(+Q[el "  
 	
r,   c                   | j                  d| dt        t           t        ||||t	        ||dt
        j                              t              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   z/eventsrS   rT   rV   )rX   r   r   r   r   r   JobListEventsParamsr(   rL   rO   rP   r1   r2   r3   r4   s           r+   list_eventszJobs.list_events   sj    : !! !3 4G< 23(+'%%!&!& +>> %! " 
 	
r,   )r)   r   returnNoner9   zBUnion[str, Literal['babbage-002', 'davinci-002', 'gpt-3.5-turbo']]r:   strr.   z,job_create_params.Hyperparameters | NotGivenr/   Optional[str] | NotGivenr0   rj   r1   Headers | Noner2   Query | Noner3   Body | Noner4   'float | httpx.Timeout | None | NotGivenrf   r   rL   ri   r1   rk   r2   rl   r3   rm   r4   rn   rf   r   )rO   str | NotGivenrP   int | NotGivenr1   rk   r2   rl   r3   rm   r4   rn   rf   zSyncCursorPage[FineTuningJob])rL   ri   rO   rp   rP   rq   r1   rk   r2   rl   r3   rm   r4   rn   rf   z"SyncCursorPage[FineTuningJobEvent]__name__
__module____qualname____annotations__r&   r	   rD   rM   r[   r`   re   __classcell__r*   s   @r+   r   r      s   **; IR+44= )-$("&;DS
 RS
 	S

 FS
 )S
 2S
 &S
 "S
  S
 9S
 
S
v )-$("&;D

 &
 "
  
 9
 

H !* ) )-$("&;D-
 -
 	-
 &-
 "-
  -
 9-
 
'-
j )-$("&;D

 &
 "
  
 9
 

F !* ) )-$("&;D.
.
 	.

 .
 &.
 ".
  .
 9.
 
,.
r,   c                  (    e Zd ZU ded<   d fdZeeeddded	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZddded	 	 	 	 	 	 	 	 	 	 	 ddZeeddded		 	 	 	 	 	 	 	 	 	 	 	 	 dd
Zddded	 	 	 	 	 	 	 	 	 	 	 ddZ	eeddded		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ
 xZS )r   AsyncJobsWithRawResponser"   c                D    t         |   |       t        |       | _        y r$   )r%   r&   rz   r"   r'   s     r+   r&   zAsyncJobs.__init__  s     !9$!?r,   Nr-   c       	           K   | j                  dt        |||||dt        j                        t	        ||||	      t
               d{   S 7 w)r6   r7   r8   r;   r<   Nr@   rC   s
             r+   rD   zAsyncJobs.create!  sm     F ZZ "%2'6$'6 "11	 )+Q[el "   
 
 	
 
s   AA
AAr;   c          	     n   K   | j                  d| t        ||||      t               d{   S 7 w)rF   rG   r;   rH   NrI   rK   s         r+   rM   zAsyncJobs.retrievev  sL     2 YY !3 45(+Q[el "  
 
 	
 
s   ,535rN   c                   | j                  dt        t           t        ||||t	        ||dt
        j                              t              S rR   )rX   r   r   r   r   r   rY   rZ   s          r+   r[   zAsyncJobs.list  s^    8 !! /(+'%%!&!& $11  ! " 
 	
r,   c          	     p   K   | j                  d| dt        ||||      t               d{   S 7 w)r]   rG   r^   r;   rH   Nr_   rK   s         r+   r`   zAsyncJobs.cancel  sN     . ZZ !3 4G<(+Q[el "   
 
 	
 
s   -646c                   | j                  d| dt        t           t        ||||t	        ||dt
        j                              t              S rb   )rX   r   r   r   r   r   rc   rd   s           r+   re   zAsyncJobs.list_events  sj    : !! !3 4G< !34(+'%%!&!& +>> %! " 
 	
r,   )r)   r   rf   rg   rh   ro   )rO   rp   rP   rq   r1   rk   r2   rl   r3   rm   r4   rn   rf   z=AsyncPaginator[FineTuningJob, AsyncCursorPage[FineTuningJob]])rL   ri   rO   rp   rP   rq   r1   rk   r2   rl   r3   rm   r4   rn   rf   zGAsyncPaginator[FineTuningJobEvent, AsyncCursorPage[FineTuningJobEvent]]rr   rx   s   @r+   r   r     s
   //@ IR+44= )-$("&;DS
 RS
 	S

 FS
 )S
 2S
 &S
 "S
  S
 9S
 
S
v )-$("&;D

 &
 "
  
 9
 

H !* ) )-$("&;D-
 -
 	-
 &-
 "-
  -
 9-
 
G-
j )-$("&;D

 &
 "
  
 9
 

F !* ) )-$("&;D.
.
 	.

 .
 &.
 ".
  .
 9.
 
Q.
r,   c                      e Zd ZddZy)r!   c                   t        |j                        | _        t        |j                        | _        t        |j                        | _        t        |j                        | _        t        |j
                        | _        y r$   )r   rD   rM   r[   r`   re   r(   jobss     r+   r&   zJobsWithRawResponse.__init__  sl    -KK
 0MM
 ,II
	 .KK
 3
r,   N)r   r   rf   rg   rs   rt   ru   r&    r,   r+   r!   r!         
r,   r!   c                      e Zd ZddZy)rz   c                   t        |j                        | _        t        |j                        | _        t        |j                        | _        t        |j                        | _        t        |j
                        | _        y r$   )r   rD   rM   r[   r`   re   r   s     r+   r&   z!AsyncJobsWithRawResponse.__init__*  sl    3KK
 6MM
 2II
	 4KK
 9
r,   N)r   r   rf   rg   r   r   r,   r+   rz   rz   )  r   r,   rz   )+
__future__r   typingr   r   r   typing_extensionsr   httpx_typesr	   r
   r   r   r   _utilsr   	_resourcer   r   	_responser   r   
paginationr   r   _base_clientr   r   types.fine_tuningr   r   r   r   r   _clientr   r   __all__r   r   r!   rz   r   r,   r+   <module>r      sz    # 1 1 %  ? ? % : O 9 @  .;
y
? y
xy
  y
x
 
&
 
r,   