
    +h^T                    H   d dl mZ d dlmZmZ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 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!m"Z"m#Z#m$Z$ ddl%m&Z& ddl'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      Z0y)    )annotations)TYPE_CHECKINGListOptionalN   )Runs	AsyncRunsRunsWithRawResponseAsyncRunsWithRawResponse)MessagesAsyncMessagesMessagesWithRawResponseAsyncMessagesWithRawResponse   )	NOT_GIVENBodyQueryHeadersNotGiven)maybe_transform)SyncAPIResourceAsyncAPIResource)to_raw_response_wrapperasync_to_raw_response_wrapper)ThreadThreadDeletedthread_create_paramsthread_update_paramsthread_create_and_run_params)make_request_options)Run)OpenAIAsyncOpenAIThreadsAsyncThreadsc            
      >    e Zd ZU ded<   ded<   ded<   d fdZ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ddded	 	 	 	 	 	 	 	 	 	 	 ddZ	eeeeeddded		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ
 xZS )r$   r   runsr   messagesThreadsWithRawResponsewith_raw_responsec                    t         |   |       t        |      | _        t	        |      | _        t        |       | _        y N)super__init__r   r'   r   r(   r)   r*   selfclient	__class__s     X/var/www/html/venv/lib/python3.12/site-packages/openai/resources/beta/threads/threads.pyr.   zThreads.__init__)   s4     L	 (!7!=    Nr(   metadataextra_headersextra_query
extra_bodytimeoutc          
         ddi|xs i }| j                  dt        ||dt        j                        t	        ||||      t
              S )	  
        Create a thread.

        Args:
          messages: A list of [messages](https://platform.openai.com/docs/api-reference/messages) to
              start the thread with.

          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
        OpenAI-Betaassistants=v1/threadsr(   r6   r7   r8   r9   r:   bodyoptionscast_to_postr   r   ThreadCreateParamsr    r   r0   r(   r6   r7   r8   r9   r:   s          r3   createzThreads.create/   sj    @ 'QM<ORQzz  ( ( %77 )+Q[el   
 	
r4   rA   c          	     f    ddi|xs i }| j                  d| t        ||||      t              S )G  
        Retrieves a thread.

        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>   	/threads/rA   rD   rE   _getr    r   r0   	thread_idr7   r8   r9   r:   s         r3   retrievezThreads.retrieve_   sP    . 'QM<ORQyy	{#(+Q[el   
 	
r4   r6   r7   r8   r9   r:   c          
         ddi|xs i }| j                  d| t        d|it        j                        t	        ||||      t
              S )  
        Modifies a thread.

        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>   rM   r6   rA   rB   rG   r   r   ThreadUpdateParamsr    r   r0   rR   r6   r7   r8   r9   r:   s          r3   updatezThreads.update   sf    : 'QM<ORQzz	{# *h!79M9`9`a(+Q[el   
 	
r4   c          	     f    ddi|xs i }| j                  d| t        ||||      t              S )D  
        Delete a thread.

        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>   rM   rA   rN   _deleter    r   rQ   s         r3   deletezThreads.delete   sP    . 'QM<ORQ||	{#(+Q[el "  
 	
r4   	instructionsr6   modelthreadtoolsr7   r8   r9   r:   c       
            ddi|xs i }| j                  dt        ||||||dt        j                        t	        |||	|
      t
              S )  
        Create a thread and run it in one request.

        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.

          thread: If no thread is provided, an empty thread will be created.

          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
        r=   r>   /threads/runsassistant_idra   r6   rb   rc   rd   rA   rB   rG   r   r   ThreadCreateAndRunParamsr    r!   r0   ri   ra   r6   rb   rc   rd   r7   r8   r9   r:   s              r3   create_and_runzThreads.create_and_run   sv    d 'QM<ORQzz $0$0 ("$" -EE
 )+Q[el !  
 	
r4   )r1   r"   returnNoner(   z-List[thread_create_params.Message] | NotGivenr6   Optional[object] | NotGivenr7   Headers | Noner8   Query | Noner9   Body | Noner:   'float | httpx.Timeout | None | NotGivenrn   r   rR   strr7   rr   r8   rs   r9   rt   r:   ru   rn   r   rR   rw   r6   rq   r7   rr   r8   rs   r9   rt   r:   ru   rn   r   rR   rw   r7   rr   r8   rs   r9   rt   r:   ru   rn   r   ri   rw   ra   Optional[str] | NotGivenr6   rq   rb   r{   rc   z.thread_create_and_run_params.Thread | NotGivenrd   z<Optional[List[thread_create_and_run_params.Tool]] | NotGivenr7   rr   r8   rs   r9   rt   r:   ru   rn   r!   __name__
__module____qualname____annotations__r.   r   rJ   rS   rZ   r_   rm   __classcell__r2   s   @r3   r$   r$   $   s   
J--> CL09 )-$("&;D.
 @.
 .	.
 &.
 ".
  .
 9.
 
.
l )-$("&;D

 &
 "
  
 9
 

H 1: )-$("&;D%
%
 .	%
 &%
 "%
  %
 9%
 
%
Z )-$("&;D

 &
 "
  
 9
 

H 2;09*3AJNW )-$("&;DD
 D
 /	D

 .D
 (D
 ?D
 LD
 &D
 "D
  D
 9D
 
D
r4   c            
      >    e Zd ZU ded<   ded<   ded<   d fdZ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ddded	 	 	 	 	 	 	 	 	 	 	 ddZ	eeeeeddded		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ
 xZS )r%   r	   r'   r   r(   AsyncThreadsWithRawResponser*   c                    t         |   |       t        |      | _        t	        |      | _        t        |       | _        y r,   )r-   r.   r	   r'   r   r(   r   r*   r/   s     r3   r.   zAsyncThreads.__init__  s5     f%	%f-!<T!Br4   Nr5   c          
        K   ddi|xs i }| j                  dt        ||dt        j                        t	        ||||      t
               d{   S 7 w)r<   r=   r>   r?   r@   rA   rB   NrF   rI   s          r3   rJ   zAsyncThreads.create  sx     @ 'QM<ORQZZ  ( ( %77 )+Q[el    
 
 	
 
s   AAAArA   c          	        K   ddi|xs i }| j                  d| t        ||||      t               d{   S 7 w)rL   r=   r>   rM   rA   rN   NrO   rQ   s         r3   rS   zAsyncThreads.retrieveH  s^     . 'QM<ORQYY	{#(+Q[el   
 
 	
 
   6?=?rT   c          
        K   ddi|xs i }| j                  d| t        d|it        j                        t	        ||||      t
               d{   S 7 w)rV   r=   r>   rM   r6   rA   rB   NrW   rY   s          r3   rZ   zAsyncThreads.updateh  st     : 'QM<ORQZZ	{# *h!79M9`9`a(+Q[el    
 
 	
 
s   AAAAc          	        K   ddi|xs i }| j                  d| t        ||||      t               d{   S 7 w)r\   r=   r>   rM   rA   rN   Nr]   rQ   s         r3   r_   zAsyncThreads.delete  s^     . 'QM<ORQ\\	{#(+Q[el " " 
 
 	
 
r   r`   c       
           K   ddi|xs i }| j                  dt        ||||||dt        j                        t	        |||	|
      t
               d{   S 7 w)rf   r=   r>   rg   rh   rA   rB   Nrj   rl   s              r3   rm   zAsyncThreads.create_and_run  s     d 'QM<ORQZZ $0$0 ("$" -EE
 )+Q[el !   
 
 	
 
s   AAAA)r1   r#   rn   ro   rp   rv   rx   ry   rz   r|   r   s   @r3   r%   r%     s   
O22C CL09 )-$("&;D.
 @.
 .	.
 &.
 ".
  .
 9.
 
.
l )-$("&;D

 &
 "
  
 9
 

H 1: )-$("&;D%
%
 .	%
 &%
 "%
  %
 9%
 
%
Z )-$("&;D

 &
 "
  
 9
 

H 2;09*3AJNW )-$("&;DD
 D
 /	D

 .D
 (D
 ?D
 LD
 &D
 "D
  D
 9D
 
D
r4   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   r(   r   rJ   rS   rZ   r_   rm   r0   threadss     r3   r.   zThreadsWithRawResponse.__init__  s    '5	/0@0@A-NN
 0
 .NN
 .NN
 6""
r4   N)r   r$   rn   ro   r}   r~   r   r.    r4   r3   r)   r)         
r4   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   r(   r   rJ   rS   rZ   r_   rm   r   s     r3   r.   z$AsyncThreadsWithRawResponse.__init__  s    ,W\\:	4W5E5EF3NN
 6
 4NN
 4NN
 <""
r4   N)r   r%   rn   ro   r   r   r4   r3   r   r     r   r4   r   )1
__future__r   typingr   r   r   httpxr'   r   r	   r
   r   r(   r   r   r   r   _typesr   r   r   r   r   _utilsr   	_resourcer   r   	_responser   r   
types.betar   r   r   r   r   _base_clientr    types.beta.threadsr!   _clientr"   r#   __all__r$   r%   r)   r   r   r4   r3   <module>r      s    # 0 0  P P  A @ & ; P  2 &/n
%f
o f
Rf
# f
R
 
,
 
r4   