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

Function _parse_openai_events

tests/test_anthropic_compat.py:581–594  ·  view source on GitHub ↗
(raw_events: list[bytes])

Source from the content-addressed store, hash-verified

579
580
581def _parse_openai_events(raw_events: list[bytes]) -> tuple[list[dict], bool]:
582 results: list[dict] = []
583 done = False
584 for raw in raw_events:
585 text = raw.decode()
586 for line in text.strip().split("\n"):
587 if not line.startswith("data: "):
588 continue
589 payload = line[6:]
590 if payload == "[DONE]":
591 done = True
592 continue
593 results.append(json.loads(payload))
594 return results, done
595
596
597class TestStreamConverter:

Callers 1

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected