Skip to content

Use Claude Code, Codex, VSCode, Pi, and OpenCode (and 6 other harnesses) for free (1.3B+ free tokens) from your terminal, app, IDE, or phone, and now from the browser with native browser sessions (multi-harness + multi-model) like OpenClaw (voice supported + ToS friendly)

Python
1.1 KB
Raw Blame
"""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(),
        )