
    +hhg                    D   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rddl(m)Z)m*Z* ddgZ+ G d de      Z, G d de      Z- G d d      Z. G d d      Z/y)    )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            	          e Zd ZU ded<   ded<   d fdZeeeeddded	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZddded		 	 	 	 	 	 	 	 	 	 	 	 	 dd
Zeddded	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZee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 xZS )r#   r	   stepsRunsWithRawResponsewith_raw_responsec                d    t         |   |       t        |      | _        t	        |       | _        y N)super__init__r	   r&   r'   r(   selfclient	__class__s     Z/var/www/html/venv/lib/python3.12/site-packages/openai/resources/beta/threads/runs/runs.pyr,   zRuns.__init__#   s(     6]
!4T!:    Ninstructionsmetadatamodeltoolsextra_headersextra_query
extra_bodytimeoutc       	            ddi|xs i }| j                  d| dt        |||||dt        j                        t	        |||	|
      t
              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assistant_idr4   r5   r6   r7   r8   r9   r:   r;   bodyoptionscast_to_postr   r   RunCreateParamsr   r   r.   	thread_idrC   r4   r5   r6   r7   r8   r9   r:   r;   s              r1   createzRuns.create(   s|    ` 'QM<ORQzz	{%( $0$0 ("" "11	 )+Q[el   
 	
r2   rD   c          	     l    ddi|xs i }| j                  d| d| t        ||||      t              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
        r>   r?   r@   /runs/rD   rG   rH   _getr   r   r.   run_idrM   r8   r9   r:   r;   s          r1   retrievezRuns.retrievek   sV    0 'QM<ORQyy	{&1(+Q[el   
 	
r2   r5   r8   r9   r:   r;   c          
         ddi|xs i }| j                  d| d| t        d|it        j                        t	        ||||      t
              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
        r>   r?   r@   rQ   r5   rD   rE   rJ   r   r   RunUpdateParamsr   r   r.   rV   rM   r5   r8   r9   r:   r;   s           r1   updatezRuns.update   sl    < 'QM<ORQzz	{&1 *h!79J9Z9Z[(+Q[el   
 	
r2   afterbeforelimitorderr8   r9   r:   r;   c                   ddi|xs i }| j                  d| dt        t           t        ||||	t	        ||||dt
        j                              t              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
        r>   r?   r@   rA   )r`   ra   rb   rc   )r8   r9   r:   r;   query)pagerG   r6   )_get_api_listr   r   r   r   r   RunListParams
r.   rM   r`   ra   rb   rc   r8   r9   r:   r;   s
             r1   listz	Runs.list   s    V 'QM<ORQ!!	{%($(+'%%!&"(!&!&	 $11 % " 
 	
r2   c          	     n    ddi|xs i }| j                  d| d| dt        ||||      t              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
        r>   r?   r@   rQ   /cancelrD   rR   rJ   r   r   rU   s          r1   cancelzRuns.cancel   sX    0 'QM<ORQzz	{&8(+Q[el   
 	
r2   c          
         ddi|xs i }| j                  d| d| dt        d|it        j                        t	        ||||      t
              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
        r>   r?   r@   rQ   /submit_tool_outputstool_outputsrD   rE   rJ   r   r    RunSubmitToolOutputsParamsr   r   r.   rV   rM   rt   r8   r9   r:   r;   s           r1   submit_tool_outputszRuns.submit_tool_outputs  st    < 'QM<ORQzz	{&0DE .0N0i0i )+Q[el   	
 		
r2   )r/   r!   returnNonerM   strrC   r|   r4   Optional[str] | NotGivenr5   Optional[object] | NotGivenr6   r}   r7   z1Optional[List[run_create_params.Tool]] | NotGivenr8   Headers | Noner9   Query | Noner:   Body | Noner;   'float | httpx.Timeout | None | NotGivenry   r   rV   r|   rM   r|   r8   r   r9   r   r:   r   r;   r   ry   r   rV   r|   rM   r|   r5   r~   r8   r   r9   r   r:   r   r;   r   ry   r   )rM   r|   r`   str | NotGivenra   r   rb   int | NotGivenrc   !Literal['asc', 'desc'] | NotGivenr8   r   r9   r   r:   r   r;   r   ry   zSyncCursorPage[Run]rV   r|   rM   r|   rt   z/List[run_submit_tool_outputs_params.ToolOutput]r8   r   r9   r   r:   r   r;   r   ry   r   __name__
__module____qualname____annotations__r,   r   rN   rW   r^   rk   rp   rx   __classcell__r0   s   @r1   r#   r#      s   L**; 2;09*3CL )-$("&;DA
A
 	A

 /A
 .A
 (A
 AA
 &A
 "A
  A
 9A
 
A
T )-$("&;D

 	
 &
 "
  
 9
 

L 1: )-$("&;D&
&
 	&

 .&
 &&
 "&
  &
 9&
 
&
X !*!* )3< )-$("&;D?
?
 	?

 ?
 ?
 1?
 &?
 "?
  ?
 9?
 
?
P )-$("&;D

 	
 &
 "
  
 9
 

R )-$("&;D(
(
 	(

 F(
 &(
 "(
  (
 9(
 
(
r2   c            	          e Zd ZU ded<   ded<   d fdZeeeeddded	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZddded		 	 	 	 	 	 	 	 	 	 	 	 	 dd
Zeddded	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZee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 xZS )r$   r
   r&   AsyncRunsWithRawResponser(   c                d    t         |   |       t        |      | _        t	        |       | _        y r*   )r+   r,   r
   r&   r   r(   r-   s     r1   r,   zAsyncRuns.__init__E  s)     '
!9$!?r2   Nr3   c       	           K   ddi|xs i }| j                  d| dt        |||||dt        j                        t	        |||	|
      t
               d{   S 7 w)	r=   r>   r?   r@   rA   rB   rD   rE   NrI   rL   s              r1   rN   zAsyncRuns.createJ  s     ` 'QM<ORQZZ	{%( $0$0 ("" "11	 )+Q[el    
 
 	
 
s   AAAArD   c          	        K   ddi|xs i }| j                  d| d| t        ||||      t               d{   S 7 w)rP   r>   r?   r@   rQ   rD   rR   NrS   rU   s          r1   rW   zAsyncRuns.retrieve  sd     0 'QM<ORQYY	{&1(+Q[el   
 
 	
 
s   9AA ArX   c          
        K   ddi|xs i }| j                  d| d| t        d|it        j                        t	        ||||      t
               d{   S 7 w)	rZ   r>   r?   r@   rQ   r5   rD   rE   Nr[   r]   s           r1   r^   zAsyncRuns.update  sz     < 'QM<ORQZZ	{&1 *h!79J9Z9Z[(+Q[el    
 
 	
 
s   AAAAr_   c                   ddi|xs i }| j                  d| dt        t           t        ||||	t	        ||||dt
        j                              t              S re   )rh   r   r   r   r   r   ri   rj   s
             r1   rk   zAsyncRuns.list  s    V 'QM<ORQ!!	{%( %(+'%%!&"(!&!&	 $11 % " 
 	
r2   c          	        K   ddi|xs i }| j                  d| d| dt        ||||      t               d{   S 7 w)	rm   r>   r?   r@   rQ   rn   rD   rR   Nro   rU   s          r1   rp   zAsyncRuns.cancel  sf     0 'QM<ORQZZ	{&8(+Q[el    
 
 	
 
s   :AAAc          
        K   ddi|xs i }| j                  d| d| dt        d|it        j                        t	        ||||      t
               d	{   S 7 w)
rr   r>   r?   r@   rQ   rs   rt   rD   rE   Nru   rw   s           r1   rx   zAsyncRuns.submit_tool_outputs8  s     < 'QM<ORQZZ	{&0DE .0N0i0i )+Q[el    	
 	
 		
 	
s   AAAA)r/   r"   ry   rz   r{   r   r   )rM   r|   r`   r   ra   r   rb   r   rc   r   r8   r   r9   r   r:   r   r;   r   ry   z)AsyncPaginator[Run, AsyncCursorPage[Run]]r   r   r   s   @r1   r$   r$   A  s   //@ 2;09*3CL )-$("&;DA
A
 	A

 /A
 .A
 (A
 AA
 &A
 "A
  A
 9A
 
A
T )-$("&;D

 	
 &
 "
  
 9
 

L 1: )-$("&;D&
&
 	&

 .&
 &&
 "&
  &
 9&
 
&
X !*!* )3< )-$("&;D?
?
 	?

 ?
 ?
 1?
 &?
 "?
  ?
 9?
 
3?
P )-$("&;D

 	
 &
 "
  
 9
 

R )-$("&;D(
(
 	(

 F(
 &(
 "(
  (
 9(
 
(
r2   c                      e Zd ZddZy)r'   c                p   t        |j                        | _        t        |j                        | _        t        |j                        | _        t        |j
                        | _        t        |j                        | _        t        |j                        | _        t        |j                        | _        y r*   )	r   r&   r   rN   rW   r^   rk   rp   rx   r.   runss     r1   r,   zRunsWithRawResponse.__init__d  s    )$**5
-KK
 0MM
 .KK
 ,II
	 .KK
 $;$$$
 r2   N)r   r#   ry   rz   r   r   r   r,    r2   r1   r'   r'   c      
r2   r'   c                      e Zd ZddZy)r   c                p   t        |j                        | _        t        |j                        | _        t        |j                        | _        t        |j
                        | _        t        |j                        | _        t        |j                        | _        t        |j                        | _        y r*   )	r   r&   r   rN   rW   r^   rk   rp   rx   r   s     r1   r,   z!AsyncRunsWithRawResponse.__init__|  s    .tzz:
3KK
 6MM
 4KK
 2II
	 4KK
 $A$$$
 r2   N)r   r$   ry   rz   r   r   r2   r1   r   r   {  r   r2   r   )0
__future__r   typingr   r   r   typing_extensionsr   httpxr&   r	   r
   r   r   _typesr   r   r   r   r   _utilsr   	_resourcer   r   	_responser   r   
paginationr   r   _base_clientr   r   types.beta.threadsr   r   r   r   r    _clientr!   r"   __all__r#   r$   r'   r   r   r2   r1   <module>r      s    # 0 0 %  U U A A ' < Q ; B  0;
_
? _
D	_
  _
D	
 
0
 
r2   