
    iz                       d dl mZ d dlZd dl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mZmZ ddl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( ddl)m*Z* ddl+m,Z, ddl-m.Z. ddl/m0Z0 ddgZ1 G d de          Z2 G d de          Z3 G d d          Z4 G d d          Z5 G d d          Z6 G d d          Z7dS )    )annotationsN)UnionIterableOptional)Literal   )_legacy_response)BodyOmitQueryHeadersNotGivenomit	not_given)path_templatemaybe_transformasync_maybe_transform)cached_property)SyncAPIResourceAsyncAPIResource)to_streamed_response_wrapper"async_to_streamed_response_wrapper)SyncCursorPageAsyncCursorPage)AsyncPaginatormake_request_options)message_list_paramsmessage_create_paramsmessage_update_params)Message)Metadata)MessageDeleted)MessageContentPartParamMessagesAsyncMessagesc                     e Zd ZdZed0d            Zed1d            Z ej        d          e	e	ddde
d	d2d            Z ej        d          ddde
dd3d             Z ej        d          e	ddde
d!d4d"            Z ej        d          e	e	e	e	e	ddde
d#	d5d-            Z ej        d          ddde
dd6d/            ZdS )7r$   4Build Assistants that can call models and use tools.returnMessagesWithRawResponsec                     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
        )r)   selfs    m/home/ubuntu/.hermes/hermes-agent/venv/lib/python3.11/site-packages/openai/resources/beta/threads/messages.pywith_raw_responsezMessages.with_raw_response"   s     't,,,    MessagesWithStreamingResponsec                     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
        )r1   r,   s    r.   with_streaming_responsez Messages.with_streaming_response,   s     -T222r0   >The Assistants API is deprecated in favor of the Responses APINattachmentsmetadataextra_headersextra_query
extra_bodytimeout	thread_idstrcontent-Union[str, Iterable[MessageContentPartParam]]roleLiteral['user', 'assistant']r7   ;Optional[Iterable[message_create_params.Attachment]] | Omitr8   Optional[Metadata] | Omitr9   Headers | Noner:   Query | Noner;   Body | Noner<   'float | httpx.Timeout | None | NotGivenr    c          
         |st          d|          ddi|pi }|                     t          d|          t          ||||dt          j                  t          ||||	          t                    S )	/  
        Create a message.

        Args:
          content: The text contents of the message.

          role:
              The role of the entity that is creating the message. Allowed values include:

              - `user`: Indicates the message is sent by an actual user and should be used in
                most cases to represent user-generated messages.
              - `assistant`: Indicates the message is generated by the assistant. Use this
                value to insert messages from the assistant into the conversation.

          attachments: A list of files attached to the message, and the tools they should be added to.

          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.

          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
        8Expected a non-empty value for `thread_id` but received OpenAI-Betaassistants=v2/threads/{thread_id}/messagesr=   r?   rA   r7   r8   r9   r:   r;   r<   bodyoptionscast_to)
ValueError_postr   r   r   MessageCreateParamsr   r    
r-   r=   r?   rA   r7   r8   r9   r:   r;   r<   s
             r.   createzMessages.create5   s    ^  	geXaeefff&QM<ORQzz9YOOO & #. (	  &9  )+Q[el     
 
 	
r0   rQ   
message_idc          	         |st          d|          |st          d|          ddi|pi }|                     t          d||          t          ||||          t                    S )	G  
        Retrieve a message.

        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
        rK   9Expected a non-empty value for `message_id` but received rL   rM   */threads/{thread_id}/messages/{message_id}r=   r[   rQ   rT   rU   rV   _getr   r   r    r-   r[   r=   r9   r:   r;   r<   s          r.   retrievezMessages.retrievex   s    2  	geXaeefff 	igYcgghhh&QM<ORQyyFR[hrsss(+Q[el     
 
 	
r0   r8   r9   r:   r;   r<   c          
        |st          d|          |st          d|          ddi|pi }|                     t          d||          t          d|it          j                  t          ||||          t          	          S )
  
        Modifies a message.

        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, 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.

          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
        rK   r^   rL   rM   r_   r`   r8   rQ   rR   )rV   rW   r   r   r   MessageUpdateParamsr   r    r-   r[   r=   r8   r9   r:   r;   r<   s           r.   updatezMessages.update   s    B  	geXaeefff 	igYcgghhh&QM<ORQzzFR[hrsss *h!79N9bcc(+Q[el     
 
 	
r0   	afterbeforelimitorderrun_idr9   r:   r;   r<   rm   
str | Omitrn   ro   
int | Omitrp   Literal['asc', 'desc'] | Omitrq   SyncCursorPage[Message]c       	           |st          d|          ddi|pi }|                     t          d|          t          t                   t          |||	|
t          |||||dt          j                            t                    S 	ah  
        Returns a list of messages for a given 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,
              starting 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.

          run_id: Filter messages by the run ID that generated them.

          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
        rK   rL   rM   rN   rO   )rm   rn   ro   rp   rq   )r9   r:   r;   r<   query)pagerT   model)	rV   _get_api_listr   r   r    r   r   r   MessageListParamsr-   r=   rm   rn   ro   rp   rq   r9   r:   r;   r<   s              r.   listzMessages.list   s    ^  	geXaeefff&QM<ORQ!!9YOOO((+'%%!&"(!&!&"(  (9	 	    ' " 
 
 	
r0   r"   c          	         |st          d|          |st          d|          ddi|pi }|                     t          d||          t          ||||          t                    S )	F  
        Deletes a message.

        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
        rK   r^   rL   rM   r_   r`   rQ   ra   rV   _deleter   r   r"   rd   s          r.   deletezMessages.delete  s    2  	geXaeefff 	igYcgghhh&QM<ORQ||FR[hrsss(+Q[el   #  
 
 	
r0   )r(   r)   )r(   r1   r=   r>   r?   r@   rA   rB   r7   rC   r8   rD   r9   rE   r:   rF   r;   rG   r<   rH   r(   r    r[   r>   r=   r>   r9   rE   r:   rF   r;   rG   r<   rH   r(   r    r[   r>   r=   r>   r8   rD   r9   rE   r:   rF   r;   rG   r<   rH   r(   r    )r=   r>   rm   rr   rn   rr   ro   rs   rp   rt   rq   rr   r9   rE   r:   rF   r;   rG   r<   rH   r(   ru   r[   r>   r=   r>   r9   rE   r:   rF   r;   rG   r<   rH   r(   r"   __name__
__module____qualname____doc__r   r/   r4   typing_extensions
deprecatedr   r   rZ   re   rk   r~   r    r0   r.   r$   r$      s       >>- - - _- 3 3 3 _3 "!"bcc TX.2 )-$("&;D@
 @
 @
 @
 @
 dc@
D "!"bcc )-$("&;D#
 #
 #
 #
 #
 dc#
J "!"bcc /3 )-$("&;D,
 ,
 ,
 ,
 ,
 dc,
\ "!"bcc
 !! /3! )-$("&;DE
 E
 E
 E
 E
 dcE
N "!"bcc )-$("&;D#
 #
 #
 #
 #
 dc#
 #
 #
r0   c                     e Zd ZdZed0d            Zed1d            Z ej        d          e	e	ddde
d	d2d            Z ej        d          ddde
dd3d             Z ej        d          e	ddde
d!d4d"            Z ej        d          e	e	e	e	e	ddde
d#	d5d-            Z ej        d          ddde
dd6d/            ZdS )7r%   r'   r(   AsyncMessagesWithRawResponsec                     t          |           S r+   )r   r,   s    r.   r/   zAsyncMessages.with_raw_response?  s     ,D111r0   "AsyncMessagesWithStreamingResponsec                     t          |           S r3   )r   r,   s    r.   r4   z%AsyncMessages.with_streaming_responseI  s     2$777r0   r5   Nr6   r=   r>   r?   r@   rA   rB   r7   rC   r8   rD   r9   rE   r:   rF   r;   rG   r<   rH   r    c          
       K   |st          d|          ddi|pi }|                     t          d|          t          ||||dt          j                   d{V t          ||||	          t          	           d{V S )
rJ   rK   rL   rM   rN   rO   rP   NrQ   rR   )rV   rW   r   r   r   rX   r   r    rY   s
             r.   rZ   zAsyncMessages.createR  s      ^  	geXaeefff&QM<ORQZZ9YOOO,& #. (	  &9        )+Q[el      
 
 
 
 
 
 
 
 	
r0   rQ   r[   c          	        K   |st          d|          |st          d|          ddi|pi }|                     t          d||          t          ||||          t                     d	{V S )
r]   rK   r^   rL   rM   r_   r`   rQ   ra   Nrb   rd   s          r.   re   zAsyncMessages.retrieve  s      2  	geXaeefff 	igYcgghhh&QM<ORQYYFR[hrsss(+Q[el     
 
 
 
 
 
 
 
 	
r0   rf   c          
     0  K   |st          d|          |st          d|          ddi|pi }|                     t          d||          t          d|it          j                   d{V t          ||||	          t          
           d{V S )rh   rK   r^   rL   rM   r_   r`   r8   NrQ   rR   )rV   rW   r   r   r   ri   r   r    rj   s           r.   rk   zAsyncMessages.update  s      B  	geXaeefff 	igYcgghhh&QM<ORQZZFR[hrsss,j(-CEZEnoooooooo(+Q[el      
 
 
 
 
 
 
 
 	
r0   rl   rm   rr   rn   ro   rs   rp   rt   rq   1AsyncPaginator[Message, AsyncCursorPage[Message]]c       	           |st          d|          ddi|pi }|                     t          d|          t          t                   t          |||	|
t          |||||dt          j                            t                    S rw   )	rV   r{   r   r   r    r   r   r   r|   r}   s              r.   r~   zAsyncMessages.list  s    ^  	geXaeefff&QM<ORQ!!9YOOO )(+'%%!&"(!&!&"(  (9	 	    ' " 
 
 	
r0   r"   c          	        K   |st          d|          |st          d|          ddi|pi }|                     t          d||          t          ||||          t                     d	{V S )
r   rK   r^   rL   rM   r_   r`   rQ   ra   Nr   rd   s          r.   r   zAsyncMessages.delete2  s      2  	geXaeefff 	igYcgghhh&QM<ORQ\\FR[hrsss(+Q[el   # " 
 
 
 
 
 
 
 
 	
r0   )r(   r   )r(   r   r   r   r   )r=   r>   rm   rr   rn   rr   ro   rs   rp   rt   rq   rr   r9   rE   r:   rF   r;   rG   r<   rH   r(   r   r   r   r   r0   r.   r%   r%   <  s       >>2 2 2 _2 8 8 8 _8 "!"bcc TX.2 )-$("&;D@
 @
 @
 @
 @
 dc@
D "!"bcc )-$("&;D#
 #
 #
 #
 #
 dc#
J "!"bcc /3 )-$("&;D,
 ,
 ,
 ,
 ,
 dc,
\ "!"bcc
 !! /3! )-$("&;DE
 E
 E
 E
 E
 dcE
N "!"bcc )-$("&;D#
 #
 #
 #
 #
 dc#
 #
 #
r0   c                      e Zd ZddZdS )r)   messagesr$   r(   Nonec                @   || _         t          j        |j                  | _        t          j        |j                  | _        t          j        |j                  | _        t          j        |j                  | _        t          j        |j                  | _        d S N)	_messagesr	   to_raw_response_wrapperrZ   re   rk   r~   r   r-   r   s     r.   __init__z MessagesWithRawResponse.__init__Z  s    ! 4  	 4!  	 4  	 4  		 4  	r0   Nr   r$   r(   r   r   r   r   r   r   r0   r.   r)   r)   Y  (        
 
 
 
 
 
r0   r)   c                      e Zd Z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                  | _        d S r   )r   r	   async_to_raw_response_wrapperrZ   re   rk   r~   r   r   s     r.   r   z%AsyncMessagesWithRawResponse.__init__y  s    ! :  	 :!  	 :  	 :  		 :  	r0   Nr   r%   r(   r   r   r   r0   r.   r   r   x  r   r0   r   c                      e Zd ZddZdS )r1   r   r$   r(   r   c                   || _         t          |j                  | _        t          |j                  | _        t          |j                  | _        t          |j                  | _        t          |j                  | _        d S r   )r   r   rZ   re   rk   r~   r   r   s     r.   r   z&MessagesWithStreamingResponse.__init__  s    ! )  	 )!  	 )  	 )  		 )  	r0   Nr   r   r   r0   r.   r1   r1     r   r0   r1   c                      e Zd ZddZdS )r   r   r%   r(   r   c                   || _         t          |j                  | _        t          |j                  | _        t          |j                  | _        t          |j                  | _        t          |j                  | _        d S r   )r   r   rZ   re   rk   r~   r   r   s     r.   r   z+AsyncMessagesWithStreamingResponse.__init__  s    ! /  	 /!  	 /  	 /  		 /  	r0   Nr   r   r   r0   r.   r   r     r   r0   r   )8
__future__r   r   typingr   r   r   r   httpx r	   _typesr
   r   r   r   r   r   r   _utilsr   r   r   _compatr   	_resourcer   r   	_responser   r   
paginationr   r   _base_clientr   r   types.beta.threadsr   r   r   types.beta.threads.messager    types.shared_params.metadatar!   "types.beta.threads.message_deletedr"   -types.beta.threads.message_content_part_paramr#   __all__r$   r%   r)   r   r1   r   r   r0   r.   <module>r      s   # " " " " "     , , , , , , , , , , % % % % % %  ! ! ! ! ! ! L L L L L L L L L L L L L L L L L L L L L L L L L L L L ' ' ' ' ' ' ; ; ; ; ; ; ; ; Z Z Z Z Z Z Z Z : : : : : : : :        e d d d d d d d d d 2 2 2 2 2 2 5 5 5 5 5 5 A A A A A A U U U U U U
'Z
 Z
 Z
 Z
 Z
 Z
 Z
 Z
zZ
 Z
 Z
 Z
 Z
$ Z
 Z
 Z
z
 
 
 
 
 
 
 
>
 
 
 
 
 
 
 
>
 
 
 
 
 
 
 
>
 
 
 
 
 
 
 
 
 
r0   