Team Ai
Apppublic

Yash030/claude-code-proxy

sourceHugging Faceupdated 5mo agoView on Hugging Face
2likes
streaming.cpython-314.pyc62 linesDownload Raw Back to __pycache__
1+
2�EjM����Rt^RIHt^RIt^RIHt^RIHtHt^RIH	t	^RI3Ht^RIH
t
HtHtHtHt^RIHt^R	IHt^R4IHt^RIHtHt^RIHtHtHtR
RltRR/RRllt R#)zCSSE streaming for local web_search / web_fetch server tool results.)�annotationsN)�
AsyncIterator)�UTC�datetime)�Any)�MessagesRequest)�SERVER_TOOL_USE�WEB_FETCH_TOOL_ERROR�WEB_FETCH_TOOL_RESULT�WEB_SEARCH_TOOL_RESULT�WEB_SEARCH_TOOL_RESULT_ERROR)�format_sse_event)�_MAX_FETCH_CHARS)�WebFetchEgressPolicy)�
extract_query�extract_url)�forced_server_tool_name�forced_tool_turn_text�has_tool_namedc�$�V^8�dQhRRRRRR/#)��query�str�resultszlist[dict[str, str]]�return�)�formats"�?C:\Users\yashw\.claude\temp-hf-clone\api\web_tools\streaming.py�__annotate__rs"����3��)=��#��c	���V'gRV2#RV2.p\V^R7F,wr4VPVRVR,RVR,24K.	RPV4#)z!No web search results found for: zSearch results for: )�startz. �title�5�urlz6 7)�	enumerate�append�join)rr�lines�index�results&&   r�_search_summaryr+si���2�5�'�:�:�#�E�7�
+�,�E�"�7�!�4�
��
����w�b���� 1��F�5�M�?�C�D�5��;�;�u��r�verbose_client_errorsFc8�,�V^8�dQhRRRRRRRRR	R9/#)r�requestr�input_tokens�int�web_fetch_egressrr,�boolrzAsyncIterator[str]r)rs"rrr'sH��gE�gE�
�gE��gE�+�	gE�10 �gE��
gErc��"�^RIHp\V4pVe\W4'gR#\	V4pR\11P!42pR\12P!4P2pVR8XdRMRp	VR8XdR\V4/MR	\V4/p13R\R14\/pR\R15\/p\RRRR
RVRR
RRR.RVPRRRRRRVR^///45x�\RRRR^RR\ RVRVRV16//45x�\RRRR^/45x�VR8Xdc\#V17R,4p
VP%V
4GRjx�L18pVUu.uFpRRRVR,R	VR	,/NK	pp\'W�4p\pM�VP)\#V19R	,4V4GRjx�L20pRR R	VR	,RRR!R"RR#R$VR$,R%VR%,/RVR,R&R'R(//R)\*P,!\.4P14/pVR%,R\2p\p\;^\=V4^,4p\RRRR^RRVR.VRV//45x�\RRRR^/45x�\RRRR^RRR#R#R///45x�\R0RR0R^R1RR2R#V//45x�\RRRR^/45x�\R3RR3R1RR4RR/RRVRVR5V	^///45x�\R6RR6/45x�R#EL�uupiELC \4dcpTR218Xd\#T22R	,4MRpTP7TTTR*7Y�,pRY�,R+R,/pTP9TTTR-7pRp?EL6Rp?ii;i5i)7u�Stream a minimal Anthropic-shaped turn for forced `web_search` / `web_fetch` (local fallback).23 24When `ENABLE_WEB_SERVER_TOOLS` is on, this is a proxy-side execution path — not a full25hosted Anthropic citation or encrypted-content pipeline.26)�outboundN�msg_�	srvtoolu_�27web_search�web_search_requests�web_fetch_requestsrr$�	web_fetch�
message_start�type�message�id�role�	assistant�content�model�stop_reason�
stop_sequence�usager/�
output_tokens�content_block_startr)�
content_block�name�input�content_block_stop�web_search_resultr"�web_fetch_result�document�source�text�28media_type�data�	citations�enabledT�retrieved_at)�	fetch_url�29error_code�unavailable)�verbose�tool_use_id��content_block_delta�delta�30text_delta�
message_delta�end_turn�server_tool_use�message_stop)r[r4rrr�uuid�uuid4�hexrrrr31rr	r
rBrr�_run_web_searchr+�_run_web_fetchr�nowr�	isoformatr�	Exception�_log_web_tool_failure�_web_tool_client_error_summary�max�len)r.r/r1r,r4�	tool_namerP�32message_id�tool_id�	usage_key�33tool_input�_result_block_for_tool�_error_payload_type_for_toolrrr*�result_content�summary�result_block_type�fetched�errorrVrFs&&$$                   r�stream_web_server_tool_responser{'s~����'��0�I����w� B� B�� ��)�D���34�35��~�&�J��$�*�*�,�*�*�+�,�G�!*�l�!:��@T��36��$�37�-��%�&��[��&�
'��	�,��*���38	�2��)�$� �39���O���j��	����2������t����.�,���K�	�	40��� ���)��Q�����g��	���	�		41�����v�';�W�a�H���-42���$��43�7�+�,�E�$�4�4�U�;�;�G�&�
#�&�F�	�/��V�G�_��6�%�=��44&�

�#�&�e�5�G� 6��$�3�3��J�u�%�&�(8���G��*��w�u�~���J����$�g�l�&;������45�W�W�-��)�T�!2�	�����S� 1� ;� ;� =��N��f�o�&7�'7�8�G� 5����3�w�<�1�,�-�M�46���)��Q���)��w��>��	47�����v�';�W�a�H���48���)��Q��f�f�f�b�9�	49������)��Q��f�l�F�G�<�	50�����v�';�W�a�H������O��m�Z��$�G������!�I�q�>��	51����>�F�N�+C�52D�D�}<��#���(�5354�.7�;�.F�C�55�5�)�*�D�	��&�&�y�%�9�&�M�2�=���0�;��-�56���9�9��u�&;�:�57���5859�so�DM"�-K2�K'�K2�K*�3K2�M"�%K2�,K/�-A6K2�#CM"�'K2�*K2�2M�=AM�M"�M�M")!�__doc__�60__future__rrc�collections.abcrrr�typingr�api.models.anthropicr�core.anthropic.server_tool_sserr	r61rr�core.anthropic.sser
�	constantsr�egressr�parsersrrr.rrrr+r{rrr�<module>r�s[��I�"��)�"��0���0�'�(�/����gE�62#(�gE�gEr