
    2Rj                       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Z7 G d de"      Z8 G d de#      Z9 G d d      Z: G d d      Z; G d d      Z< G d d      Z=y)     )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dd       Zedd       Zedd       Zeeeeeeeddde	d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ
ddde	d	 	 	 	 	 	 	 	 	 	 	 d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ddde	d	 	 	 	 	 	 	 	 	 	 	 ddZy)r+   IManage fine-tuning jobs to tailor a model to your specific training data.c                ,    t        | j                        S r.   )r   _clientselfs    n/var/www/html/meridian/meridian-ai/venv/lib/python3.12/site-packages/openai/resources/fine_tuning/jobs/jobs.pycheckpointszJobs.checkpoints(   s     4<<((    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
        )JobsWithRawResponser2   s    r4   with_raw_responsezJobs.with_raw_response-   s     #4((r6   c                    t        |       S 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
        )JobsWithStreamingResponser2   s    r4   with_streaming_responsezJobs.with_streaming_response7   s     )..r6   Nhyperparametersintegrationsmetadatamethodseedsuffixvalidation_fileextra_headersextra_query
extra_bodytimeoutc                   | j                  dt        |||||||||	d	t        j                        t	        |
|||ddi      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/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	modeltraining_filer@   rA   rB   rC   rD   rE   rF   bearer_authTrG   rH   rI   rJ   securitybodyoptionscast_to)_postr   r&   JobCreateParamsr$   r)   r3   rO   rP   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   s                 r4   createzJobs.create@   st    B zz "%2'6$0 ($ $'6
 "11 )+'%'. "/  
 	
r6   rG   rH   rI   rJ   c                   |st        d|      | j                  t        d|      t        ||||ddi      t              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/{fine_tuning_job_id}fine_tuning_job_idrQ   TrR   rV   rW   
ValueError_getr   r$   r)   r3   rb   rG   rH   rI   rJ   s         r4   retrievezJobs.retrieve   s_    2 "`as`vwxxyyBWij(+'%'. "  

 
	
r6   afterlimitrB   rG   rH   rI   rJ   c                   | j                  dt        t           t        ||||t	        |||dt
        j                        ddi      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.

          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
        rM   )rj   rk   rB   rQ   TrG   rH   rI   rJ   queryrS   pagerV   rO   )_get_api_listr!   r)   r$   r   r%   JobListParamsr3   rj   rk   rB   rG   rH   rI   rJ   s           r4   listz	Jobs.list   sl    @ !!.(+'%%!&!&$,
 $11 (.  % " 
 	
r6   c                   |st        d|      | j                  t        d|      t        ||||ddi      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
        r_   -/fine_tuning/jobs/{fine_tuning_job_id}/cancelra   rQ   TrR   rc   re   rX   r   r$   r)   rg   s         r4   cancelzJobs.cancel  _    . "`as`vwxxzzI^pq(+'%'. "  

 
	
r6   rj   rk   rG   rH   rI   rJ   c                   |st        d|      | j                  t        d|      t        t           t        ||||t        ||dt        j                        ddi      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
        r_   z-/fine_tuning/jobs/{fine_tuning_job_id}/eventsra   )rj   rk   rQ   Trn   rp   )	re   rr   r   r!   r*   r$   r   r'   JobListEventsParamsr3   rb   rj   rk   rG   rH   rI   rJ   s           r4   list_eventszJobs.list_events<  s    : "`as`vwxx!!I^pq 23(+'%%!&!& +>> (. %# " 
 	
r6   c                   |st        d|      | j                  t        d|      t        ||||ddi      t              S )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
        r_   ,/fine_tuning/jobs/{fine_tuning_job_id}/pausera   rQ   TrR   rc   ry   rg   s         r4   pausez
Jobs.pauseo  s_    . "`as`vwxxzzH]op(+'%'. "  

 
	
r6   c                   |st        d|      | j                  t        d|      t        ||||ddi      t              S )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
        r_   -/fine_tuning/jobs/{fine_tuning_job_id}/resumera   rQ   TrR   rc   ry   rg   s         r4   resumezJobs.resume  r{   r6   )returnr   )r   r9   )r   r=   rO   zQUnion[str, Literal['babbage-002', 'davinci-002', 'gpt-3.5-turbo', 'gpt-4o-mini']]rP   strr@   z(job_create_params.Hyperparameters | OmitrA   z8Optional[Iterable[job_create_params.Integration]] | OmitrB   zOptional[Metadata] | OmitrC   zjob_create_params.Method | OmitrD   zOptional[int] | OmitrE   Optional[str] | OmitrF   r   rG   Headers | NonerH   Query | NonerI   Body | NonerJ   'float | httpx.Timeout | None | NotGivenr   r)   rb   r   rG   r   rH   r   rI   r   rJ   r   r   r)   )rj   
str | Omitrk   
int | OmitrB   Optional[Dict[str, str]] | OmitrG   r   rH   r   rI   r   rJ   r   r   zSyncCursorPage[FineTuningJob])rb   r   rj   r   rk   r   rG   r   rH   r   rI   r   rJ   r   r   z"SyncCursorPage[FineTuningJobEvent]__name__
__module____qualname____doc__r   r5   r:   r>   r   r   r[   rh   ru   rz   r   r   r    r6   r4   r+   r+   %   s   S) ) ) ) / / EIQU.226%)'+04 )-$("&;D#y
 ay
 	y

 By
 Oy
 ,y
 0y
 #y
 %y
 .y
 &y
 "y
   !y
" 9#y
$ 
%y
B )-$("&;D%
%
 &%
 "%
  %
 9%
 
%
T ! 48 )-$("&;D3
 3
 	3

 23
 &3
 "3
  3
 93
 
'3
v )-$("&;D#
#
 &#
 "#
  #
 9#
 
#
R !  )-$("&;D1
1
 	1

 1
 &1
 "1
  1
 91
 
,1
r )-$("&;D#
#
 &#
 "#
  #
 9#
 
#
V )-$("&;D#
#
 &#
 "#
  #
 9#
 
#
r6   c                     e Zd ZdZedd       Zedd       Zedd       Zeeeeeeeddde	d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ
ddde	d	 	 	 	 	 	 	 	 	 	 	 d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ddde	d	 	 	 	 	 	 	 	 	 	 	 ddZy)r,   r.   c                ,    t        | j                        S r0   )r   r1   r2   s    r4   r5   zAsyncJobs.checkpoints  s      --r6   c                    t        |       S r8   )AsyncJobsWithRawResponser2   s    r4   r:   zAsyncJobs.with_raw_response  s     (--r6   c                    t        |       S r<   )AsyncJobsWithStreamingResponser2   s    r4   r>   z!AsyncJobs.with_streaming_response  s     .d33r6   Nr?   c                  K   | j                  dt        |||||||||	d	t        j                         d{   t	        |
|||ddi      t
               d{   S 7 '7 w)rL   rM   rN   NrQ   TrR   rT   )rX   r   r&   rY   r$   r)   rZ   s                 r4   r[   zAsyncJobs.create  s     B ZZ,"%2'6$0 ($ $'6
 "11  )+'%'. "/   
 
 	

s!   4A"A
"A"A A" A"r\   c                  K   |st        d|      | j                  t        d|      t        ||||ddi      t               d{   S 7 w)	r^   r_   r`   ra   rQ   TrR   rc   Nrd   rg   s         r4   rh   zAsyncJobs.retrieveP  sm     2 "`as`vwxxYYBWij(+'%'. "  

 

 
	
 

   AA	A
Ari   c                   | j                  dt        t           t        ||||t	        |||dt
        j                        ddi      t              S rm   )rr   r"   r)   r$   r   r%   rs   rt   s           r4   ru   zAsyncJobs.listw  sl    @ !! /(+'%%!&!&$,
 $11 (.  % " 
 	
r6   c                  K   |st        d|      | j                  t        d|      t        ||||ddi      t               d{   S 7 w)	rw   r_   rx   ra   rQ   TrR   rc   Nry   rg   s         r4   rz   zAsyncJobs.cancel  m     . "`as`vwxxZZI^pq(+'%'. "   

 

 
	
 

r   r|   c                   |st        d|      | j                  t        d|      t        t           t        ||||t        ||dt        j                        ddi      t              S r~   )	re   rr   r   r"   r*   r$   r   r'   r   r   s           r4   r   zAsyncJobs.list_events  s    : "`as`vwxx!!I^pq !34(+'%%!&!& +>> (. %# " 
 	
r6   c                  K   |st        d|      | j                  t        d|      t        ||||ddi      t               d{   S 7 w)	r   r_   r   ra   rQ   TrR   rc   Nry   rg   s         r4   r   zAsyncJobs.pause  sm     . "`as`vwxxZZH]op(+'%'. "   

 

 
	
 

r   c                  K   |st        d|      | j                  t        d|      t        ||||ddi      t               d{   S 7 w)	r   r_   r   ra   rQ   TrR   rc   Nry   rg   s         r4   r   zAsyncJobs.resume)  r   r   )r   r   )r   r   )r   r   r   r   )rj   r   rk   r   rB   r   rG   r   rH   r   rI   r   rJ   r   r   z=AsyncPaginator[FineTuningJob, AsyncCursorPage[FineTuningJob]])rb   r   rj   r   rk   r   rG   r   rH   r   rI   r   rJ   r   r   zGAsyncPaginator[FineTuningJobEvent, AsyncCursorPage[FineTuningJobEvent]]r   r   r6   r4   r,   r,     s   S. . . . 4 4 EIQU.226%)'+04 )-$("&;D#y
 ay
 	y

 By
 Oy
 ,y
 0y
 #y
 %y
 .y
 &y
 "y
   !y
" 9#y
$ 
%y
B )-$("&;D%
%
 &%
 "%
  %
 9%
 
%
T ! 48 )-$("&;D3
 3
 	3

 23
 &3
 "3
  3
 93
 
G3
v )-$("&;D#
#
 &#
 "#
  #
 9#
 
#
R !  )-$("&;D1
1
 	1

 1
 &1
 "1
  1
 91
 
Q1
r )-$("&;D#
#
 &#
 "#
  #
 9#
 
#
V )-$("&;D#
#
 &#
 "#
  #
 9#
 
#
r6   c                  &    e Zd ZddZedd       Zy)r9   c                
   || _         t        j                  |j                        | _        t        j                  |j                        | _        t        j                  |j
                        | _        t        j                  |j                        | _        t        j                  |j                        | _        t        j                  |j                        | _        t        j                  |j                        | _	        y N)
_jobsr
   to_raw_response_wrapperr[   rh   ru   rz   r   r   r   r3   jobss     r4   __init__zJobsWithRawResponse.__init__P  s    
&>>KK
 )@@MM
 %<<II
	 '>>KK
 ,CC
 &==JJ

 '>>KK
r6   c                @    t        | j                  j                        S r0   )r   r   r5   r2   s    r4   r5   zJobsWithRawResponse.checkpointsi  s     *$***@*@AAr6   Nr   r+   r   None)r   r   r   r   r   r   r   r5   r   r6   r4   r9   r9   O  s    
2 B Br6   r9   c                  &    e Zd ZddZedd       Zy)r   c                
   || _         t        j                  |j                        | _        t        j                  |j                        | _        t        j                  |j
                        | _        t        j                  |j                        | _        t        j                  |j                        | _        t        j                  |j                        | _        t        j                  |j                        | _	        y r   )
r   r
   async_to_raw_response_wrapperr[   rh   ru   rz   r   r   r   r   s     r4   r   z!AsyncJobsWithRawResponse.__init__p  s    
&DDKK
 )FFMM
 %BBII
	 'DDKK
 ,II
 &CCJJ

 'DDKK
r6   c                @    t        | j                  j                        S r0   )r   r   r5   r2   s    r4   r5   z$AsyncJobsWithRawResponse.checkpoints  s     /tzz/E/EFFr6   Nr   r,   r   r   )r   r   r   r   r6   r4   r   r   o  s    
2 G Gr6   r   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                        | _        t        |j                        | _        t        |j                        | _        y r   )	r   r   r[   rh   ru   rz   r   r   r   r   s     r4   r   z"JobsWithStreamingResponse.__init__  s    
2KK
 5MM
 1II
	 3KK
 8
 2JJ

 3KK
r6   c                @    t        | j                  j                        S r0   )r   r   r5   r2   s    r4   r5   z%JobsWithStreamingResponse.checkpoints  s     0

0F0FGGr6   Nr   )r   r   r   r   r6   r4   r=   r=     s    
2 H Hr6   r=   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                        | _        t        |j                        | _        t        |j                        | _        y r   )	r   r    r[   rh   ru   rz   r   r   r   r   s     r4   r   z'AsyncJobsWithStreamingResponse.__init__  s    
8KK
 ;MM
 7II
	 9KK
 >
 8JJ

 9KK
r6   c                @    t        | j                  j                        S r0   )r   r   r5   r2   s    r4   r5   z*AsyncJobsWithStreamingResponse.checkpoints  s     5TZZ5K5KLLr6   Nr   )r   r   r   r   r6   r4   r   r     s    
2 M Mr6   r   )>
__future__r   typingr   r   r   r   typing_extensionsr   httpx r
   _typesr   r   r   r   r   r   r   _utilsr   r   r   _compatr   r5   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,   r9   r   r=   r   r   r6   r4   <module>r      s    # 2 2 %  ! L L L L L '  < Z : ] \ 5 ? J;
R
? R
jR
  R
jB B@G G@H H@M Mr6   