(controller)
| 669 | console.log("[DEMOD] Processing basic prompted conversation (is temporary: "+temp_chat+"). Scanning for moderation results..."); |
| 670 | const stream = new ReadableStream({ |
| 671 | async start(controller) { |
| 672 | var reader = original_result.body.getReader(); |
| 673 | |
| 674 | while (true) { |
| 675 | const { |
| 676 | done, |
| 677 | value |
| 678 | } = await reader.read(); |
| 679 | |
| 680 | var raw_chunk = value || new Uint8Array; |
| 681 | var chunk = decoder.decode(raw_chunk); |
| 682 | var response = new ChatResponse(payload, chunk, true); |
| 683 | |
| 684 | await response.process(response_blocked); |
| 685 | |
| 686 | if (mod_result < response.mod_result) { |
| 687 | mod_result = response.mod_result; |
| 688 | updateDeModMessageState(mod_result); |
| 689 | } |
| 690 | response_blocked = response.is_blocked; |
| 691 | payload = response.payload; |
| 692 | |
| 693 | for (const entry of response.queue) { |
| 694 | const encoded_chunk = encoder.encode(entry); |
| 695 | controller.enqueue(encoded_chunk); |
| 696 | } |
| 697 | |
| 698 | if (response.is_done || done) { |
| 699 | controller.close(); |
| 700 | break; |
| 701 | } |
| 702 | } |
| 703 | }, |
| 704 | }); |
| 705 | |
| 706 | return new Response(stream, { |
nothing calls this directly
no test coverage detected