(ms)
| 18 | const enc = new TextEncoder(); |
| 19 | const ndjson = (parts) => new ReadableStream({ start(c) { for (const p of parts) c.enqueue(enc.encode(p)); c.close(); } }); |
| 20 | const sleep = (ms) => new Promise((r) => setTimeout(r, ms)); |
| 21 | |
| 22 | function mockOllama(reqPath, body) { |
| 23 | const stream = !(body && body.stream === false); // ollama streams by default |