o
    iz                     @  st  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Z1G dd deZ2G dd deZ3G dd dZ4G dd dZ5G dd dZ6G d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d7ddZed8ddZed	e	e	d
d
d
e
dd9dd Zed	d
d
d
e
d!d:d#d$Zed	e	d
d
d
e
d%d;d&d'Zed	e	e	e	e	e	d
d
d
e
d(	d<d2d3Zed	d
d
d
e
d!d=d5d6Zd
S )>r#   4Build Assistants that can call models and use tools.returnMessagesWithRawResponsec                 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
        )r(   self r-   `/home/kim/smarthome/.venv/lib/python3.10/site-packages/openai/resources/beta/threads/messages.pywith_raw_response"      zMessages.with_raw_responseMessagesWithStreamingResponsec                 C  r)   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+   r-   r-   r.   with_streaming_response,      z Messages.with_streaming_response>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          
   	   C  sZ   |s	t d|ddi|pi }| jtd|dt||||dtjt||||	dtd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<   r-   r-   r.   create5   s$   /
	zMessages.createrP   
message_idc                C  Z   |s	t d||st d|ddi|pi }| jtd||dt||||dtd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
        rJ   9Expected a non-empty value for `message_id` but received rK   rL   */threads/{thread_id}/messages/{message_id}r=   rZ   rP   rS   rT   rU   _getr   r   r   r,   rZ   r=   r9   r:   r;   r<   r-   r-   r.   retrievex      zMessages.retriever8   r9   r:   r;   r<   c             	   C  sh   |s	t d||st d|ddi|pi }| jtd||dtd|itjt||||dtd	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
        rJ   r]   rK   rL   r^   r_   r8   rP   rQ   )rU   rV   r   r   r   MessageUpdateParamsr   r   r,   rZ   r=   r8   r9   r:   r;   r<   r-   r-   r.   update   s   !zMessages.update	afterbeforelimitorderrun_idr9   r:   r;   r<   rl   
str | Omitrm   rn   
int | Omitro   Literal['asc', 'desc'] | Omitrp   SyncCursorPage[Message]c       	         C  b   |s	t d|ddi|pi }| jtd|dtt t|||	|
t|||||dtjdtd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
        rJ   rK   rL   rM   rN   )rl   rm   rn   ro   rp   )r9   r:   r;   r<   query)pagerS   model)	rU   _get_api_listr   r   r   r   r   r   MessageListParamsr,   r=   rl   rm   rn   ro   rp   r9   r:   r;   r<   r-   r-   r.   list   .   /
zMessages.listr!   c                C  r[   )	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
        rJ   r]   rK   rL   r^   r_   rP   r`   rU   _deleter   r   r!   rc   r-   r-   r.   delete  re   zMessages.delete)r'   r(   )r'   r1   r=   r>   r?   r@   rA   rB   r7   rC   r8   rD   r9   rE   r:   rF   r;   rG   r<   rH   r'   r   rZ   r>   r=   r>   r9   rE   r:   rF   r;   rG   r<   rH   r'   r   rZ   r>   r=   r>   r8   rD   r9   rE   r:   rF   r;   rG   r<   rH   r'   r   )r=   r>   rl   rq   rm   rq   rn   rr   ro   rs   rp   rq   r9   rE   r:   rF   r;   rG   r<   rH   r'   rt   rZ   r>   r=   r>   r9   rE   r:   rF   r;   rG   r<   rH   r'   r!   __name__
__module____qualname____doc__r   r/   r3   typing_extensions
deprecatedr   r   rY   rd   rj   r}   r   r-   r-   r-   r.   r#      X    	B%.Gc                   @  r%   )>r$   r&   r'   AsyncMessagesWithRawResponsec                 C  r)   r*   )r   r+   r-   r-   r.   r/   ?  r0   zAsyncMessages.with_raw_response"AsyncMessagesWithStreamingResponsec                 C  r)   r2   )r   r+   r-   r-   r.   r3   I  r4   z%AsyncMessages.with_streaming_responser5   Nr6   r=   r>   r?   r@   rA   rB   r7   rC   r8   rD   r9   rE   r:   rF   r;   rG   r<   rH   r   c          
   	     sh   |s
t d|ddi|pi }| jtd|dt||||dtjI dH t||||	dtd	I dH S )
rI   rJ   rK   rL   rM   rN   rO   NrP   rQ   )rU   rV   r   r   r   rW   r   r   rX   r-   r-   r.   rY   R  s&   /
	zAsyncMessages.createrP   rZ   c                  b   |s
t d||st d|ddi|pi }| jtd||dt||||dtdI d	H S )
r\   rJ   r]   rK   rL   r^   r_   rP   r`   Nra   rc   r-   r-   r.   rd        zAsyncMessages.retrieverf   c             	     sv   |s
t d||st d|ddi|pi }| jtd||dtd|itjI dH t||||d	td
I dH S )rg   rJ   r]   rK   rL   r^   r_   r8   NrP   rQ   )rU   rV   r   r   r   rh   r   r   ri   r-   r-   r.   rj     s   !zAsyncMessages.updaterk   rl   rq   rm   rn   rr   ro   rs   rp   1AsyncPaginator[Message, AsyncCursorPage[Message]]c       	         C  ru   rv   )	rU   rz   r   r   r   r   r   r   r{   r|   r-   r-   r.   r}     r~   zAsyncMessages.listr!   c                  r   )
r   rJ   r]   rK   rL   r^   r_   rP   r`   Nr   rc   r-   r-   r.   r   2  r   zAsyncMessages.delete)r'   r   )r'   r   r   r   r   )r=   r>   rl   rq   rm   rq   rn   rr   ro   rs   rp   rq   r9   rE   r:   rF   r;   rG   r<   rH   r'   r   r   r   r-   r-   r-   r.   r$   <  r   c                   @     e Zd ZdddZdS )	r(   messagesr#   r'   Nonec                 C  P   || _ t|j| _t|j| _t|j| _t|j| _t|j| _d S N)	_messagesr   Zto_raw_response_wrapperrY   rd   rj   r}   r   r,   r   r-   r-   r.   __init__Z  *   z MessagesWithRawResponse.__init__Nr   r#   r'   r   r   r   r   r   r-   r-   r-   r.   r(   Y      r(   c                   @  r   )	r   r   r$   r'   r   c                 C  r   r   )r   r   Zasync_to_raw_response_wrapperrY   rd   rj   r}   r   r   r-   r-   r.   r   y  r   z%AsyncMessagesWithRawResponse.__init__Nr   r$   r'   r   r   r-   r-   r-   r.   r   x  r   r   c                   @  r   )	r1   r   r#   r'   r   c                 C  F   || _ t|j| _t|j| _t|j| _t|j| _t|j| _d S r   )r   r   rY   rd   rj   r}   r   r   r-   r-   r.   r     *   z&MessagesWithStreamingResponse.__init__Nr   r   r-   r-   r-   r.   r1     r   r1   c                   @  r   )	r   r   r$   r'   r   c                 C  r   r   )r   r   rY   rd   rj   r}   r   r   r-   r-   r.   r     r   z+AsyncMessagesWithStreamingResponse.__init__Nr   r   r-   r-   r-   r.   r     r   r   )8
__future__r   r   typingr   r   r   r   Zhttpx r   _typesr	   r
   r   r   r   r   r   Z_utilsr   r   r   Z_compatr   Z	_resourcer   r   	_responser   r   Z
paginationr   r   Z_base_clientr   r   Ztypes.beta.threadsr   r   r   Ztypes.beta.threads.messager   Ztypes.shared_params.metadatar    Z"types.beta.threads.message_deletedr!   Z-types.beta.threads.message_content_part_paramr"   __all__r#   r$   r(   r   r1   r   r-   r-   r-   r.   <module>   s:   $    