Spaces:
Running
Running
sync: upstream 9194f15 + custom addons (KeyRotator, RotatingChatTransport, sol/terra/luna, ScannerTrap, health, Py3.12 compat)
e99df76 Download src/free_claude_code/api/handlers/classifier_response.py from dherain24/claude-proxy: direct link, hf CLI and curl.
- Browser
- Download file 1.18 kB
-
https://huggingface.co/spaces/dherain24/claude-proxy/resolve/main/src/free_claude_code/api/handlers/classifier_response.py
- Command line
-
hf download hf://spaces/dherain24/claude-proxy/src/free_claude_code/api/handlers/classifier_response.py
-
curl -L -o classifier_response.py https://huggingface.co/spaces/dherain24/claude-proxy/resolve/main/src/free_claude_code/api/handlers/classifier_response.py
1.18 kB
| from __future__ import annotations | |
| """Hide structured provider reasoning from Claude's classifier response.""" | |
| import sys | |
| from collections.abc import AsyncIterator | |
| from free_claude_code.core.anthropic.streaming.decoder import AnthropicSSEDecoder | |
| from free_claude_code.core.trace import close_stream_input | |
| from ..classifier_projection import ClassifierProjection | |
| async def classifier_response(source: AsyncIterator[str]) -> AsyncIterator[str]: | |
| """Apply the same projection to private, nonstreaming aggregation.""" | |
| decoder = AnthropicSSEDecoder() | |
| projection = ClassifierProjection() | |
| try: | |
| async for chunk in source: | |
| for frame in decoder.feed_frames(chunk): | |
| projected = projection.feed(frame) | |
| if projected is not None: | |
| yield projected | |
| for frame in decoder.finish_frames(): | |
| projected = projection.feed(frame) | |
| if projected is not None: | |
| yield projected | |
| finally: | |
| await close_stream_input( | |
| source, | |
| owner="classifier_response", | |
| source="api", | |
| preserved_error=sys.exception(), | |
| ) | |