a
    ff                     @  sT  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gZ,G dd deZ-G dd deZ.G dd dZ/G dd dZ0G dd dZ1G dd dZ2d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)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 N)r!   self r'   _/var/www/ai-form-bot/venv/lib/python3.9/site-packages/openai/resources/beta/threads/messages.pywith_raw_response!   s    zMessages.with_raw_responseMessagesWithStreamingResponsec                 C  s   t | S r$   )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[object] | NotGivenHeaders | NoneQuery | NoneBody | None'float | httpx.Timeout | None | NotGivenr   
	thread_idcontentroler-   r.   r/   r0   r1   r2   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. Keys
              can be a maximum of 64 characters long and values can be a maxium of 512
              characters long.

          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>   r?   r-   r.   r/   r0   r1   r2   bodyoptionscast_to)
ValueError_postr   r   MessageCreateParamsr   r   
r&   r=   r>   r?   r-   r.   r/   r0   r1   r2   r'   r'   r(   create)   s$    ,
	zMessages.createrG   
message_idr=   r/   r0   r1   r2   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
        rA   9Expected a non-empty value for `message_id` but received rB   rC   rD   
/messages/rG   rJ   rK   rL   _getr   r   r&   rR   r=   r/   r0   r1   r2   r'   r'   r(   retrievei   s    zMessages.retriever.   r/   r0   r1   r2   rR   r=   r.   r/   r0   r1   r2   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. Keys
              can be a maximum of 64 characters long and values can be a maxium of 512
              characters long.

          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
        rA   rT   rB   rC   rD   rU   r.   rG   rH   )rL   rM   r   r   MessageUpdateParamsr   r   r&   rR   r=   r.   r/   r0   r1   r2   r'   r'   r(   update   s    zMessages.update	afterbeforelimitorderrun_idr/   r0   r1   r2   str | NotGivenint | NotGiven!Literal['asc', 'desc'] | NotGivenzSyncCursorPage[Message]r=   rb   rc   rd   re   rf   r/   r0   r1   r2   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 	af  
        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,
              ending 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
        rA   rB   rC   rD   rE   )rb   rc   rd   re   rf   )r/   r0   r1   r2   query)pagerJ   model)rL   _get_api_listr   r   r   r   r   MessageListParamsr&   r=   rb   rc   rd   re   rf   r/   r0   r1   r2   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
        rA   rT   rB   rC   rD   rU   rG   rV   rL   _deleter   r   rY   r'   r'   r(   delete  s    zMessages.delete__name__
__module____qualname__r   r)   r+   r	   rP   rZ   r`   rr   rv   r'   r'   r'   r(   r       sJ   	$G* 0&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)   (  s    zAsyncMessages.with_raw_response"AsyncMessagesWithStreamingResponsec                 C  s   t | S r$   )r|   r%   r'   r'   r(   r+   ,  s    z%AsyncMessages.with_streaming_responseNr,   r3   r4   r5   r6   r7   r8   r9   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 )
r@   rA   rB   rC   rD   rE   rF   NrG   rH   )rL   rM   r   r   rN   r   r   rO   r'   r'   r(   rP   0  s$    ,
	zAsyncMessages.createrG   rQ   c                  sb   |st d||s$t d|ddi|p0i }| jd| d| t||||dtdI d	H S )
rS   rA   rT   rB   rC   rD   rU   rG   rV   NrW   rY   r'   r'   r(   rZ   p  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]   rA   rT   rB   rC   rD   rU   r.   NrG   rH   )rL   rM   r   r   r^   r   r   r_   r'   r'   r(   r`     s    zAsyncMessages.updatera   rg   rh   ri   z1AsyncPaginator[Message, AsyncCursorPage[Message]]rj   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 rk   )rL   ro   r   r   r   r   r   rp   rq   r'   r'   r(   rr     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 )
rs   rA   rT   rB   rC   rD   rU   rG   rV   Nrt   rY   r'   r'   r(   rv     s    zAsyncMessages.deleterw   r'   r'   r'   r(   r    '  sJ   	$G* 0&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 r$   )	_messagesr   Zto_raw_response_wrapperrP   rZ   r`   rr   rv   r&   r   r'   r'   r(   __init__/  s     z MessagesWithRawResponse.__init__Nrx   ry   rz   r   r'   r'   r'   r(   r!   .  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_wrapperrP   rZ   r`   rr   rv   r   r'   r'   r(   r   D  s     z%AsyncMessagesWithRawResponse.__init__Nr   r'   r'   r'   r(   r{   C  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   rP   rZ   r`   rr   rv   r   r'   r'   r(   r   Y  s     z&MessagesWithStreamingResponse.__init__Nr   r'   r'   r'   r(   r*   X  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   rP   rZ   r`   rr   rv   r   r'   r'   r(   r   n  s     z+AsyncMessagesWithStreamingResponse.__init__Nr   r'   r'   r'   r(   r|   m  s   r|   )3
__future__r   typingr   r   r   typing_extensionsr   Zhttpx r   _typesr	   r
   r   r   r   Z_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.beta.threads.message_deletedr   Z-types.beta.threads.message_content_part_paramr   __all__r   r    r!   r{   r*   r|   r'   r'   r'   r(   <module>   s4     	  	