o
    j                     @  s  d dl mZ d dlmZmZmZ d dl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 dd
lmZmZmZmZmZmZ ddlmZmZmZmZm Z  ddl!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/m0Z0 ddl1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7 ddl8m9Z9 ddl:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@ ddlAmZmZ ddlBmCZC ddgZDG dd de)ZEG dd de*ZFG dd dZGG dd dZHG dd  d ZIG d!d" d"ZJdS )#    )annotations)IterableOptionaloverload)partial)LiteralN   )_legacy_response   )Runs	AsyncRunsRunsWithRawResponseAsyncRunsWithRawResponseRunsWithStreamingResponseAsyncRunsWithStreamingResponse)MessagesAsyncMessagesMessagesWithRawResponseAsyncMessagesWithRawResponseMessagesWithStreamingResponse"AsyncMessagesWithStreamingResponse)	NOT_GIVENBodyQueryHeadersNotGiven)required_argsmaybe_transformasync_maybe_transform)r   r   )cached_property)SyncAPIResourceAsyncAPIResource)to_streamed_response_wrapper"async_to_streamed_response_wrapper)StreamAsyncStream)ThreadThreadDeletedAssistantStreamEventthread_create_paramsthread_update_paramsthread_create_and_run_params)make_request_options)AssistantEventHandlerAssistantEventHandlerTAssistantStreamManagerAsyncAssistantEventHandlerAsyncAssistantEventHandlerTAsyncAssistantStreamManager)r   r   )RunThreadsAsyncThreadsc                   @    e Zd ZedLddZedMddZedNd	d
ZedOddZeedddeddPddZ	dddeddQd"d#Z
eddded$dRd%d&ZdddeddSd(d)Zeeeeeeeddded*
dTd6d7Zeeeeeeddded8	dUd;d7Zeeeeeeddded8	dVd>d7Zed+gd+d/geeeeeeddded*
dWd@d7Zeeeeeeddded8	dXdBdCZeeeeeeddded8	dYdGdCZeeeeeddddedH
dZdKdCZdS )[r4   returnr   c                 C  
   t | jS N)r   _clientself r=   k/var/www/html/fyndo/pharma/fyndo/venv/lib/python3.10/site-packages/openai/resources/beta/threads/threads.pyrunsA      
zThreads.runsr   c                 C  r8   r9   )r   r:   r;   r=   r=   r>   messagesE   r@   zThreads.messagesThreadsWithRawResponsec                 C     t | S r9   )rB   r;   r=   r=   r>   with_raw_responseI      zThreads.with_raw_responseThreadsWithStreamingResponsec                 C  rC   r9   )rF   r;   r=   r=   r>   with_streaming_responseM   rE   zThreads.with_streaming_responseNrA   metadataextra_headersextra_query
extra_bodytimeoutrA   1Iterable[thread_create_params.Message] | NotGivenrI   Optional[object] | NotGivenrJ   Headers | NonerK   Query | NonerL   Body | NonerM   'float | httpx.Timeout | None | NotGivenr&   c             	   C  s<   ddi|pi }| j dt||dtjt||||dtdS )	  
        Create a thread.

        Args:
          messages: A list of [messages](https://platform.openai.com/docs/api-reference/messages) to
              start the thread with.

          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
        OpenAI-Betaassistants=v1/threadsrA   rI   rJ   rK   rL   rM   bodyoptionscast_to)_postr   r)   ThreadCreateParamsr,   r&   r<   rA   rI   rJ   rK   rL   rM   r=   r=   r>   createQ   s    zThreads.createrY   	thread_idstrc                C  D   |s	t d|ddi|pi }| jd| t||||dtdS )G  
        Retrieves a thread.

        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
        8Expected a non-empty value for `thread_id` but received rU   rV   	/threads/rY   r\   r]   
ValueError_getr,   r&   r<   rb   rJ   rK   rL   rM   r=   r=   r>   retrieve      zThreads.retrieverI   rJ   rK   rL   rM   c             	   C  sR   |s	t d|ddi|pi }| jd| td|itjt||||dtdS )  
        Modifies a thread.

        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
        rf   rU   rV   rg   rI   rY   rZ   )rj   r^   r   r*   ThreadUpdateParamsr,   r&   r<   rb   rI   rJ   rK   rL   rM   r=   r=   r>   update   s   zThreads.updater'   c                C  rd   )D  
        Delete a thread.

        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
        rf   rU   rV   rg   rY   rh   rj   _deleter,   r'   rl   r=   r=   r>   delete   rn   zThreads.delete
instructionsrI   modelstreamthreadtoolsrJ   rK   rL   rM   assistant_idry   Optional[str] | NotGivenrz   r{   #Optional[Literal[False]] | NotGivenr|   .thread_create_and_run_params.Thread | NotGivenr}   @Optional[Iterable[thread_create_and_run_params.Tool]] | NotGivenr3   c                C     dS a  
        Create a thread and run it in one request.

        Args:
          assistant_id: The ID of the
              [assistant](https://platform.openai.com/docs/api-reference/assistants) to use to
              execute this run.

          instructions: Override the default system message of the assistant. This is useful for
              modifying the behavior on a per-run basis.

          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.

          model: The ID of the [Model](https://platform.openai.com/docs/api-reference/models) to
              be used to execute this run. If a value is provided here, it will override the
              model associated with the assistant. If not, the model associated with the
              assistant will be used.

          stream: If `true`, returns a stream of events that happen during the Run as server-sent
              events, terminating when the Run enters a terminal state with a `data: [DONE]`
              message.

          thread: If no thread is provided, an empty thread will be created.

          tools: Override the tools the assistant can use for this run. This is useful for
              modifying the behavior on a per-run basis.

          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
        Nr=   r<   r~   ry   rI   rz   r{   r|   r}   rJ   rK   rL   rM   r=   r=   r>   create_and_run      8zThreads.create_and_run	ry   rI   rz   r|   r}   rJ   rK   rL   rM   Literal[True]Stream[AssistantStreamEvent]c                C  r   a  
        Create a thread and run it in one request.

        Args:
          assistant_id: The ID of the
              [assistant](https://platform.openai.com/docs/api-reference/assistants) to use to
              execute this run.

          stream: If `true`, returns a stream of events that happen during the Run as server-sent
              events, terminating when the Run enters a terminal state with a `data: [DONE]`
              message.

          instructions: Override the default system message of the assistant. This is useful for
              modifying the behavior on a per-run basis.

          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.

          model: The ID of the [Model](https://platform.openai.com/docs/api-reference/models) to
              be used to execute this run. If a value is provided here, it will override the
              model associated with the assistant. If not, the model associated with the
              assistant will be used.

          thread: If no thread is provided, an empty thread will be created.

          tools: Override the tools the assistant can use for this run. This is useful for
              modifying the behavior on a per-run basis.

          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
        Nr=   r<   r~   r{   ry   rI   rz   r|   r}   rJ   rK   rL   rM   r=   r=   r>   r   (  r   bool"Run | Stream[AssistantStreamEvent]c                C  r   r   r=   r   r=   r=   r>   r   b  r   3Optional[Literal[False]] | Literal[True] | NotGivenc                C  sR   ddi|pi }| j dt|||||||dtjt||	|
|dt|p#dtt dS NrU   rV   /threads/runsr~   ry   rI   rz   r{   r|   r}   rY   Fr[   r\   r]   r{   
stream_cls)r^   r   r+   ThreadCreateAndRunParamsr,   r3   r$   r(   r   r=   r=   r>   r     s*   	-AssistantStreamManager[AssistantEventHandler]c       
         C  r   'Create a thread and stream the run backNr=   r<   r~   ry   rI   rz   r|   r}   rJ   rK   rL   rM   r=   r=   r>   create_and_run_stream     zThreads.create_and_run_streamevent_handlerr.   .AssistantStreamManager[AssistantEventHandlerT]c                C  r   r   r=   r<   r~   ry   rI   rz   r|   r}   r   rJ   rK   rL   rM   r=   r=   r>   r        
ry   rI   rz   r|   r}   r   rJ   rK   rL   rM   AssistantEventHandlerT | None^AssistantStreamManager[AssistantEventHandler] | AssistantStreamManager[AssistantEventHandlerT]c                C  sn   dd|rdndd|pi }t | jdt||||d||dtjt||	|
|d	tdtt d
}t	||p4t
 dS r   rV   zthreads.create_and_run_streamtruefalse)rU   zX-Stainless-Stream-Helperz X-Stainless-Custom-Event-Handlerr   Tr   rY   r   )r   )r   r^   r   r+   r   r,   r3   r$   r(   r/   r-   )r<   r~   ry   rI   rz   r|   r}   r   rJ   rK   rL   rM   make_requestr=   r=   r>   r     s8   
	)r7   r   )r7   r   )r7   rB   )r7   rF   rA   rN   rI   rO   rJ   rP   rK   rQ   rL   rR   rM   rS   r7   r&   rb   rc   rJ   rP   rK   rQ   rL   rR   rM   rS   r7   r&   rb   rc   rI   rO   rJ   rP   rK   rQ   rL   rR   rM   rS   r7   r&   rb   rc   rJ   rP   rK   rQ   rL   rR   rM   rS   r7   r'   r~   rc   ry   r   rI   rO   rz   r   r{   r   r|   r   r}   r   rJ   rP   rK   rQ   rL   rR   rM   rS   r7   r3   )r~   rc   r{   r   ry   r   rI   rO   rz   r   r|   r   r}   r   rJ   rP   rK   rQ   rL   rR   rM   rS   r7   r   )r~   rc   r{   r   ry   r   rI   rO   rz   r   r|   r   r}   r   rJ   rP   rK   rQ   rL   rR   rM   rS   r7   r   )r~   rc   ry   r   rI   rO   rz   r   r{   r   r|   r   r}   r   rJ   rP   rK   rQ   rL   rR   rM   rS   r7   r   )r~   rc   ry   r   rI   rO   rz   r   r|   r   r}   r   rJ   rP   rK   rQ   rL   rR   rM   rS   r7   r   )r~   rc   ry   r   rI   rO   rz   r   r|   r   r}   r   r   r.   rJ   rP   rK   rQ   rL   rR   rM   rS   r7   r   )r~   rc   ry   r   rI   rO   rz   r   r|   r   r}   r   r   r   rJ   rP   rK   rQ   rL   rR   rM   rS   r7   r   __name__
__module____qualname__r   r?   rA   rD   rG   r   ra   rm   rs   rw   r   r   r   r   r=   r=   r=   r>   r4   @       6&/"999(c                   @  r6   )[r5   r7   r   c                 C  r8   r9   )r   r:   r;   r=   r=   r>   r?      r@   zAsyncThreads.runsr   c                 C  r8   r9   )r   r:   r;   r=   r=   r>   rA   $  r@   zAsyncThreads.messagesAsyncThreadsWithRawResponsec                 C  rC   r9   )r   r;   r=   r=   r>   rD   (  rE   zAsyncThreads.with_raw_response!AsyncThreadsWithStreamingResponsec                 C  rC   r9   )r   r;   r=   r=   r>   rG   ,  rE   z$AsyncThreads.with_streaming_responseNrH   rA   rN   rI   rO   rJ   rP   rK   rQ   rL   rR   rM   rS   r&   c             	     sJ   ddi|pi }| j dt||dtjI dH t||||dtdI dH S )rT   rU   rV   rW   rX   NrY   rZ   )r^   r   r)   r_   r,   r&   r`   r=   r=   r>   ra   0  s    zAsyncThreads.createrY   rb   rc   c                  L   |s
t d|ddi|pi }| jd| t||||dtdI dH S )re   rf   rU   rV   rg   rY   rh   Nri   rl   r=   r=   r>   rm   `     zAsyncThreads.retrievero   c             	     s`   |s
t d|ddi|pi }| jd| td|itjI dH t||||dtdI dH S )	rp   rf   rU   rV   rg   rI   NrY   rZ   )rj   r^   r   r*   rq   r,   r&   rr   r=   r=   r>   rs     s   zAsyncThreads.updater'   c                  r   )rt   rf   rU   rV   rg   rY   rh   Nru   rl   r=   r=   r>   rw     r   zAsyncThreads.deleterx   r~   ry   r   rz   r{   r   r|   r   r}   r   r3   c                     dS r   r=   r   r=   r=   r>   r        8zAsyncThreads.create_and_runr   r   !AsyncStream[AssistantStreamEvent]c                  r   r   r=   r   r=   r=   r>   r     r   r   'Run | AsyncStream[AssistantStreamEvent]c                  r   r   r=   r   r=   r=   r>   r   A  r   r   c                  s`   ddi|pi }| j dt|||||||dtjI d H t||	|
|dt|p'dtt dI d H S r   )r^   r   r+   r   r,   r3   r%   r(   r   r=   r=   r>   r   {  s,   	7AsyncAssistantStreamManager[AsyncAssistantEventHandler]c       
         C  r   r   r=   r   r=   r=   r>   r     r   z"AsyncThreads.create_and_run_streamr   r1   8AsyncAssistantStreamManager[AsyncAssistantEventHandlerT]c                C  r   r   r=   r   r=   r=   r>   r     r   r   "AsyncAssistantEventHandlerT | NonerAsyncAssistantStreamManager[AsyncAssistantEventHandler] | AsyncAssistantStreamManager[AsyncAssistantEventHandlerT]c                C  sl   dd|rdndd|pi }| j dt||||d||dtjt||	|
|d	tdtt d
}t||p3t	 dS r   )
r^   r   r+   r   r,   r3   r%   r(   r2   r0   )r<   r~   ry   rI   rz   r|   r}   r   rJ   rK   rL   rM   requestr=   r=   r>   r     s6   
	)r7   r   )r7   r   )r7   r   )r7   r   r   r   r   r   r   )r~   rc   r{   r   ry   r   rI   rO   rz   r   r|   r   r}   r   rJ   rP   rK   rQ   rL   rR   rM   rS   r7   r   )r~   rc   r{   r   ry   r   rI   rO   rz   r   r|   r   r}   r   rJ   rP   rK   rQ   rL   rR   rM   rS   r7   r   )r~   rc   ry   r   rI   rO   rz   r   r{   r   r|   r   r}   r   rJ   rP   rK   rQ   rL   rR   rM   rS   r7   r   )r~   rc   ry   r   rI   rO   rz   r   r|   r   r}   r   rJ   rP   rK   rQ   rL   rR   rM   rS   r7   r   )r~   rc   ry   r   rI   rO   rz   r   r|   r   r}   r   r   r1   rJ   rP   rK   rQ   rL   rR   rM   rS   r7   r   )r~   rc   ry   r   rI   rO   rz   r   r|   r   r}   r   r   r   rJ   rP   rK   rQ   rL   rR   rM   rS   r7   r   r   r=   r=   r=   r>   r5     r   c                   @  2   e Zd ZdddZeddd	ZedddZdS )rB   threadsr4   r7   Nonec                 C  P   || _ t|j| _t|j| _t|j| _t|j| _t|j| _d S r9   )_threadsr	   to_raw_response_wrapperra   rm   rs   rw   r   r<   r   r=   r=   r>   __init__      
zThreadsWithRawResponse.__init__r   c                 C     t | jjS r9   )r   r   r?   r;   r=   r=   r>   r?        zThreadsWithRawResponse.runsr   c                 C  r   r9   )r   r   rA   r;   r=   r=   r>   rA     r   zThreadsWithRawResponse.messagesNr   r4   r7   r   )r7   r   )r7   r   r   r   r   r   r   r?   rA   r=   r=   r=   r>   rB          
rB   c                   @  r   )r   r   r5   r7   r   c                 C  r   r9   )r   r	   async_to_raw_response_wrapperra   rm   rs   rw   r   r   r=   r=   r>   r     r   z$AsyncThreadsWithRawResponse.__init__r   c                 C  r   r9   )r   r   r?   r;   r=   r=   r>   r?   1  r   z AsyncThreadsWithRawResponse.runsr   c                 C  r   r9   )r   r   rA   r;   r=   r=   r>   rA   5  r   z$AsyncThreadsWithRawResponse.messagesNr   r5   r7   r   )r7   r   )r7   r   r   r=   r=   r=   r>   r     r   r   c                   @  r   )rF   r   r4   r7   r   c                 C  F   || _ t|j| _t|j| _t|j| _t|j| _t|j| _d S r9   )r   r"   ra   rm   rs   rw   r   r   r=   r=   r>   r   ;      
z%ThreadsWithStreamingResponse.__init__r   c                 C  r   r9   )r   r   r?   r;   r=   r=   r>   r?   N  r   z!ThreadsWithStreamingResponse.runsr   c                 C  r   r9   )r   r   rA   r;   r=   r=   r>   rA   R  r   z%ThreadsWithStreamingResponse.messagesNr   )r7   r   )r7   r   r   r=   r=   r=   r>   rF   :  r   rF   c                   @  r   )r   r   r5   r7   r   c                 C  r   r9   )r   r#   ra   rm   rs   rw   r   r   r=   r=   r>   r   X  r   z*AsyncThreadsWithStreamingResponse.__init__r   c                 C  r   r9   )r   r   r?   r;   r=   r=   r>   r?   k  r   z&AsyncThreadsWithStreamingResponse.runsr   c                 C  r   r9   )r   r   rA   r;   r=   r=   r>   rA   o  r   z*AsyncThreadsWithStreamingResponse.messagesNr   )r7   r   )r7   r   r   r=   r=   r=   r>   r   W  r   r   )K
__future__r   typingr   r   r   	functoolsr   typing_extensionsr   httpx r	   r?   r   r   r   r   r   r   rA   r   r   r   r   r   r   _typesr   r   r   r   r   _utilsr   r   r   	runs.runs_compatr   	_resourcer    r!   	_responser"   r#   
_streamingr$   r%   
types.betar&   r'   r(   r)   r*   r+   _base_clientr,   lib.streamingr-   r.   r/   r0   r1   r2   messages.messagestypes.beta.threadsr3   __all__r4   r5   rB   r   rF   r   r=   r=   r=   r>   <module>   sB          b   d