MCPcopy Create free account
hub / github.com/CommonstackAI/UncommonRoute / anthropic_sse

Function anthropic_sse

uncommon_route/proxy.py:5516–5534  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5514 )
5515
5516 async def anthropic_sse() -> AsyncGenerator[bytes, None]:
5517 stream_chunks: list[bytes] = []
5518 try:
5519 async for chunk in stream_resp.aiter_bytes():
5520 stream_chunks.append(chunk)
5521 for ev in converter.feed(chunk):
5522 yield ev
5523 for ev in converter.finish():
5524 yield ev
5525 await _record_stream_success(
5526 parse_stream_usage_metrics(stream_chunks, selected_model, _get_pricing()),
5527 stream_chunks=stream_chunks,
5528 )
5529 except Exception:
5530 await _record_stream_failure()
5531 raise
5532 finally:
5533 await _record_stream_aborted(stream_chunks=stream_chunks)
5534 await stream_resp.aclose()
5535
5536 return StreamingResponse(
5537 anthropic_sse(),

Callers 1

_handle_chat_coreFunction · 0.85

Calls 8

_record_stream_successFunction · 0.85
_get_pricingFunction · 0.85
_record_stream_failureFunction · 0.85
_record_stream_abortedFunction · 0.85
appendMethod · 0.45
feedMethod · 0.45
finishMethod · 0.45

Tested by

no test coverage detected