Spaces:
Running
Running
| import sys | |
| import traceback | |
| def monkey_patch(): | |
| from free_claude_code.api.handlers.messages import MessagesHandler | |
| orig = MessagesHandler._unexpected_execution_error_response | |
| def patched(self, exc, **kwargs): | |
| print('--- EXCEPTION TRACEBACK ---') | |
| traceback.print_exception(type(exc), exc, exc.__traceback__) | |
| print('---------------------------') | |
| return orig(self, exc, **kwargs) | |
| MessagesHandler._unexpected_execution_error_response = patched | |
| def run(): | |
| monkey_patch() | |
| from fastapi.testclient import TestClient | |
| from free_claude_code.runtime.bootstrap import build_asgi_app | |
| from free_claude_code.config.settings import Settings | |
| from free_claude_code.api.dependencies import require_proxy_auth | |
| app = build_asgi_app(Settings(nvidia_nim_api_key="FAKE")) | |
| app.dependency_overrides[require_proxy_auth] = lambda: None | |
| client = TestClient(app) | |
| client.post( | |
| "/v1/messages", | |
| json={ | |
| "model": "nvidia/nemotron", | |
| "messages": [{"role": "user", "content": "hi"}], | |
| "max_tokens": 10 | |
| } | |
| ) | |
| run() | |