(raw_events: list[bytes])
| 579 | |
| 580 | |
| 581 | def _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 | |
| 597 | class TestStreamConverter: |
no test coverage detected