o
    ØRWj)~  ã                   @  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-   úu/home/esfera/Documents/content_generation/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  s`   |s	t d|›�ƒ‚ddi|pi ¥}| jtd|d�t||||dœtjƒt||||	ddi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   Úbearer_authT©r9   r:   r;   r<   Úsecurity©Ú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.create©r9   r:   r;   r<   Ú
message_idc             	   C  ó`   |s	t d|›�ƒ‚|st d|›�ƒ‚ddi|pi ¥}| jtd||d�t||||ddi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=   r]   rP   TrQ   ©rU   rV   ©rW   Ú_getr   r   r   ©r,   r]   r=   r9   r:   r;   r<   r-   r-   r.   Úretrieve|   ó    û÷zMessages.retrieve©r8   r9   r:   r;   r<   c             
   C  sn   |s	t d|›�ƒ‚|st d|›�ƒ‚ddi|pi ¥}| jtd||d�td|itjƒt||||dd	i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   ra   rb   r8   rP   TrQ   rS   )rW   rX   r   r   r   ÚMessageUpdateParamsr   r   ©r,   r]   r=   r8   r9   r:   r;   r<   r-   r-   r.   Úupdate¦   s"   !ûözMessages.update©	ÚafterÚbeforeÚlimitÚorderÚrun_idr9   r:   r;   r<   ro   ú
str | Omitrp   rq   ú
int | Omitrr   úLiteral['asc', 'desc'] | Omitrs   úSyncCursorPage[Message]c       	         C  óh   |s	t d|›�ƒ‚ddi|pi ¥}| jtd|d�tt t|||	|
t|||||dœtjƒddi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   )ro   rp   rq   rr   rs   rP   T)r9   r:   r;   r<   ÚqueryrR   )ÚpagerU   Úmodel)	rW   Ú_get_api_listr   r   r   r   r   r   ÚMessageListParams©r,   r=   ro   rp   rq   rr   rs   r9   r:   r;   r<   r-   r-   r.   ÚlistÙ   ó0   /
ûø
ñì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   ra   rb   rP   TrQ   rc   ©rW   Ú_deleter   r   r!   rf   r-   r-   r.   Údelete"  rh   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   ©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>   ro   rt   rp   rt   rq   ru   rr   rv   rs   rt   r9   rE   r:   rF   r;   rG   r<   rH   r'   rw   ©r]   r>   r=   r>   r9   rE   r:   rF   r;   rG   r<   rH   r'   r!   ©Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r/   r3   Útyping_extensionsÚ
deprecatedr   r   r[   rg   rm   r€   r…   r-   r-   r-   r.   r#      óX    	óFö)õ2òHöc                   @  r%   )>r$   r&   r'   ÚAsyncMessagesWithRawResponsec                 C  r)   r*   )r’   r+   r-   r-   r.   r/   P  r0   zAsyncMessages.with_raw_responseÚ"AsyncMessagesWithStreamingResponsec                 C  r)   r2   )r“   r+   r-   r-   r.   r3   Z  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          
   
   Ã  sn   �|s
t d|›�ƒ‚ddi|pi ¥}| jtd|d�t||||dœtjƒI dH t||||	dd	id
�td�I dH S )rI   rJ   rK   rL   rM   rN   rO   NrP   TrQ   rS   )rW   rX   r   r   r   rY   r   r   rZ   r-   r-   r.   r[   c  s.   €/
üù	ûîzAsyncMessages.creater\   r]   c             	   Ã  óh   �|s
t d|›�ƒ‚|st d|›�ƒ‚ddi|pi ¥}| jtd||d�t||||ddid	�td
�I dH S )r_   rJ   r`   rK   rL   ra   rb   rP   TrQ   rc   Nrd   rf   r-   r-   r.   rg   ª  ó"   €û÷zAsyncMessages.retrieveri   c             
   Ã  s|   �|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	d
id�td�I dH S )rj   rJ   r`   rK   rL   ra   rb   r8   NrP   TrQ   rS   )rW   rX   r   r   r   rk   r   r   rl   r-   r-   r.   rm   Ô  s$   €!ûözAsyncMessages.updatern   ro   rt   rp   rq   ru   rr   rv   rs   ú1AsyncPaginator[Message, AsyncCursorPage[Message]]c       	         C  rx   ry   )	rW   r}   r   r   r   r   r   r   r~   r   r-   r-   r.   r€     r�   zAsyncMessages.listr!   c             	   Ã  r”   )r‚   rJ   r`   rK   rL   ra   rb   rP   TrQ   rc   Nrƒ   rf   r-   r-   r.   r…   P  r•   zAsyncMessages.delete)r'   r’   )r'   r“   r†   r‡   rˆ   )r=   r>   ro   rt   rp   rt   rq   ru   rr   rv   rs   rt   r9   rE   r:   rF   r;   rG   r<   rH   r'   r–   r‰   rŠ   r-   r-   r-   r.   r$   M  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   Úto_raw_response_wrapperr[   rg   rm   r€   r…   ©r,   r˜   r-   r-   r.   Ú__init__|  ó*   ÿÿÿÿÿÿÿÿÿÿz MessagesWithRawResponse.__init__N©r˜   r#   r'   r™   ©r‹   rŒ   r�   rŸ   r-   r-   r-   r.   r(   {  ó    r(   c                   @  r—   )	r’   r˜   r$   r'   r™   c                 C  rš   r›   )rœ   r   Úasync_to_raw_response_wrapperr[   rg   rm   r€   r…   rž   r-   r-   r.   rŸ   ›  r    z%AsyncMessagesWithRawResponse.__init__N©r˜   r$   r'   r™   r¢   r-   r-   r-   r.   r’   š  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   r[   rg   rm   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   r[   rg   rm   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   Ú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-   r-   r-   r.   Ú<module>   s:   $  0  0