
    2Rj)~                       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      Z7y)    )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dd       Zedd       Z ej                  d      e	e	ddde
d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Z ej                  d      ddde
d	 	 	 	 	 	 	 	 	 	 	 	 	 dd	       Z ej                  d      e	ddde
d
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Z ej                  d      e	e	e	e	e	ddde
d		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Z ej                  d      ddde
d	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Zy)r$   4Build Assistants that can call models and use tools.c                    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
        )MessagesWithRawResponseselfs    n/var/www/html/meridian/meridian-ai/venv/lib/python3.12/site-packages/openai/resources/beta/threads/messages.pywith_raw_responsezMessages.with_raw_response"   s     't,,    c                    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
        )MessagesWithStreamingResponser+   s    r-   with_streaming_responsez Messages.with_streaming_response,   s     -T22r/   >The Assistants API is deprecated in favor of the Responses APINattachmentsmetadataextra_headersextra_query
extra_bodytimeoutc                   |st        d|      ddi|xs i }| j                  t        d|      t        ||||dt        j
                        t        ||||	ddi	      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	thread_idcontentroler6   r7   bearer_authTr8   r9   r:   r;   securitybodyoptionscast_to)
ValueError_postr   r   r   MessageCreateParamsr   r    
r,   rC   rE   rF   r6   r7   r8   r9   r:   r;   s
             r-   createzMessages.create5   s    ^ WXaWdeff&QM<ORQzz9YO & #. (	 &99 )+'%'. %  
 	
r/   r8   r9   r:   r;   c                   |st        d|      |st        d|      ddi|xs i }| j                  t        d||      t        ||||ddi	      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
        r>   9Expected a non-empty value for `message_id` but received r?   r@   */threads/{thread_id}/messages/{message_id}rC   
message_idrG   TrH   rL   rM   rN   _getr   r   r    r,   rY   rC   r8   r9   r:   r;   s          r-   retrievezMessages.retrieve|   s    2 WXaWdeffXYcXfghh&QM<ORQyyFR[hrs(+'%'.   

 
	
r/   r7   r8   r9   r:   r;   c                   |st        d|      |st        d|      ddi|xs i }| j                  t        d||      t        d|it        j
                        t        ||||dd	i
      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
        r>   rV   r?   r@   rW   rX   r7   rG   TrH   rJ   )rN   rO   r   r   r   MessageUpdateParamsr   r    r,   rY   rC   r7   r8   r9   r:   r;   s           r-   updatezMessages.update   s    B WXaWdeffXYcXfghh&QM<ORQzzFR[hrs *h!79N9b9bc(+'%'.   
 	
r/   	afterbeforelimitorderrun_idr8   r9   r:   r;   c       	            |st        d|      ddi|xs i }| j                  t        d|      t        t           t        |||	|
t        |||||dt        j                        ddi	      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
        r>   r?   r@   rA   rB   )rf   rg   rh   ri   rj   rG   T)r8   r9   r:   r;   queryrI   )pagerL   model)	rN   _get_api_listr   r   r    r   r   r   MessageListParamsr,   rC   rf   rg   rh   ri   rj   r8   r9   r:   r;   s              r-   listzMessages.list   s    ^ WXaWdeff&QM<ORQ!!9YO((+'%%!&"(!&!&"( (99	 (." ) " 
 	
r/   c                   |st        d|      |st        d|      ddi|xs i }| j                  t        d||      t        ||||ddi	      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
        r>   rV   r?   r@   rW   rX   rG   TrH   rZ   rN   _deleter   r   r"   r]   s          r-   deletezMessages.delete"  s    2 WXaWdeffXYcXfghh&QM<ORQ||FR[hrs(+'%'. #  

 
	
r/   )returnr*   )ry   r2   rC   strrE   z-Union[str, Iterable[MessageContentPartParam]]rF   zLiteral['user', 'assistant']r6   z;Optional[Iterable[message_create_params.Attachment]] | Omitr7   Optional[Metadata] | Omitr8   Headers | Noner9   Query | Noner:   Body | Noner;   'float | httpx.Timeout | None | NotGivenry   r    rY   r{   rC   r{   r8   r}   r9   r~   r:   r   r;   r   ry   r    rY   r{   rC   r{   r7   r|   r8   r}   r9   r~   r:   r   r;   r   ry   r    )rC   r{   rf   
str | Omitrg   r   rh   
int | Omitri   Literal['asc', 'desc'] | Omitrj   r   r8   r}   r9   r~   r:   r   r;   r   ry   zSyncCursorPage[Message]rY   r{   rC   r{   r8   r}   r9   r~   r:   r   r;   r   ry   r"   __name__
__module____qualname____doc__r   r.   r3   typing_extensions
deprecatedr   r   rR   r^   rd   rs   rx    r/   r-   r$   r$      s   >- - 3 3 "!!"bc TX.2 )-$("&;DD
D
 ?	D

 +D
 QD
 ,D
 &D
 "D
  D
 9D
 
D
 dD
L "!!"bc )-$("&;D'
'
 	'
 &'
 "'
  '
 9'
 
'
 d'
R "!!"bc /3 )-$("&;D0
0
 	0

 ,0
 &0
 "0
  0
 90
 
0
 d0
d "!!"bc
 !! /3! )-$("&;DF
F
 	F

 F
 F
 -F
 F
 &F
 "F
  F
 9F
 
!F
 dF
P "!!"bc )-$("&;D'
'
 	'
 &'
 "'
  '
 9'
 
'
 d'
r/   c                     e Zd ZdZedd       Zedd       Z ej                  d      e	e	ddde
d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Z ej                  d      ddde
d	 	 	 	 	 	 	 	 	 	 	 	 	 dd	       Z ej                  d      e	ddde
d
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Z ej                  d      e	e	e	e	e	ddde
d		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Z ej                  d      ddde
d	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Zy)r%   r'   c                    t        |       S r)   )AsyncMessagesWithRawResponser+   s    r-   r.   zAsyncMessages.with_raw_responseP  s     ,D11r/   c                    t        |       S r1   )"AsyncMessagesWithStreamingResponser+   s    r-   r3   z%AsyncMessages.with_streaming_responseZ  s     2$77r/   r4   Nr5   c                 K   |st        d|      ddi|xs i }| j                  t        d|      t        ||||dt        j
                         d{   t        ||||	dd	i
      t               d{   S 7 '7 w)r=   r>   r?   r@   rA   rB   rD   NrG   TrH   rJ   )rN   rO   r   r   r   rP   r   r    rQ   s
             r-   rR   zAsyncMessages.createc  s     ^ WXaWdeff&QM<ORQZZ9YO,& #. (	 &99  )+'%'. %   
 
 	

s$   ABA>
"B9B :B BrS   c                  K   |st        d|      |st        d|      ddi|xs i }| j                  t        d||      t        ||||ddi	      t        
       d{   S 7 w)rU   r>   rV   r?   r@   rW   rX   rG   TrH   rZ   Nr[   r]   s          r-   r^   zAsyncMessages.retrieve  s     2 WXaWdeffXYcXfghh&QM<ORQYYFR[hrs(+'%'.   

 

 
	
 

   A"A+$A)%A+r_   c               $  K   |st        d|      |st        d|      ddi|xs i }| j                  t        d||      t        d|it        j
                         d{   t        ||||d	d
i      t               d{   S 7 '7 w)ra   r>   rV   r?   r@   rW   rX   r7   NrG   TrH   rJ   )rN   rO   r   r   r   rb   r   r    rc   s           r-   rd   zAsyncMessages.update  s     B WXaWdeffXYcXfghh&QM<ORQZZFR[hrs,j(-CEZEnEnoo(+'%'.    
 
 	
o
s$   A"B$B
%"BBBBre   c       	            |st        d|      ddi|xs i }| j                  t        d|      t        t           t        |||	|
t        |||||dt        j                        ddi	      t        
      S rl   )	rN   rp   r   r   r    r   r   r   rq   rr   s              r-   rs   zAsyncMessages.list  s    ^ WXaWdeff&QM<ORQ!!9YO )(+'%%!&"(!&!&"( (99	 (." ) " 
 	
r/   c                  K   |st        d|      |st        d|      ddi|xs i }| j                  t        d||      t        ||||ddi	      t        
       d{   S 7 w)ru   r>   rV   r?   r@   rW   rX   rG   TrH   rZ   Nrv   r]   s          r-   rx   zAsyncMessages.deleteP  s     2 WXaWdeffXYcXfghh&QM<ORQ\\FR[hrs(+'%'. # " 

 

 
	
 

r   )ry   r   )ry   r   rz   r   r   )rC   r{   rf   r   rg   r   rh   r   ri   r   rj   r   r8   r}   r9   r~   r:   r   r;   r   ry   z1AsyncPaginator[Message, AsyncCursorPage[Message]]r   r   r   r/   r-   r%   r%   M  s   >2 2 8 8 "!!"bc TX.2 )-$("&;DD
D
 ?	D

 +D
 QD
 ,D
 &D
 "D
  D
 9D
 
D
 dD
L "!!"bc )-$("&;D'
'
 	'
 &'
 "'
  '
 9'
 
'
 d'
R "!!"bc /3 )-$("&;D0
0
 	0

 ,0
 &0
 "0
  0
 90
 
0
 d0
d "!!"bc
 !! /3! )-$("&;DF
F
 	F

 F
 F
 -F
 F
 &F
 "F
  F
 9F
 
;F
 dF
P "!!"bc )-$("&;D'
'
 	'
 &'
 "'
  '
 9'
 
'
 d'
r/   c                      e Zd ZddZy)r*   c                z   || _         t        j                  |j                        | _        t        j                  |j                        | _        t        j                  |j
                        | _        t        j                  |j                        | _        t        j                  |j                        | _        y N)	_messagesr	   to_raw_response_wrapperrR   r^   rd   rs   rx   r,   messagess     r-   __init__z MessagesWithRawResponse.__init__|  s    ! 44 	 44!! 	 44 	 44 		 44 	r/   Nr   r$   ry   Noner   r   r   r   r   r/   r-   r*   r*   {      
r/   r*   c                      e Zd ZddZy)r   c                z   || _         t        j                  |j                        | _        t        j                  |j                        | _        t        j                  |j
                        | _        t        j                  |j                        | _        t        j                  |j                        | _        y r   )r   r	   async_to_raw_response_wrapperrR   r^   rd   rs   rx   r   s     r-   r   z%AsyncMessagesWithRawResponse.__init__  s    ! :: 	 ::!! 	 :: 	 :: 		 :: 	r/   Nr   r%   ry   r   r   r   r/   r-   r   r     r   r/   r   c                      e Zd ZddZy)r2   c                   || _         t        |j                        | _        t        |j                        | _        t        |j                        | _        t        |j
                        | _        t        |j                        | _        y r   )r   r   rR   r^   rd   rs   rx   r   s     r-   r   z&MessagesWithStreamingResponse.__init__  s    ! ) 	 )!! 	 ) 	 ) 		 ) 	r/   Nr   r   r   r/   r-   r2   r2     r   r/   r2   c                      e Zd ZddZy)r   c                   || _         t        |j                        | _        t        |j                        | _        t        |j                        | _        t        |j
                        | _        t        |j                        | _        y r   )r   r   rR   r^   rd   rs   rx   r   s     r-   r   z+AsyncMessagesWithStreamingResponse.__init__  s    ! / 	 /!! 	 / 	 / 		 / 	r/   Nr   r   r   r/   r-   r   r     r   r/   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   r2   r   r   r/   r-   <module>r      s    #  , , %  ! L L L L L ' ; Z : e d 2 5 A U
'k
 k
\	k
$ k
\	
 
>
 
>
 
>
 
r/   