Team Ai
Apppublic

Yash030/claude-code-proxy

sourceHugging Faceupdated 5mo agoView on Hugging Face
2likes
app.cpython-314.pyc76 linesDownload Raw Back to __pycache__
1+
2sj��� �Rt^RIt^RIHt^RIHt^RIHtHt^RI	H3t4^RIHt^RI
Ht^RIHt^R	IHtHtHt^R5IHt^RIHt^RIHt^R
IHt^R
IHt^RIH t H!t!^RI"H#t#]RRl4t$!RR4t%RR/RRllt&RRlt'R#)z.FastAPI application factory and configuration.N)�asynccontextmanager)�Any)�FastAPI�Request)�$request_validation_exception_handler)�RequestValidationError)�JSONResponse)�logger)�Receive�Scope�Send)�configure_logging)�get_settings)�
ProviderError)�router)�6AppRuntime�startup_failure_message)�!summarize_request_validation_bodyc�$�V^8�dQhR\/#���app�r)�formats"�2C:\Users\yashw\.claude\claude-code-free\api\app.py�__annotate__rs������c��"�\P!V\4R7pVP4GRjx�L7R5x�VP	4GRjx�L8R#L#L5i)zApplication lifespan manager.��settingsN)r�for_appr�startup�shutdown)r�runtimes& r�lifespanr$sJ���� � ��|�~�>�G�9�/�/�10���	�11�12�13�14���	��s!�4A�A�A�A�A�Ac�la�]tRt^#toRtV3RlRltV3RlRltV3RlRltV3RlR	ltR15t	Vt16R#)�GracefulLifespanAppzHASGI wrapper that reports startup failures without Starlette tracebacks.c� <�V^8�dQhRS[/#rr)r�
__classdict__s"�rr� GracefulLifespanApp.__annotate__&s�����G�rc��WnR#�N�r)�selfrs&&r�__init__�GracefulLifespanApp.__init__&s���rc�&<�V^8�dQhRS[RS[/#)r�name�return)�strr)rr(s"�rrr))s���'�'��'��'rc�.�\VPV4#r+)�getattrr)r-r1s&&r�__getattr__�GracefulLifespanApp.__getattr__)s���t�x�x��&�&rc�0<�V^8�dQhRS[RS[RS[RR/#)r�scope�receive�sendr2N)rr17r)rr(s"�rrr),s)���,�,�E�,�G�,�4�,�D�,rc��"�VR,R8wdVPWV4GRjx�L18R#VPW#4GRjx�L19R#L!L5i)�typer$N)r�	_lifespan)r-r9r:r;s&&&&r�__call__�GracefulLifespanApp.__call__,sB�����=�J�&��(�(�5�4�0�0�0���n�n�W�+�+�+�
1�+�s!�$A�A�A�A20�A�21Ac�*<�V^8�dQhRS[RS[RR/#)rr:r;r2N)r22r)rr(s"�rrr)2s"�����w��d��t�rc23��"�\4p\P!VPVR7pRpV!4GRjx�L24pVR,R8Xd0VP	4GRjx�L25RpT!RR/4GRjx�L26KMVR,R	8XgK]V'dVP4GRjx�L27V!RR
/4GRjx�L28R#L�La \29d*pT!RRR\
Y74/4GRjx�L30Rp?R#Rp?ii;iL�LU \31dKp\P!R32\T4P4T!RRRR/4GRjx�L33Rp?R#Rp?ii;iL�5i)rFTNr=zlifespan.startupzlifespan.startup.failed�messagezlifespan.startup.completezlifespan.shutdownzShutdown failed: exc_type={}zlifespan.shutdown.failed�zlifespan.shutdown.complete)rrr rr!�	Exceptionrr"r	�errorr=�__name__)r-r:r;rr#�startup_completerC�excs&&&     rr>�GracefulLifespanApp._lifespan2sR����>���$�$�T�X�X��A�� ���#�I�o�G��v��"4�4�	�!�/�/�+�+�+�$(� ��F�$?�@�A�A�A���v��"5�5�#��%�.�.�0�0�0�34�F�$@�A�B�B�B��3&�,�� ���"�$=�%�'>�x�'M���������B�1��$�����%C�T�#�Y�EW�EW�X�"�F�,F�	�SU�#V�W�W�W�����C�s��:E�C�E�C�#C�$C�(E�7C>�8E�E�D�*D�+D�/
E�<E�=E�C�C;�C6�*C-�+C6�0E�6C;�;E�D�E�
9E�E	�E�E�E�Er,N)rG�35__module__�__qualname__�__firstlineno__�__doc__r.r6r?r>�__static_attributes__�__classdictcell__)r(s@rr&r&#s0����R���'�'�,�,��rr&�lifespan_enabledTc�0�V^8�dQhR\R\/#)rrQr2)�boolr)rs"rrrSs��Y�Y�D�Y�G�Yrc��\4p\VPVPR7RRRR/pV'd36\VR&\R
/VBpVP
\4VP
\4VP\4RRl4pVP\4R	R37l4pVP\4RRl4pV#)z-Create and configure the FastAPI application.)�verbose_third_party�titlezClaude Code Proxy�versionz2.0.0r$c�0�V^8�dQhR\R\/#�r�requestrI)rr)rs"rr� create_app.<locals>.__annotate__hs��H�H��H�>T�Hrc��n"�VP4GRjx�L38p\	V4wrE\39P!RVPP\VPP4VP4Uu.uFp\VPRR44NK 	upVP4Uu.uFp\VPRR44NK 	upVV4\W4GRjx�L40#L� \d#pR\T4P/pRp?ELRp?ii;iuupiuupiL@5i)z;Log request shape for 422 debugging without content values.N�_json_errorziRequest validation failed: path={} query={} error_locs={} error_types={} message_summary={} tool_names={}�locr=rD�)�jsonrEr=rGrr	�debug�url�pathr3�query�errors�list�getr)rZrI�body�e�message_summary�41tool_namesrFs&&     r�validation_error_handler�,create_app.<locals>.validation_error_handlergs����	5� ����'�D�'H��&M�#�����w��K�K�������!�!�"�58�Z�Z�\�B�\�E�T�%�)�)�E�2�&�
'�\�B�58�Z�Z�\�B�\�E�S����6�2�&�
'�\�B���	42�:�'�G�G�G�(���	5�!�4��7�#3�#3�4�D��	5��
C��B�H�sb�D5�C9�C7�C9�A#D5�?$D)�#D5�7$D.�D5�2D3�3D5�7C9�9D&�D!�D5�!D&�&D5c�0�V^8�dQhR\R\/#rY)rr)rs"rrr[~s��43�44�g�45�M�46rc��T"�\4pVP'd9\P!RVPVP47VP4M,\P!RVPVP484\VP49VP4R7#5i)z<Handle provider-specific errors and return Anthropic format.z7Provider Error: error_type={} status_code={} message={}z,Provider Error: error_type={} status_code={}��status_code�content)	r�log_api_error_tracebacksr	rF�50error_typerqrCr�to_anthropic_format)rZrI�err_settingss&& r�provider_error_handler�*create_app.<locals>.provider_error_handler}s���$�~���0�0�0��L�L�I����������	
�
�L�L�>�������
�51�����+�+�-�52�	53�s�B&B(c�0�V^8�dQhR\R\/#rY)rrE)rs"rrr[�s��54�55�W�56�9�57rc58��"�\4pVP'dB\P!RV4\P!\P59!44MJ\P!RVPPVP\V4P4\RRRRRRRR//R	7#5i)60z2Handle general errors and return Anthropic format.zGeneral Error: {}z,General Error: path={} method={} exc_type={}i�r=rF�	api_errorrCzAn unexpected error occurred.rp)rrsr	rF�	traceback�61format_excrbrc�methodr=rGr)rZrIrs&& r�general_error_handler�)create_app.<locals>.general_error_handler�s���� �>���,�,�,��L�L�,�c�2��L�L��-�-�/�0��L�L�>���� � �����S�	�"�"�	
�������K��>���	62�		63�s�B=B?r_)
rr
�log_file�log_raw_api_payloadsr$r�include_routerr�admin_router�exception_handlerrrrE)rQr�64app_kwargsrrlrwrs$      r�65create_appr�Ss����~�H�����x�/L�/L��66	�$��7�"�J��!)�67�:��68�69�J�70�C����v�����|�$�	���1�2�H�3�H�*	���=�)�71�*�72�*	���9�%�73�&�74�0�Jrc�$�V^8�dQhR\/#)rr2)r&)rs"rrr�s��C�C�,�Crc�,�\\RR74#)zDCreate the server ASGI app with graceful lifespan failure reporting.F)rQ)r&r�r_rr�create_asgi_appr��s���z�5�A�B�Br)(rNr|�75contextlibr�typingr�fastapirr�fastapi.exception_handlersr�fastapi.exceptionsr�fastapi.responsesr�logurur	�starlette.typesr76rr�config.logging_configr
�config.settingsr�providers.exceptionsr�adminrr��routesr#rr�validation_logrr$r&r�r�r_rr�<module>r�so��4��*��$�K�5�*��0�0�3�(�.�)��8�=�����-�-�`Y�4�Y�xCr