
    ~i&<                       d dl mZ d dlmZ d dlmZmZmZ d dlZd dl	Z	d dl
mZ d dl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 ddlmZ ddl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* ddl+m,Z, ddl-m.Z.m/Z/ ddl0m1Z1 ddl2m3Z3 ddl4m5Z5 ddl6m7Z7 ddl8m9Z9 d dl:m;Z; ddgZ<ddddZ=d Z>	 d3d4d(Z? G d) de          Z@ G d* de          ZA G d+ d,          ZB G d- d.          ZC G d/ d0          ZD G d1 d2          ZEdS )5    )annotations)Path)UnionIterableOptionalN)Literal)urlparseunquote_plus   )BodyQueryHeaders)with_sts_tokenasync_with_sts_token)make_request_options)SyncAPIResourceAsyncAPIResource)cached_property)ArkAPIError)to_raw_response_wrapperasync_to_raw_response_wrapperto_streamed_response_wrapper"async_to_streamed_response_wrapper)StreamAsyncStream)
ToolChoice)Response)	ToolParam)ResponseInputParamResponseInputItemParam)ResponseInputContentParam)ResponseStreamEvent)ResponseTextConfigParam)ResponseCaching)	Reasoning)Thinking	ResponsesAsyncResponses	image_url	video_urlfile_url)input_imageinput_video
input_filefile extra_headersHeaders | NonetoolsIterable[ToolParam] | Nonereturnr   c                v   || S |D ]}|                     dd          dk    r	| i } d| d<   |                     dd          dk    r	| i } d| d<   |                     dd          dk    r	| i } d| d	<   |                     dd          d
k    r	| i } d| d<   |                     dd          dk    r	| i } d| d<   | S )Ntype 
web_searchtruezark-beta-web-searchmcpzark-beta-mcpknowledge_searchzark-beta-knowledge-search
doubao_appzark-beta-doubao-appimage_processzark-beta-image-process)get)r1   r3   
tool_params      ~/root/.openclaw/workspace/.venvs/ark-sdk/lib/python3.11/site-packages/volcenginesdkarkruntime/resources/responses/responses.py_add_beta_headersrB   @   s    } = =
>>&"%%55$ "39M/0>>&"%%..$ ",2M.)>>&"%%);;;$ "9?M56>>&"%%55$ "39M/0>>&"%%88$ "6<M23    c                      e Zd Zed8d            Zed9d            Zedddddddddddddddddddddd:d0            Zddddd1d;d5Zddddd1d<d7Z	dS )=r'   r5   ResponsesWithRawResponsec                     t          |           S N)rE   selfs    rA   with_raw_responsezResponses.with_raw_response^   s    '---rC   ResponsesWithStreamingResponsec                     t          |           S rG   )rK   rH   s    rA   with_streaming_responsez!Responses.with_streaming_responseb   s    -d333rC   Ninstructionsmax_output_tokensparallel_tool_callsprevious_response_idthinkingstorecachingstreamtemperaturetexttool_choicer3   top_pmax_tool_calls	expire_atr1   extra_query
extra_bodytimeout	reasoninginputUnion[str, ResponseInputParam]modelstrrO   Optional[str] | NonerP   Optional[int] | NonerQ   Optional[bool] | NonerR   rS   Optional[Thinking] | NonerT   rU    Optional[ResponseCaching] | NonerV   /Optional[Literal[False]] | Literal[True] | NonerW   Optional[float] | NonerX   ResponseTextConfigParam | NonerY   ToolChoice | Noner3   r4   rZ   r[   r\   r1   r2   r]   Query | Noner^   Body | Noner_   #float | httpx.Timeout | None | Noner`   Optional[Reasoning] | None&Response | Stream[ResponseStreamEvent]c          
        t          ||          }|                     di d|d|d|d|d|d|d|d	|d
|	d|
d|d|d|d|d|d|d|d|it          ||||          t          |
pdt          t
                             }|S )N
/responsesra   rc   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   rY   r3   rZ   r[   r\   r`   r1   r]   r^   r_   Fbodyoptionscast_torV   
stream_cls)rB   _postr   r   r   r"   rI   ra   rc   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   rY   r3   rZ   r[   r\   r1   r]   r^   r_   r`   resps                           rA   createzResponses.createf   sL   6 *-??zz  $%6	
 &': '(< H  7 & {  {    !.!" Y#$ Y% ( )+'%	   ?U12=  
 
@ rC   ru   response_idfloat | httpx.Timeout | Noner   c          	         |st          d|          |                     d| t          ||||          t          dt          t
                             S N:Expected a non-empty value for `response_id` but received /responses/ru   F)rx   ry   rV   rz   
ValueError_getr   r   r   r"   rI   r   r1   r]   r^   r_   s         rA   retrievezResponses.retrieve   s      	\[\\   yy'+''(+'%	   12  
 
 	
rC   Nonec          	         |st          d|          ddi|pi }|                     d| t          ||||          t          d                     S Nr   Acceptz*/*r   ru   )rx   ry   r   _deleter   r7   r   s         rA   deletezResponses.delete   s      	\[\\   "5B]-@bB||'+''(+'%	   JJ  	
 	
 		
rC   )r5   rE   )r5   rK   ).ra   rb   rc   rd   rO   re   rP   rf   rQ   rg   rR   re   rS   rh   rT   rg   rU   ri   rV   rj   rW   rk   rX   rl   rY   rm   r3   r4   rZ   rk   r[   rf   r\   rf   r1   r2   r]   rn   r^   ro   r_   rp   r`   rq   r5   rr   r   rd   r1   r2   r]   rn   r^   ro   r_   r   r5   r   r   rd   r1   r2   r]   rn   r^   ro   r_   r   r5   r   )
__name__
__module____qualname__r   rJ   rM   r   r~   r   r   r0   rC   rA   r'   r'   ]   s       . . . _. 4 4 4 _4  .2265959.2'+48BF.2/3)-,0(,/3*.(,$("&7;041; ; ; ; ; ^;B )-$("&04
 
 
 
 
 
< )-$("&04
 
 
 
 
 
 
 
rC   c                      e Zd Zed=d            Zed>d            Zedddddddddddddddddddddd?d0            Zddddd1d@d5Zddddd1dAd7Z	dBd9Z
dCd<ZdS )Dr(   r5   AsyncResponsesWithRawResponsec                     t          |           S rG   )r   rH   s    rA   rJ   z AsyncResponses.with_raw_response   s    ,T222rC   #AsyncResponsesWithStreamingResponsec                     t          |           S rG   )r   rH   s    rA   rM   z&AsyncResponses.with_streaming_response   s    24888rC   NrN   ra   rb   rc   rd   rO   re   rP   rf   rQ   rg   rR   rS   rh   rT   rU   ri   rV   rj   rW   rk   rX   rl   rY   rm   r3   r4   rZ   r[   r\   r1   r2   r]   rn   r^   ro   r_   rp   r`   rq   +Response | AsyncStream[ResponseStreamEvent]c          
     b  K   t          ||          }|                     |           d {V  |                     di d|d|d|d|d|d|d	|d
|d|	d|
d|d|d|d|d|d|d|d|it          ||||          t          |
pdt
          t                              d {V }|S )N)ra   rt   ra   rc   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   rY   r3   rZ   r[   r\   r`   ru   Frv   )rB   _prepare_responses_inputr{   r   r   r   r"   r|   s                           rA   r~   zAsyncResponses.create   s     6 *-??++%+888888888ZZ  $%6	
 &': '(< H  7 & {  {    !.!" Y#$ Y% ( )+'%	   ?U"#67=   
 
 
 
 
 
 
 
B rC   ru   r   r   r   c          	        K   |st          d|          |                     d| t          ||||          t          dt          t
                              d {V S r   r   r   s         rA   r   zAsyncResponses.retrieve"  s        	\[\\   YY'+''(+'%	   12  
 
 
 
 
 
 
 
 	
rC   r   c          	        K   |st          d|          ddi|pi }|                     d| t          ||||          t          d                      d {V S r   r   r   s         rA   r   zAsyncResponses.delete<  s        	\[\\   "5B]-@bB\\'+''(+'%	   JJ " 	
 	
 	
 	
 	
 	
 	
 	
 		
rC   r   c                   K   g }|D ]S}d|vr|d         }t          |t                    s%|D ]+}|                    |                     |                     ,Tt	          j        |  d {V  d S )Ncontent)r   )
isinstancelistappend_prepare_responses_input_fileasynciogather)rI   ra   tasks
input_itemcontent_listr   s         rA   r   z'AsyncResponses._prepare_responses_inputU  s       		R 		RJ
**%i0LlD11 ' R RT???PPQQQQR ne$$$$$$$$$$rC   r   r!   c           	     f  K   d|vrd S |d         }|t                                           vrd S t           |         }||vrd S ||         }t          |          }|j        t          k    rd S t          |j                  }|j        r|j         | }n|}t          |          }| j	        j
                            |d           d {V }	| j	        j
                            |	j                   d {V }	|	j        dk    r#t          d| d|	j         d|	j         d	          d ||<   |	j        |d
<   d S )Nr7   	user_data)r/   purpose)idactivezFile path: z,id: z processing failed with status .file_id)&RESPONSES_MULTIMODAL_CONTENT_DATA_KEYSkeysr	   schemeFILE_PATH_SCHEMEr
   pathnetlocr   _clientfilesr~   wait_for_processingr   statusr   )
rI   r   content_typecontent_data_keycontent_dataparseddecoded_path	full_path	file_pathr/   s
             rA   r   z,AsyncResponses._prepare_responses_input_filed  s       Fv F K K M MMMFA,O7**F#$45,''=,,,F $FK00= 	% "=8,88II$IOO	\'..I{.SSSSSSSS\';;tw;GGGGGGGG;(""didddgddVZVaddd  
 %) !!W	rC   )r5   r   )r5   r   ).ra   rb   rc   rd   rO   re   rP   rf   rQ   rg   rR   re   rS   rh   rT   rg   rU   ri   rV   rj   rW   rk   rX   rl   rY   rm   r3   r4   rZ   rk   r[   rf   r\   rf   r1   r2   r]   rn   r^   ro   r_   rp   r`   rq   r5   r   r   r   )ra   r   )r   r!   )r   r   r   r   rJ   rM   r   r~   r   r   r   r   r0   rC   rA   r(   r(      s<       3 3 3 _3 9 9 9 _9  .2265959.2'+48BF.2/3)-,0(,/3*.(,$("&7;041> > > > > >H )-$("&04
 
 
 
 
 
< )-$("&04
 
 
 
 
 
2% % % %%% %% %% %% %% %%rC   c                      e Zd ZddZdS )rE   	responsesr'   r5   r   c                F    || _         t          |j                  | _        d S rG   )
_responsesr   r~   rI   r   s     rA   __init__z!ResponsesWithRawResponse.__init__  s$    #-
 
rC   Nr   r'   r5   r   r   r   r   r   r0   rC   rA   rE   rE     (        
 
 
 
 
 
rC   rE   c                      e Zd ZddZdS )r   r   r(   r5   r   c                F    || _         t          |j                  | _        d S rG   )r   r   r~   r   s     rA   r   z&AsyncResponsesWithRawResponse.__init__  s$    #3
 
rC   Nr   r(   r5   r   r   r0   rC   rA   r   r     r   rC   r   c                      e Zd ZddZdS )rK   r   r'   r5   r   c                F    || _         t          |j                  | _        d S rG   )r   r   r~   r   s     rA   r   z'ResponsesWithStreamingResponse.__init__  s$    #2
 
rC   Nr   r   r0   rC   rA   rK   rK     r   rC   rK   c                      e Zd ZddZdS )r   r   r(   r5   r   c                F    || _         t          |j                  | _        d S rG   )r   r   r~   r   s     rA   r   z,AsyncResponsesWithStreamingResponse.__init__  s$    #8
 
rC   Nr   r   r0   rC   rA   r   r     r   rC   r   )Nr0   )r1   r2   r3   r4   r5   r   )F
__future__r   pathlibr   typingr   r   r   httpxr   typing_extensionsr   urllib.parser	   r
   _typesr   r   r   _utils._utilsr   r   _base_clientr   	_resourcer   r   _compatr   _exceptionsr   	_responser   r   r   r   
_streamingr   r   &types.responses.response_create_paramsr   types.responses.responser   types.responses.tool_paramr   $types.responses.response_input_paramr   r    9types.responses.response_input_message_content_list_paramr!   %types.responses.response_stream_eventr"   *types.responses.response_text_config_paramr#   &types.responses.response_caching_paramr$   types.shared_paramsr%   4volcenginesdkarkruntime.types.shared_params.thinkingr&   __all__r   r   rB   r'   r(   rE   r   rK   r   r0   rC   rA   <module>r      s   # " " " " "                  % % % % % % / / / / / / / / * * * * * * * * * * A A A A A A A A 0 0 0 0 0 0 : : : : : : : : & & & & & & & & & & & &            . - - - - - - - @ @ @ @ @ @ 0 0 0 0 0 0 3 3 3 3 3 3             I H H H H H Q Q Q Q Q Q E E E E E E , , , , , , I I I I I I(
) * * &   OQ    :x
 x
 x
 x
 x
 x
 x
 x
vq% q% q% q% q%% q% q% q%h
 
 
 
 
 
 
 

 
 
 
 
 
 
 

 
 
 
 
 
 
 

 
 
 
 
 
 
 
 
 
rC   