Team Ai
Apppublic

Yash030/claude-code-proxy

sourceHugging Faceupdated 5mo agoView on Hugging Face
2likes
optimization_handlers.cpython-314.pyc24 linesDownload Raw Back to __pycache__
1+
2�j,����Rt^RIt^RIHt^RIHt^RIHtHt^RI	H3t4HtHtH
t
HtHt^RIHt^RIHtHtRR	ltR5RltRR
ltRRltRRltRRltRRlt]]]]]].tRRltR#)z�Optimization handlers for fast-path API responses.6 7Each handler returns a MessagesResponse if the request matches and the8optimization is enabled, otherwise None.9N)�logger)�Settings)�extract_command_prefix�extract_filepaths_from_command)�is_filepath_extraction_request�is_prefix_detection_request�is_quota_check_request�is_suggestion_mode_request�is_title_generation_request�is_trivial_text_request)�MessagesRequest)�MessagesResponse�Usagec10�T�V^8�dQhR\R\R\R\R\/#)��request_data�text�input_tokens�
output_tokens�return)r�str�intr
)�formats"�DC:\Users\yashw\.claude\claude-code-free\api\optimization_handlers.py�__annotate__rs:��
�
�!�
�11
�
��	
�12�
��

�c��\R\P!42VPRRRV/.R\	W#R7R7#)�msg_�typer�end_turn�rr)�id�model�content�stop_reason�usage)r
�uuid�uuid4r"r)rrrrs&&$$r�_text_responser(sD���
�$�*�*�,�� �� � ��&�&�$�/�0����K��rc�J�V^8�dQhR\R\R\R,/#�rr�settingsrN�rrr
)rs"rrr*s)����!��-5�����rc��VP'gR#\V4wr#V'gR#\P!R4\	V\V4^d^R7#)z?Fast prefix detection - return command prefix without API call.Nz+Optimization: Fast prefix detection requestr )�fast_prefix_detectionrr�infor(r)rr+�
is_prefix_req�commands&&  r�try_prefix_detectionr2*sQ���)�)�)��8��F��M���13�K�K�=�>����w�'���	�rc�J�V^8�dQhR\R\R\R,/#r*r,)rs"rrr>�)����!��-5�����rc��VP'gR#\V4'gR#\P!R4\	VR^14^R7#)zMock quota probe requests.Nz0Optimization: Intercepted and mocked quota probezQuota check passed.r )�enable_network_probe_mockrrr/r(�rr+s&&r�try_quota_mockr8>sG���-�-�-��!�,�/�/��15�K�K�B�C������	�rc�J�V^8�dQhR\R\R\R,/#r*r,)rs"rrrPr4rc��VP'gR#\V4'gR#\P!R4\	VR^d^R7#)zSkip title generation requests.Nz.Optimization: Skipped title generation request�Conversationr )�enable_title_generation_skipr16rr/r(r7s&&r�try_title_skipr=PsG���0�0�0��&�|�4�4��17�K�K�@�A������	�rc�J�V^8�dQhR\R\R\R,/#r*r,)rs"rrrbr4rc��VP'gR#\V4'gR#\P!R4\	VR^d^R7#)zSkip suggestion mode requests.Nz-Optimization: Skipped suggestion mode request�r )�enable_suggestion_mode_skipr	rr/r(r7s&&r�try_suggestion_skiprBbsG���/�/�/��%�l�3�3��18�K�K�?�@���19���	�rc�J�V^8�dQhR\R\R\R,/#r*r,)rs"rrrts)����!��-5�����rc��VP'gR#\V4wr#pV'gR#\W44p\P!R4\VV^d^20R7#)z"Mock filepath extraction requests.Nz(Optimization: Mocked filepath extractionr )�enable_filepath_extraction_mockrrrr/r()rr+�is_fp�cmd�output�	filepathss&&    r�try_filepath_mockrJtsX���3�3�3��7��E��E����.�s�;�I�21�K�K�:�;������	�rc�J�V^8�dQhR\R\R\R,/#r*r,)rs"rrr�s)����!��-5�����rc�z�\V4wr#V'gR#\P!R4\VV^^R7#)zIFast-path trivial text requests (hi, ok, status checks) without API call.Nz,Optimization: Fast-path trivial text requestr )rrr/r()rr+�22is_trivialrs&&  r�try_trivial_textrN�s=��/�|�<��J���23�K�K�>�?������	�rc�J�V^8�dQhR\R\R\R,/#r*r,)rs"rrr�s)����!��-5�����rc�@�\FpV!W4pVfKVu#	R#)z@Run optimization handlers in order. Returns first match or None.N)�OPTIMIZATION_HANDLERS)rr+�handler�results&&  r�try_optimizationsrT�s(��)����0�����M�)�r)�__doc__r&�logurur�config.settingsr�
command_utilsrr�	detectionrrrr	r24r�models.anthropicr�models.responsesr
rr(r2r8r=rBrJrNrQrT�rr�<module>r]sn�����$�Q���.�5�
� �(�$�$�$�*�&������
��r