@nemesis-oss/ollama-sdk 1.25.1 → 1.25.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- export { I as InvokeRequest, O as OllamaRuntime, b as OllamaRuntimeOptions, a as OperationDefinition, S as SchemaRef } from './runtime-CUzw4GAE.cjs';
1
+ export { I as InvokeRequest, O as OllamaRuntime, b as OllamaRuntimeOptions, a as OperationDefinition, S as SchemaRef } from './runtime-BoTPAvJH.cjs';
2
2
  import { z } from 'zod';
3
3
  import './types-CH3pdrak.cjs';
4
4
 
@@ -1,4 +1,4 @@
1
- export { I as InvokeRequest, O as OllamaRuntime, b as OllamaRuntimeOptions, a as OperationDefinition, S as SchemaRef } from './runtime-D_rMXIVT.js';
1
+ export { I as InvokeRequest, O as OllamaRuntime, b as OllamaRuntimeOptions, a as OperationDefinition, S as SchemaRef } from './runtime-DQRudJFP.js';
2
2
  import { z } from 'zod';
3
3
  import './types-CH3pdrak.js';
4
4
 
@@ -245,34 +245,32 @@ async function* parseSseStream(stream) {
245
245
  }
246
246
  return void 0;
247
247
  };
248
- const _reader = __using(_stack, disposableReader(reader), true);
249
- while (true) {
250
- const { done, value } = await reader.read();
251
- if (done) break;
252
- buffer += decoder.decode(value, { stream: true });
248
+ function* drainLines(endOfStream) {
253
249
  while (true) {
254
250
  const lf = buffer.indexOf("\n");
255
251
  const cr = buffer.indexOf("\r");
256
- if (lf === -1 && cr === -1) break;
257
- if (cr !== -1 && lf === -1 && cr === buffer.length - 1) break;
252
+ if (lf === -1 && cr === -1) return;
253
+ if (!endOfStream && lf === -1 && cr === buffer.length - 1) return;
258
254
  const lineEnd = lf === -1 ? cr : cr === -1 ? lf : Math.min(lf, cr);
259
- let separatorLength = 1;
260
- if (buffer[lineEnd] === "\r" && buffer[lineEnd + 1] === "\n") {
261
- separatorLength = 2;
262
- }
255
+ const separatorLength = buffer[lineEnd] === "\r" && buffer[lineEnd + 1] === "\n" ? 2 : 1;
263
256
  const line = buffer.slice(0, lineEnd);
264
257
  buffer = buffer.slice(lineEnd + separatorLength);
265
258
  const event = processLine(line);
266
259
  if (event) yield event;
267
260
  }
268
261
  }
262
+ const _reader = __using(_stack, disposableReader(reader), true);
263
+ while (true) {
264
+ const { done, value } = await reader.read();
265
+ if (done) break;
266
+ buffer += decoder.decode(value, { stream: true });
267
+ yield* drainLines(false);
268
+ }
269
269
  buffer += decoder.decode();
270
- if (buffer.length > 0) {
271
- const event = processLine(buffer);
272
- if (event) yield event;
270
+ yield* drainLines(true);
271
+ if (data.length > 0 || buffer.length > 0) {
272
+ throw new OllamaStreamError("SSE stream ended mid-event; the incomplete event was discarded");
273
273
  }
274
- const terminal = dispatch(eventType, data, lastEventId, retry);
275
- if (terminal) yield terminal;
276
274
  } catch (_) {
277
275
  var _error = _, _hasError = true;
278
276
  } finally {