
    OYhfRk                       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Z1 G d de      Z2 G d de      Z3 G d d      Z4 G d d      Z5 G d d      Z6 G d d      Z7y)    )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            
      J   e Zd Zedd       Zedd       Zedd       Zee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y)r&   c                ,    t        | j                        S N)r   _clientselfs    e/var/www/feuerwehr-webapp/venv/lib/python3.12/site-packages/openai/resources/fine_tuning/jobs/jobs.pycheckpointszJobs.checkpoints(   s    4<<((    c                    t        |       S r*   )JobsWithRawResponser,   s    r.   with_raw_responsezJobs.with_raw_response,   s    "4((r0   c                    t        |       S r*   )JobsWithStreamingResponser,   s    r.   with_streaming_responsezJobs.with_streaming_response0   s    (..r0   N	hyperparametersintegrationsseedsuffixvalidation_fileextra_headersextra_query
extra_bodytimeoutc                   | j                  dt        |||||||dt        j                        t	        ||	|
|      t
              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/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-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_filer8   r9   r:   r;   r<   r=   r>   r?   r@   bodyoptionscast_to)_postr   r"   JobCreateParamsr    r$   r-   rE   rF   r8   r9   r:   r;   r<   r=   r>   r?   r@   s               r.   createzJobs.create4   se    b zz "%2'6$0 $'6 "11 )+Q[el "#  
 	
r0   rG   c          	     r    |st        d|      | 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
        AExpected a non-empty value for `fine_tuning_job_id` but received /fine_tuning/jobs/rG   rJ   rK   
ValueError_getr    r$   r-   fine_tuning_job_idr=   r>   r?   r@   s         r.   retrievezJobs.retrieve   sV    2 "`as`vwxxyy !3 45(+Q[el "  
 	
r0   afterlimitr=   r>   r?   r@   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
        rC   r\   r]   r=   r>   r?   r@   querypagerJ   rE   )_get_api_listr   r$   r    r   r!   JobListParamsr-   r\   r]   r=   r>   r?   r@   s          r.   listz	Jobs.list   s^    8 !!.(+'%%!&!& $11  ! " 
 	
r0   c          	     t    |st        d|      | 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
        rR   rS   /cancelrG   rT   rV   rL   r    r$   rX   s         r.   cancelzJobs.cancel   sX    . "`as`vwxxzz !3 4G<(+Q[el "  
 	
r0   c                   |st        d|      | 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
        rR   rS   z/eventsr`   ra   rc   )rV   re   r   r%   r    r   r#   JobListEventsParamsr-   rY   r\   r]   r=   r>   r?   r@   s           r.   list_eventszJobs.list_events  s    : "`as`vwxx!! !3 4G< 23(+'%%!&!& +>> %! " 
 	
r0   )returnr   )rs   r2   )rs   r5   rE   zBUnion[str, Literal['babbage-002', 'davinci-002', 'gpt-3.5-turbo']]rF   strr8   z,job_create_params.Hyperparameters | NotGivenr9   z<Optional[Iterable[job_create_params.Integration]] | NotGivenr:   zOptional[int] | NotGivenr;   Optional[str] | NotGivenr<   rv   r=   Headers | Noner>   Query | Noner?   Body | Noner@   'float | httpx.Timeout | None | NotGivenrs   r$   rY   ru   r=   rw   r>   rx   r?   ry   r@   rz   rs   r$   )r\   str | NotGivenr]   int | NotGivenr=   rw   r>   rx   r?   ry   r@   rz   rs   zSyncCursorPage[FineTuningJob])rY   ru   r\   r|   r]   r}   r=   rw   r>   rx   r?   ry   r@   rz   rs   z"SyncCursorPage[FineTuningJobEvent]__name__
__module____qualname__r   r/   r3   r6   r
   rO   rZ   rh   rm   rr    r0   r.   r&   r&   '   sR   ) ) ) ) / / IRU^)2+44= )-$("&;Dc
 Rc
 	c

 Fc
 Sc
 'c
 )c
 2c
 &c
 "c
  c
 9c
  
!c
V )-$("&;D!
!
 &!
 "!
  !
 9!
 
!
L !* ) )-$("&;D-
 -
 	-
 &-
 "-
  -
 9-
 
'-
j )-$("&;D

 &
 "
  
 9
 

J !* ) )-$("&;D0
0
 	0

 0
 &0
 "0
  0
 90
 
,0
r0   c            
      J   e Zd Zedd       Zedd       Zedd       Zee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y)r'   c                ,    t        | j                        S r*   )r   r+   r,   s    r.   r/   zAsyncJobs.checkpoints@  s    --r0   c                    t        |       S r*   )AsyncJobsWithRawResponser,   s    r.   r3   zAsyncJobs.with_raw_responseD  s    '--r0   c                    t        |       S r*   )AsyncJobsWithStreamingResponser,   s    r.   r6   z!AsyncJobs.with_streaming_responseH  s    -d33r0   Nr7   c                  K   | j                  dt        |||||||dt        j                         d{   t	        ||	|
|      t
               d{   S 7 $7 w)rB   rC   rD   NrG   rH   )rL   r   r"   rM   r    r$   rN   s               r.   rO   zAsyncJobs.createL  s~     b ZZ,"%2'6$0 $'6 "11  )+Q[el "#   
 
 	

s!   2AA
AAAArG   c          	        K   |st        d|      | j                  d| t        ||||      t               d{   S 7 w)rQ   rR   rS   rG   rT   NrU   rX   s         r.   rZ   zAsyncJobs.retrieve  sd     2 "`as`vwxxYY !3 45(+Q[el "  
 
 	
 
s   <AAAr[   c                   | j                  dt        t           t        ||||t	        ||dt
        j                              t              S r_   )re   r   r$   r    r   r!   rf   rg   s          r.   rh   zAsyncJobs.list  s^    8 !! /(+'%%!&!& $11  ! " 
 	
r0   c          	        K   |st        d|      | j                  d| dt        ||||      t               d{   S 7 w)rj   rR   rS   rk   rG   rT   Nrl   rX   s         r.   rm   zAsyncJobs.cancel  sf     . "`as`vwxxZZ !3 4G<(+Q[el "   
 
 	
 
s   =AA Ac                   |st        d|      | j                  d| dt        t           t	        ||||t        ||dt        j                              t              S ro   )rV   re   r   r%   r    r   r#   rp   rq   s           r.   rr   zAsyncJobs.list_events$  s    : "`as`vwxx!! !3 4G< !34(+'%%!&!& +>> %! " 
 	
r0   )rs   r   )rs   r   )rs   r   rt   r{   )r\   r|   r]   r}   r=   rw   r>   rx   r?   ry   r@   rz   rs   z=AsyncPaginator[FineTuningJob, AsyncCursorPage[FineTuningJob]])rY   ru   r\   r|   r]   r}   r=   rw   r>   rx   r?   ry   r@   rz   rs   zGAsyncPaginator[FineTuningJobEvent, AsyncCursorPage[FineTuningJobEvent]]r~   r   r0   r.   r'   r'   ?  sT   . . . . 4 4 IRU^)2+44= )-$("&;Dc
 Rc
 	c

 Fc
 Sc
 'c
 )c
 2c
 &c
 "c
  c
 9c
  
!c
V )-$("&;D!
!
 &!
 "!
  !
 9!
 
!
L !* ) )-$("&;D-
 -
 	-
 &-
 "-
  -
 9-
 
G-
j )-$("&;D

 &
 "
  
 9
 

J !* ) )-$("&;D0
0
 	0

 0
 &0
 "0
  0
 90
 
Q0
r0   c                  &    e Zd ZddZedd       Zy)r2   c                z   || _         t        j                  |j                        | _        t        j                  |j                        | _        t        j                  |j
                        | _        t        j                  |j                        | _        t        j                  |j                        | _        y r*   )_jobsr	   to_raw_response_wrapperrO   rZ   rh   rm   rr   r-   jobss     r.   __init__zJobsWithRawResponse.__init__X  s    
&>>KK
 )@@MM
 %<<II
	 '>>KK
 ,CC
r0   c                @    t        | j                  j                        S r*   )r   r   r/   r,   s    r.   r/   zJobsWithRawResponse.checkpointsk  s    )$***@*@AAr0   Nr   r&   rs   None)rs   r   r   r   r   r   r   r/   r   r0   r.   r2   r2   W  s    
& B Br0   r2   c                  &    e Zd ZddZedd       Zy)r   c                z   || _         t        j                  |j                        | _        t        j                  |j                        | _        t        j                  |j
                        | _        t        j                  |j                        | _        t        j                  |j                        | _        y r*   )r   r	   async_to_raw_response_wrapperrO   rZ   rh   rm   rr   r   s     r.   r   z!AsyncJobsWithRawResponse.__init__q  s    
&DDKK
 )FFMM
 %BBII
	 'DDKK
 ,II
r0   c                @    t        | j                  j                        S r*   )r   r   r/   r,   s    r.   r/   z$AsyncJobsWithRawResponse.checkpoints  s    .tzz/E/EFFr0   Nr   r'   rs   r   )rs   r   r   r   r0   r.   r   r   p  s    
& G Gr0   r   c                  &    e Zd ZddZedd       Zy)r5   c                   || _         t        |j                        | _        t        |j                        | _        t        |j                        | _        t        |j
                        | _        t        |j                        | _        y r*   )r   r   rO   rZ   rh   rm   rr   r   s     r.   r   z"JobsWithStreamingResponse.__init__  ss    
2KK
 5MM
 1II
	 3KK
 8
r0   c                @    t        | j                  j                        S r*   )r   r   r/   r,   s    r.   r/   z%JobsWithStreamingResponse.checkpoints  s    /

0F0FGGr0   Nr   )rs   r   r   r   r0   r.   r5   r5     s    
& H Hr0   r5   c                  &    e Zd ZddZedd       Zy)r   c                   || _         t        |j                        | _        t        |j                        | _        t        |j                        | _        t        |j
                        | _        t        |j                        | _        y r*   )r   r   rO   rZ   rh   rm   rr   r   s     r.   r   z'AsyncJobsWithStreamingResponse.__init__  ss    
8KK
 ;MM
 7II
	 9KK
 >
r0   c                @    t        | j                  j                        S r*   )r   r   r/   r,   s    r.   r/   z*AsyncJobsWithStreamingResponse.checkpoints  s    4TZZ5K5KLLr0   Nr   )rs   r   r   r   r0   r.   r   r     s    
& M Mr0   r   )8
__future__r   typingr   r   r   typing_extensionsr   httpx r	   _typesr
   r   r   r   r   _utilsr   r   _compatr   r/   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   r5   r   r   r0   r.   <module>r      s    # , , %  ! @ @ (  < Z : ] \ ? J;
U
? U
pU
  U
pB B2G G2H H2M Mr0   