a
    !fU                     @  s  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rddl#m$Z$m%Z% ddgZ&G dd deZ'G dd deZ(G dd dZ)G dd dZ*dS )    )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                      s   e Zd ZU ded< ddd fddZeeeddded	d
dddddddddd
ddZdddeddddddddddZeedddeddddddddddd Zdddeddddddddd!d"Z	eedddeddddddddd#d$d%d&Z
  ZS )'r   JobsWithRawResponsewith_raw_responser   Noneclientreturnc                   s   t  | t| | _d S N)super__init__r   r    selfr#   	__class__ b/var/www/html/python-backend/venv/lib/python3.9/site-packages/openai/resources/fine_tuning/jobs.pyr'   !   s    zJobs.__init__Nhyperparameterssuffixvalidation_fileextra_headersextra_query
extra_bodytimeoutBUnion[str, Literal['babbage-002', 'davinci-002', 'gpt-3.5-turbo']]str,job_create_params.Hyperparameters | NotGivenOptional[str] | NotGivenHeaders | NoneQuery | NoneBody | None'float | httpx.Timeout | None | NotGivenr   
modeltraining_filer/   r0   r1   r2   r3   r4   r5   r$   c       	   
   	   C  s2   | j dt|||||dtjt||||	dtd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r?   r@   r/   r0   r1   r2   r3   r4   r5   bodyoptionscast_to_postr   r   ZJobCreateParamsr   r   
r)   r?   r@   r/   r0   r1   r2   r3   r4   r5   r,   r,   r-   create%   s     C
zJobs.createrD   fine_tuning_job_idr2   r3   r4   r5   r$   c                C  s"   | j d| t||||dtd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/rD   rG   rH   _getr   r   r)   rN   r2   r3   r4   r5   r,   r,   r-   retrievez   s    zJobs.retrieveafterlimitr2   r3   r4   r5   str | NotGivenint | NotGivenzSyncCursorPage[FineTuningJob]rW   rX   r2   r3   r4   r5   r$   c                C  s2   | j dtt t||||t||dtjdtd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
        rB   rW   rX   r2   r3   r4   r5   querypagerG   r?   )_get_api_listr   r   r   r   r   JobListParamsr)   rW   rX   r2   r3   r4   r5   r,   r,   r-   list   s"    z	Jobs.listc                C  s$   | j d| dt||||dtd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
        rP   /cancelrD   rQ   rJ   r   r   rT   r,   r,   r-   cancel   s    
zJobs.cancelz"SyncCursorPage[FineTuningJobEvent]rN   rW   rX   r2   r3   r4   r5   r$   c                C  s:   | j d| dtt t||||t||dtj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
        rP   z/eventsr]   r^   r`   )rb   r   r   r   r   r   JobListEventsParamsr)   rN   rW   rX   r2   r3   r4   r5   r,   r,   r-   list_events   s"    
zJobs.list_events__name__
__module____qualname____annotations__r'   r   rL   rU   re   ri   rn   __classcell__r,   r,   r*   r-   r      sD   
	$[$5#c                      s   e Zd ZU ded< ddd fddZeeeddded	d
dddddddddd
ddZdddeddddddddddZeedddeddddddddddd Zdddeddddddddd!d"Z	eedddeddddddddd#d$d%d&Z
  ZS )'r   AsyncJobsWithRawResponser    r   r!   r"   c                   s   t  | t| | _d S r%   )r&   r'   ru   r    r(   r*   r,   r-   r'     s    zAsyncJobs.__init__Nr.   r6   r7   r8   r9   r:   r;   r<   r=   r   r>   c       	   
   	     s8   | j dt|||||dtjt||||	dtdI dH S )rA   rB   rC   rD   rE   NrI   rK   r,   r,   r-   rL   !  s     C
zAsyncJobs.createrD   rM   c                  s(   | j d| t||||dtdI dH S )rO   rP   rD   rQ   NrR   rT   r,   r,   r-   rU   v  s    zAsyncJobs.retrieverV   rY   rZ   z=AsyncPaginator[FineTuningJob, AsyncCursorPage[FineTuningJob]]r[   c                C  s2   | j dtt t||||t||dtjdtdS r\   )rb   r   r   r   r   r   rc   rd   r,   r,   r-   re     s"    zAsyncJobs.listc                  s*   | j d| dt||||dtdI dH S )rf   rP   rg   rD   rQ   Nrh   rT   r,   r,   r-   ri     s    
zAsyncJobs.cancelzGAsyncPaginator[FineTuningJobEvent, AsyncCursorPage[FineTuningJobEvent]]rj   c                C  s:   | j d| dtt t||||t||dtjdtdS rk   )rb   r   r   r   r   r   rl   rm   r,   r,   r-   rn     s"    
zAsyncJobs.list_eventsro   r,   r,   r*   r-   r     sD   
	$[$5#c                   @  s   e Zd ZdddddZdS )r   r   r!   jobsr$   c                 C  s@   t |j| _t |j| _t |j| _t |j| _t |j| _d S r%   )r   rL   rU   re   ri   rn   r)   rw   r,   r,   r-   r'     s    zJobsWithRawResponse.__init__Nrp   rq   rr   r'   r,   r,   r,   r-   r     s   r   c                   @  s   e Zd ZdddddZdS )ru   r   r!   rv   c                 C  s@   t |j| _t |j| _t |j| _t |j| _t |j| _d S r%   )r   rL   rU   re   ri   rn   rx   r,   r,   r-   r'   *  s    z!AsyncJobsWithRawResponse.__init__Nry   r,   r,   r,   r-   ru   )  s   ru   )+
__future__r   typingr   r   r   Ztyping_extensionsr   Zhttpx_typesr   r	   r
   r   r   _utilsr   Z	_resourcer   r   	_responser   r   Z
paginationr   r   Z_base_clientr   r   Ztypes.fine_tuningr   r   r   r   r   Z_clientr   r   __all__r   r   r   ru   r,   r,   r,   r-   <module>   s&    } }