
    .h                       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 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l0m1Z1 ddl2m3Z3 ddgZ4 G d de          Z5 G d de           Z6 G d d          Z7 G d d          Z8 G d d          Z9 G d d          Z:dS )     )annotations)Dict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)Metadata)FineTuningJob)FineTuningJobEventJobs	AsyncJobsc                      e Zd Zed6d            Zed7d            Zed8d            Zeeeeeeeddded	d9d$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:d0Zeeddded1d<d3Zddded%d:d4Zddded%d:d5ZdS )=r(   returnr   c                *    t          | j                  S N)r   _clientselfs    c/var/www/FlaskApp/flask-venv/lib/python3.11/site-packages/openai/resources/fine_tuning/jobs/jobs.pycheckpointszJobs.checkpoints&   s    4<(((    JobsWithRawResponsec                     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
        )r4   r/   s    r1   with_raw_responsezJobs.with_raw_response*   s     #4(((r3   JobsWithStreamingResponsec                     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
        )r8   r/   s    r1   with_streaming_responsezJobs.with_streaming_response4   s     )...r3   N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 | NotGivenr>   <Optional[Iterable[job_create_params.Integration]] | NotGivenr?   Optional[Metadata] | NotGivenr@   #job_create_params.Method | NotGivenrA   Optional[int] | NotGivenrB   Optional[str] | NotGivenrC   rD   Headers | NonerE   Query | NonerF   Body | NonerG   'float | httpx.Timeout | None | NotGivenr&   c                   |                      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#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/fine-tuning)
              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/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	rH   rJ   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   bodyoptionscast_to)_postr   r#   JobCreateParamsr!   r&   r0   rH   rJ   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   s                 r1   createzJobs.create=   s    ~ zz "%2'6$0 ($ $'6
 
 "1  )+Q[el   "'  
 
 	
r3   rZ   fine_tuning_job_idc          	         |st          d|          |                     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/rZ   r]   r^   
ValueError_getr!   r&   r0   rc   rD   rE   rF   rG   s         r1   retrievezJobs.retrieve   sn    2 " 	ywaswwxxxyy5!355(+Q[el   "  
 
 	
r3   afterlimitr?   rD   rE   rF   rG   ro   str | NotGivenrp   int | NotGiven#Optional[Dict[str, str]] | NotGivenSyncCursorPage[FineTuningJob]c                   |                      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.

          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
        rX   )ro   rp   r?   rD   rE   rF   rG   querypager]   rH   )_get_api_listr   r&   r!   r   r"   JobListParamsr0   ro   rp   r?   rD   rE   rF   rG   s           r1   listz	Jobs.list   sx    @ !!.(+'%%!&!&$, 
 $1     # " 
 
 	
r3   c          	         |st          d|          |                     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
        rf   rg   /cancelrZ   rh   rj   r_   r!   r&   rl   s         r1   cancelzJobs.cancel	  q    . " 	ywaswwxxxzz<!3<<<(+Q[el   "  
 
 	
r3   ro   rp   rD   rE   rF   rG   "SyncCursorPage[FineTuningJobEvent]c                   |st          d|          |                     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
        rf   rg   z/events)ro   rp   rw   ry   )rj   r{   r   r'   r!   r   r$   JobListEventsParamsr0   rc   ro   rp   rD   rE   rF   rG   s           r1   list_eventszJobs.list_events*  s    : " 	ywaswwxxx!!<!3<<< 23(+'%%!&!&  +>    %! " 
 
 	
r3   c          	         |st          d|          |                     d| dt          ||||          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
        rf   rg   /pauserZ   rh   r   rl   s         r1   pausez
Jobs.pause\  sq    . " 	ywaswwxxxzz;!3;;;(+Q[el   "  
 
 	
r3   c          	         |st          d|          |                     d| dt          ||||          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
        rf   rg   /resumerZ   rh   r   rl   s         r1   resumezJobs.resume}  r   r3   )r+   r   )r+   r4   )r+   r8   rH   rI   rJ   rK   r=   rL   r>   rM   r?   rN   r@   rO   rA   rP   rB   rQ   rC   rQ   rD   rR   rE   rS   rF   rT   rG   rU   r+   r&   rc   rK   rD   rR   rE   rS   rF   rT   rG   rU   r+   r&   )ro   rq   rp   rr   r?   rs   rD   rR   rE   rS   rF   rT   rG   rU   r+   rt   )rc   rK   ro   rq   rp   rr   rD   rR   rE   rS   rF   rT   rG   rU   r+   r   __name__
__module____qualname__r   r2   r7   r;   r   rb   rm   r~   r   r   r   r    r3   r1   r(   r(   %   s       ) ) ) _) ) ) ) _) / / / _/ IRU^2;6?)2+44= )-$("&;D#s
 s
 s
 s
 s
 s
v )-$("&;D!
 !
 !
 !
 !
 !
L !* )8A )-$("&;D2
 2
 2
 2
 2
 2
t )-$("&;D
 
 
 
 
 
J !* ) )-$("&;D0
 0
 0
 0
 0
 0
p )-$("&;D
 
 
 
 
 
N )-$("&;D
 
 
 
 
 
 
 
r3   c                      e Zd Zed6d            Zed7d            Zed8d            Zeeeeeeeddded	d9d$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:d0Zeeddded1d<d3Zddded%d:d4Zddded%d:d5ZdS )=r)   r+   r   c                *    t          | j                  S r-   )r   r.   r/   s    r1   r2   zAsyncJobs.checkpoints  s    ---r3   AsyncJobsWithRawResponsec                     t          |           S r6   )r   r/   s    r1   r7   zAsyncJobs.with_raw_response  s     (---r3   AsyncJobsWithStreamingResponsec                     t          |           S r:   )r   r/   s    r1   r;   z!AsyncJobs.with_streaming_response  s     .d333r3   Nr<   rH   rI   rJ   rK   r=   rL   r>   rM   r?   rN   r@   rO   rA   rP   rB   rQ   rC   rD   rR   rE   rS   rF   rT   rG   rU   r&   c                  K   |                      dt          |||||||||	d	t          j                   d{V t	          |
|||          t
                     d{V S )rW   rX   rY   NrZ   r[   )r_   r   r#   r`   r!   r&   ra   s                 r1   rb   zAsyncJobs.create  s      ~ ZZ,"%2'6$0 ($ $'6
 
 "1        )+Q[el   "'   
 
 
 
 
 
 
 
 	
r3   rZ   rc   c          	        K   |st          d|          |                     d| t          ||||          t                     d{V S )re   rf   rg   rZ   rh   Nri   rl   s         r1   rm   zAsyncJobs.retrieve,  s      2 " 	ywaswwxxxYY5!355(+Q[el   "  
 
 
 
 
 
 
 
 	
r3   rn   ro   rq   rp   rr   rs   =AsyncPaginator[FineTuningJob, AsyncCursorPage[FineTuningJob]]c                   |                      dt          t                   t          ||||t	          |||dt
          j                            t                    S rv   )r{   r   r&   r!   r   r"   r|   r}   s           r1   r~   zAsyncJobs.listO  sx    @ !! /(+'%%!&!&$, 
 $1     # " 
 
 	
r3   c          	        K   |st          d|          |                     d| dt          ||||          t                     d{V S )r   rf   rg   r   rZ   rh   Nr   rl   s         r1   r   zAsyncJobs.cancel        . " 	ywaswwxxxZZ<!3<<<(+Q[el   "   
 
 
 
 
 
 
 
 	
r3   r   GAsyncPaginator[FineTuningJobEvent, AsyncCursorPage[FineTuningJobEvent]]c                   |st          d|          |                     d| dt          t                   t	          ||||t          ||dt          j                            t                    S r   )rj   r{   r   r'   r!   r   r$   r   r   s           r1   r   zAsyncJobs.list_events  s    : " 	ywaswwxxx!!<!3<<< !34(+'%%!&!&  +>    %! " 
 
 	
r3   c          	        K   |st          d|          |                     d| dt          ||||          t                     d{V S )r   rf   rg   r   rZ   rh   Nr   rl   s         r1   r   zAsyncJobs.pause  s      . " 	ywaswwxxxZZ;!3;;;(+Q[el   "   
 
 
 
 
 
 
 
 	
r3   c          	        K   |st          d|          |                     d| dt          ||||          t                     d{V S )r   rf   rg   r   rZ   rh   Nr   rl   s         r1   r   zAsyncJobs.resume  r   r3   )r+   r   )r+   r   )r+   r   r   r   )ro   rq   rp   rr   r?   rs   rD   rR   rE   rS   rF   rT   rG   rU   r+   r   )rc   rK   ro   rq   rp   rr   rD   rR   rE   rS   rF   rT   rG   rU   r+   r   r   r   r3   r1   r)   r)     s       . . . _. . . . _. 4 4 4 _4 IRU^2;6?)2+44= )-$("&;D#s
 s
 s
 s
 s
 s
v )-$("&;D!
 !
 !
 !
 !
 !
L !* )8A )-$("&;D2
 2
 2
 2
 2
 2
t )-$("&;D
 
 
 
 
 
J !* ) )-$("&;D0
 0
 0
 0
 0
 0
p )-$("&;D
 
 
 
 
 
N )-$("&;D
 
 
 
 
 
 
 
r3   c                  .    e Zd Zd	dZed
d            ZdS )r4   jobsr(   r+   Nonec                   || _         t          j        |j                  | _        t          j        |j                  | _        t          j        |j                  | _        t          j        |j                  | _        t          j        |j                  | _        t          j        |j                  | _        t          j        |j	                  | _	        d S r-   )
_jobsr
   to_raw_response_wrapperrb   rm   r~   r   r   r   r   r0   r   s     r1   __init__zJobsWithRawResponse.__init__  s    
&>K
 
 )@M
 
 %<I
 
	 '>K
 
 ,C
 
 &=J
 

 '>K
 
r3   r   c                4    t          | j        j                  S r-   )r   r   r2   r/   s    r1   r2   zJobsWithRawResponse.checkpoints3  s    )$**@AAAr3   Nr   r(   r+   r   )r+   r   r   r   r   r   r   r2   r   r3   r1   r4   r4     sN        
 
 
 
2 B B B _B B Br3   r4   c                  .    e Zd Zd	dZed
d            ZdS )r   r   r)   r+   r   c                   || _         t          j        |j                  | _        t          j        |j                  | _        t          j        |j                  | _        t          j        |j                  | _        t          j        |j                  | _        t          j        |j                  | _        t          j        |j	                  | _	        d S r-   )
r   r
   async_to_raw_response_wrapperrb   rm   r~   r   r   r   r   r   s     r1   r   z!AsyncJobsWithRawResponse.__init__9  s    
&DK
 
 )FM
 
 %BI
 
	 'DK
 
 ,I
 
 &CJ
 

 'DK
 
r3   r   c                4    t          | j        j                  S r-   )r   r   r2   r/   s    r1   r2   z$AsyncJobsWithRawResponse.checkpointsR  s    .tz/EFFFr3   Nr   r)   r+   r   )r+   r   r   r   r3   r1   r   r   8  sN        
 
 
 
2 G G G _G G Gr3   r   c                  .    e Zd Zd	dZed
d            ZdS )r8   r   r(   r+   r   c                r   || _         t          |j                  | _        t          |j                  | _        t          |j                  | _        t          |j                  | _        t          |j                  | _        t          |j                  | _        t          |j                  | _        d S r-   )	r   r   rb   rm   r~   r   r   r   r   r   s     r1   r   z"JobsWithStreamingResponse.__init__X  s    
2K
 
 5M
 
 1I
 
	 3K
 
 8
 
 2J
 

 3K
 
r3   r   c                4    t          | j        j                  S r-   )r   r   r2   r/   s    r1   r2   z%JobsWithStreamingResponse.checkpointsq  s    /
0FGGGr3   Nr   )r+   r   r   r   r3   r1   r8   r8   W  sN        
 
 
 
2 H H H _H H Hr3   r8   c                  .    e Zd Zd	dZed
d            ZdS )r   r   r)   r+   r   c                r   || _         t          |j                  | _        t          |j                  | _        t          |j                  | _        t          |j                  | _        t          |j                  | _        t          |j                  | _        t          |j                  | _        d S r-   )	r   r   rb   rm   r~   r   r   r   r   r   s     r1   r   z'AsyncJobsWithStreamingResponse.__init__w  s    
8K
 
 ;M
 
 7I
 
	 9K
 
 >
 
 8J
 

 9K
 
r3   r   c                4    t          | j        j                  S r-   )r   r   r2   r/   s    r1   r2   z*AsyncJobsWithStreamingResponse.checkpoints  s    4TZ5KLLLr3   Nr   )r+   r   r   r   r3   r1   r   r   v  sN        
 
 
 
2 M M M _M M Mr3   r   );
__future__r   typingr   r   r   r   typing_extensionsr   httpx r
   _typesr   r   r   r   r   _utilsr   r   _compatr   r2   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)   r4   r   r8   r   r   r3   r1   <module>r      s   # " " " " " 2 2 2 2 2 2 2 2 2 2 2 2 % % % % % %  ! ! ! ! ! ! @ @ @ @ @ @ @ @ @ @ @ @ @ @ = = = = = = = = ' ' ' ' ' '                < ; ; ; ; ; ; ; Z Z Z Z Z Z Z Z : : : : : : : :        ] \ \ \ \ \ \ \ \ \ 5 5 5 5 5 5 ? ? ? ? ? ? J J J J J J;
w
 w
 w
 w
 w
? w
 w
 w
tw
 w
 w
 w
 w
  w
 w
 w
tB B B B B B B B>G G G G G G G G>H H H H H H H H>M M M M M M M M M Mr3   