a
    !fhg                     @  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 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ListOptional)LiteralN   )Steps
AsyncStepsStepsWithRawResponseAsyncStepsWithRawResponse   )	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)Runrun_list_paramsrun_create_paramsrun_update_paramsrun_submit_tool_outputs_params)OpenAIAsyncOpenAIRuns	AsyncRunsc                      s>  e Zd ZU ded< ded< ddd fdd	Zeeeed
d
d
ed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dZed
d
d
eddddddddddddZe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(d)Z
d
d
d
edddd*dddddd+d,d-Z  ZS ).r"   r   stepsRunsWithRawResponsewith_raw_responser    Noneclientreturnc                   s$   t  | t|| _t| | _d S N)super__init__r   r$   r%   r&   selfr)   	__class__ h/var/www/html/python-backend/venv/lib/python3.9/site-packages/openai/resources/beta/threads/runs/runs.pyr-   #   s    
zRuns.__init__Ninstructionsmetadatamodeltoolsextra_headersextra_query
extra_bodytimeoutstrOptional[str] | NotGivenOptional[object] | NotGiven1Optional[List[run_create_params.Tool]] | NotGivenHeaders | NoneQuery | NoneBody | None'float | httpx.Timeout | None | NotGivenr   	thread_idassistant_idr5   r6   r7   r8   r9   r:   r;   r<   r*   c       	      	   C  sJ   ddi|pi }| j d| dt|||||dtjt|||	|
dtdS )  
        Create a run.

        Args:
          assistant_id: The ID of the
              [assistant](https://platform.openai.com/docs/api-reference/assistants) to use to
              execute this run.

          instructions: Override the default system message of the assistant. This is useful for
              modifying the behavior on a per-run basis.

          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. Keys
              can be a maximum of 64 characters long and values can be a maxium of 512
              characters long.

          model: The ID of the [Model](https://platform.openai.com/docs/api-reference/models) to
              be used to execute this run. If a value is provided here, it will override the
              model associated with the assistant. If not, the model associated with the
              assistant will be used.

          tools: Override the tools the assistant can use for this run. This is useful for
              modifying the behavior on a per-run basis.

          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
        OpenAI-Betaassistants=v1	/threads//runsrG   r5   r6   r7   r8   r9   r:   r;   r<   bodyoptionscast_to_postr   r   ZRunCreateParamsr   r   r/   rF   rG   r5   r6   r7   r8   r9   r:   r;   r<   r2   r2   r3   create(   s"    0

zRuns.createrN   run_idrF   r9   r:   r;   r<   r*   c                C  s8   ddi|pi }| j d| d| t||||dtdS )D  
        Retrieves a run.

        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
        rI   rJ   rK   /runs/rN   rQ   rR   _getr   r   r/   rX   rF   r9   r:   r;   r<   r2   r2   r3   retrievek   s    zRuns.retriever6   r9   r:   r;   r<   rX   rF   r6   r9   r:   r;   r<   r*   c             	   C  sF   ddi|pi }| j d| d| td|itjt||||dtdS )}  
        Modifies a run.

        Args:
          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. Keys
              can be a maximum of 64 characters long and values can be a maxium of 512
              characters long.

          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
        rI   rJ   rK   rZ   r6   rN   rO   rT   r   r   ZRunUpdateParamsr   r   r/   rX   rF   r6   r9   r:   r;   r<   r2   r2   r3   update   s    zRuns.updateafterbeforelimitorderr9   r:   r;   r<   str | NotGivenint | NotGiven!Literal['asc', 'desc'] | NotGivenzSyncCursorPage[Run]
rF   rg   rh   ri   rj   r9   r:   r;   r<   r*   c          
      C  sN   ddi|pi }| j d| dtt t||||	t||||dtjdtdS a  
        Returns a list of runs belonging to a thread.

        Args:
          after: A cursor for use in pagination. `after` is an object ID that defines your place
              in the list. For instance, if you make a list request and receive 100 objects,
              ending with obj_foo, your subsequent call can include after=obj_foo in order to
              fetch the next page of the list.

          before: A cursor for use in pagination. `before` is an object ID that defines your place
              in the list. For instance, if you make a list request and receive 100 objects,
              ending with obj_foo, your subsequent call can include before=obj_foo in order to
              fetch the previous page of the list.

          limit: A limit on the number of objects to be returned. Limit can range between 1 and
              100, and the default is 20.

          order: Sort order by the `created_at` timestamp of the objects. `asc` for ascending
              order and `desc` for descending order.

          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
        rI   rJ   rK   rL   )rg   rh   ri   rj   )r9   r:   r;   r<   query)pagerQ   r7   )_get_api_listr   r   r   r   r   RunListParams
r/   rF   rg   rh   ri   rj   r9   r:   r;   r<   r2   r2   r3   list   s(    +
z	Runs.listc                C  s:   ddi|pi }| j d| d| dt||||dtdS )X  
        Cancels a run that is `in_progress`.

        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
        rI   rJ   rK   rZ   /cancelrN   r[   rT   r   r   r^   r2   r2   r3   cancel   s    zRuns.cancel/List[run_submit_tool_outputs_params.ToolOutput]rX   rF   tool_outputsr9   r:   r;   r<   r*   c             	   C  sH   ddi|pi }| j d| d| dtd|itjt||||dtdS )	  
        When a run has the `status: "requires_action"` and `required_action.type` is
        `submit_tool_outputs`, this endpoint can be used to submit the outputs from the
        tool calls once they're all completed. All outputs must be submitted in a single
        request.

        Args:
          tool_outputs: A list of tools for which the outputs are being submitted.

          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
        rI   rJ   rK   rZ   /submit_tool_outputsr|   rN   rO   rT   r   r   ZRunSubmitToolOutputsParamsr   r   r/   rX   rF   r|   r9   r:   r;   r<   r2   r2   r3   submit_tool_outputs  s    
zRuns.submit_tool_outputs__name__
__module____qualname____annotations__r-   r   rV   r_   re   ru   ry   r   __classcell__r2   r2   r0   r3   r"      sT   

&J& ,$H)c                      s>  e Zd ZU ded< ded< ddd fdd	Zeeeed
d
d
ed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dZed
d
d
eddddddddddddZe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(d)Z
d
d
d
edddd*dddddd+d,d-Z  ZS ).r#   r	   r$   AsyncRunsWithRawResponser&   r!   r'   r(   c                   s$   t  | t|| _t| | _d S r+   )r,   r-   r	   r$   r   r&   r.   r0   r2   r3   r-   E  s    
zAsyncRuns.__init__Nr4   r=   r>   r?   r@   rA   rB   rC   rD   r   rE   c       	      	     sP   ddi|pi }| j d| dt|||||dtjt|||	|
dtdI dH S )	rH   rI   rJ   rK   rL   rM   rN   rO   NrS   rU   r2   r2   r3   rV   J  s"    0

zAsyncRuns.createrN   rW   c                  s>   ddi|pi }| j d| d| t||||dtdI dH S )rY   rI   rJ   rK   rZ   rN   r[   Nr\   r^   r2   r2   r3   r_     s    zAsyncRuns.retriever`   ra   c             	     sL   ddi|pi }| j d| d| td|itjt||||dtdI dH S )	rb   rI   rJ   rK   rZ   r6   rN   rO   Nrc   rd   r2   r2   r3   re     s    zAsyncRuns.updaterf   rk   rl   rm   z)AsyncPaginator[Run, AsyncCursorPage[Run]]rn   c          
      C  sN   ddi|pi }| j d| dtt t||||	t||||dtjdtdS ro   )rr   r   r   r   r   r   rs   rt   r2   r2   r3   ru     s(    +
zAsyncRuns.listc                  s@   ddi|pi }| j d| d| dt||||dtdI dH S )	rv   rI   rJ   rK   rZ   rw   rN   r[   Nrx   r^   r2   r2   r3   ry     s    zAsyncRuns.cancelrz   r{   c             	     sN   ddi|pi }| j d| d| dtd|itjt||||dtdI d	H S )
r}   rI   rJ   rK   rZ   r~   r|   rN   rO   Nr   r   r2   r2   r3   r   8  s    
zAsyncRuns.submit_tool_outputsr   r2   r2   r0   r3   r#   A  sT   

&J& ,$H)c                   @  s   e Zd ZdddddZdS )r%   r"   r'   runsr*   c                 C  sX   t |j| _t|j| _t|j| _t|j| _t|j| _t|j| _t|j| _d S r+   )	r
   r$   r   rV   r_   re   ru   ry   r   r/   r   r2   r2   r3   r-   d  s&    zRunsWithRawResponse.__init__Nr   r   r   r-   r2   r2   r2   r3   r%   c  s   r%   c                   @  s   e Zd ZdddddZdS )r   r#   r'   r   c                 C  sX   t |j| _t|j| _t|j| _t|j| _t|j| _t|j| _t|j| _d S r+   )	r   r$   r   rV   r_   re   ru   ry   r   r   r2   r2   r3   r-   |  s&    z!AsyncRunsWithRawResponse.__init__Nr   r2   r2   r2   r3   r   {  s   r   )0
__future__r   typingr   r   r   Ztyping_extensionsr   Zhttpxr$   r   r	   r
   r   _typesr   r   r   r   r   _utilsr   Z	_resourcer   r   	_responser   r   Z
paginationr   r   Z_base_clientr   r   Ztypes.beta.threadsr   r   r   r   r   Z_clientr    r!   __all__r"   r#   r%   r   r2   r2   r2   r3   <module>   s,     $  $