U
    ·ÜŸj~l  ã                   @  s`  d dl m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 ddl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,m-Z- ddgZ.G dd„ deƒZ/G dd„ deƒZ0G dd„ dƒZ1G dd„ dƒZ2G dd„ dƒZ3G dd„ dƒZ4dS )é    )Úannotations)ÚUnionÚIterableÚOptional)ÚLiteralNé   )Ú_legacy_response)Ú	NOT_GIVENÚBodyÚQueryÚHeadersÚNotGiven)Ú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                   @  s  e Zd Zeddœdd„ƒZeddœdd„ƒZeeddded	œd
ddddddddddœ
dd„Zdddedœd
d
ddddddœdd„Zedddedœd
d
dddddddœdd„Z	eeeeedddedœ	d
d d d!d"d ddddd#d$œd%d&„Z
dddedœd
d
ddddd'dœd(d)„ZdS )*r    ÚMessagesWithRawResponse©Úreturnc                 C  s   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(   úJ/tmp/pip-unpacked-wheel-2qj3ofc_/openai/resources/beta/threads/messages.pyÚwith_raw_response"   s    zMessages.with_raw_responseÚMessagesWithStreamingResponsec                 C  s   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
        )r+   r&   r(   r(   r)   Úwith_streaming_response,   s    z Messages.with_streaming_responseN©ÚattachmentsÚmetadataÚextra_headersÚextra_queryÚ
extra_bodyÚtimeoutÚstrú-Union[str, Iterable[MessageContentPartParam]]úLiteral[('user', 'assistant')]ú?Optional[Iterable[message_create_params.Attachment]] | NotGivenúOptional[Metadata] | NotGivenúHeaders | NoneúQuery | NoneúBody | Noneú'float | httpx.Timeout | None | NotGivenr   ©
Ú	thread_idÚcontentÚroler/   r0   r1   r2   r3   r4   r$   c          
   	   C  sZ   |st d|›�ƒ‚ddi|pi –}| j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/ú	/messages©r@   rA   r/   r0   ©r1   r2   r3   r4   ©ÚbodyÚoptionsÚcast_to)Ú
ValueErrorÚ_postr   r   ÚMessageCreateParamsr   r   ©
r'   r?   r@   rA   r/   r0   r1   r2   r3   r4   r(   r(   r)   Úcreate5   s*    .
üù	   ÿòzMessages.createrI   ©Ú
message_idr?   r1   r2   r3   r4   r$   c                C  s\   |st d|›�ƒ‚|s$t d|›�ƒ‚ddi|p0i –}| j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
        rC   ú9Expected a non-empty value for `message_id` but received rD   rE   rF   ú
/messages/rI   ©rL   rM   ©rN   Ú_getr   r   ©r'   rT   r?   r1   r2   r3   r4   r(   r(   r)   Úretrievew   s       ÿûzMessages.retrieve©r0   r1   r2   r3   r4   ©rT   r?   r0   r1   r2   r3   r4   r$   c             	   C  sj   |st d|›�ƒ‚|s$t d|›�ƒ‚ddi|p0i –}| j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
        rC   rV   rD   rE   rF   rW   r0   rI   rJ   )rN   rO   r   r   ÚMessageUpdateParamsr   r   ©r'   rT   r?   r0   r1   r2   r3   r4   r(   r(   r)   Úupdateœ   s         ÿúzMessages.update©	ÚafterÚbeforeÚlimitÚorderÚrun_idr1   r2   r3   r4   ústr | NotGivenúint | NotGivenú#Literal[('asc', 'desc')] | NotGivenzSyncCursorPage[Message]©r?   rd   re   rf   rg   rh   r1   r2   r3   r4   r$   c       	         C  sb   |st d|›�ƒ‚ddi|pi –}| j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
        rC   rD   rE   rF   rG   )rd   re   rf   rg   rh   )r1   r2   r3   r4   Úquery)ÚpagerL   Úmodel)rN   Ú_get_api_listr   r   r   r   r   ÚMessageListParams©r'   r?   rd   re   rf   rg   rh   r1   r2   r3   r4   r(   r(   r)   ÚlistÊ   s.    .
ûøûízMessages.listr   c                C  s\   |st d|›�ƒ‚|s$t d|›�ƒ‚ddi|p0i –}| jd|› d|› �t||||d�td�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
        rC   rV   rD   rE   rF   rW   rI   rX   ©rN   Ú_deleter   r   r[   r(   r(   r)   Údelete  s       ÿûzMessages.delete©Ú__name__Ú
__module__Ú__qualname__r   r*   r-   r	   rR   r\   rb   rt   rx   r(   r(   r(   r)   r    !   sJ   	ó$Iö*õ 2ò&Nöc                   @  s  e Zd Zeddœdd„ƒZeddœdd„ƒZeeddded	œd
ddddddddddœ
dd„Zdddedœd
d
ddddddœdd„Zedddedœd
d
dddddddœdd„Z	eeeeedddedœ	d
d d d!d"d ddddd#d$œd%d&„Z
dddedœd
d
ddddd'dœd(d)„ZdS )*r!   ÚAsyncMessagesWithRawResponser#   c                 C  s   t | ƒS r%   )r}   r&   r(   r(   r)   r*   8  s    zAsyncMessages.with_raw_responseÚ"AsyncMessagesWithStreamingResponsec                 C  s   t | ƒS r,   )r~   r&   r(   r(   r)   r-   B  s    z%AsyncMessages.with_streaming_responseNr.   r5   r6   r7   r8   r9   r:   r;   r<   r=   r   r>   c          
   	   Ã  sf   |st d|›�ƒ‚ddi|pi –}| jd|› d�t||||dœtjƒI dH t||||	d�td	�I dH S )
rB   rC   rD   rE   rF   rG   rH   NrI   rJ   )rN   rO   r   r   rP   r   r   rQ   r(   r(   r)   rR   K  s*    .
üù	   ÿòzAsyncMessages.createrI   rS   c                Ã  sb   |st d|›�ƒ‚|s$t d|›�ƒ‚ddi|p0i –}| jd|› d|› �t||||d�td�I d	H S )
rU   rC   rV   rD   rE   rF   rW   rI   rX   NrY   r[   r(   r(   r)   r\   �  s       ÿûzAsyncMessages.retriever]   r^   c             	   Ã  sv   |st d|›�ƒ‚|s$t d|›�ƒ‚ddi|p0i –}| jd|› d|› �td|itjƒI dH t||||d	�td
�I dH S )r_   rC   rV   rD   rE   rF   rW   r0   NrI   rJ   )rN   rO   r   r   r`   r   r   ra   r(   r(   r)   rb   ²  s         ÿúzAsyncMessages.updaterc   ri   rj   rk   z1AsyncPaginator[Message, AsyncCursorPage[Message]]rl   c       	         C  sb   |st d|›�ƒ‚ddi|pi –}| jd|› d�tt t|||	|
t|||||dœtjƒd�td�S rm   )rN   rq   r   r   r   r   r   rr   rs   r(   r(   r)   rt   à  s.    .
ûøûízAsyncMessages.listr   c                Ã  sb   |st d|›�ƒ‚|s$t d|›�ƒ‚ddi|p0i –}| jd|› d|› �t||||d�td�I d	H S )
ru   rC   rV   rD   rE   rF   rW   rI   rX   Nrv   r[   r(   r(   r)   rx   '  s       ÿûzAsyncMessages.deletery   r(   r(   r(   r)   r!   7  sJ   	ó$Iö*õ 2ò&Nöc                   @  s   e Zd Zdddœdd„ZdS )r"   r    ÚNone©Úmessagesr$   c                 C  sP   || _ t |j¡| _t |j¡| _t |j¡| _t |j¡| _t |j¡| _d S ©N)Ú	_messagesr   Zto_raw_response_wrapperrR   r\   rb   rt   rx   ©r'   r�   r(   r(   r)   Ú__init__N  s     ÿÿÿÿÿz MessagesWithRawResponse.__init__N©rz   r{   r|   r…   r(   r(   r(   r)   r"   M  s   r"   c                   @  s   e Zd Zdddœdd„ZdS )r}   r!   r   r€   c                 C  sP   || _ t |j¡| _t |j¡| _t |j¡| _t |j¡| _t |j¡| _d S r‚   )rƒ   r   Zasync_to_raw_response_wrapperrR   r\   rb   rt   rx   r„   r(   r(   r)   r…   c  s     ÿÿÿÿÿz%AsyncMessagesWithRawResponse.__init__Nr†   r(   r(   r(   r)   r}   b  s   r}   c                   @  s   e Zd Zdddœdd„ZdS )r+   r    r   r€   c                 C  sF   || _ t|jƒ| _t|jƒ| _t|jƒ| _t|jƒ| _t|jƒ| _d S r‚   )rƒ   r   rR   r\   rb   rt   rx   r„   r(   r(   r)   r…   x  s     ÿÿÿÿÿz&MessagesWithStreamingResponse.__init__Nr†   r(   r(   r(   r)   r+   w  s   r+   c                   @  s   e Zd Zdddœdd„ZdS )r~   r!   r   r€   c                 C  sF   || _ t|jƒ| _t|jƒ| _t|jƒ| _t|jƒ| _t|jƒ| _d S r‚   )rƒ   r   rR   r\   rb   rt   rx   r„   r(   r(   r)   r…   �  s     ÿÿÿÿÿz+AsyncMessagesWithStreamingResponse.__init__Nr†   r(   r(   r(   r)   r~   Œ  s   r~   )5Ú
__future__r   Útypingr   r   r   Útyping_extensionsr   ZhttpxÚ r   Ú_typesr	   r
   r   r   r   Ú_utilsr   r   Ú_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}   r+   r~   r(   r(   r(   r)   Ú<module>   s6       