@nemesis-oss/ollama-sdk 1.24.1 → 1.25.0

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.
package/dist/index.cjs CHANGED
@@ -1300,10 +1300,11 @@ async function* parseNdjsonStream(stream) {
1300
1300
  // src/streaming/sse.ts
1301
1301
  function dispatch(event, data, id, retry) {
1302
1302
  if (data.length === 0) return void 0;
1303
- const joined = data.join("\n");
1303
+ const buffer = data.map((line) => `${line}
1304
+ `).join("");
1304
1305
  return {
1305
1306
  ...event !== void 0 ? { event } : {},
1306
- data: joined.endsWith("\n") ? joined.slice(0, -1) : joined,
1307
+ data: buffer.slice(0, -1),
1307
1308
  ...id !== void 0 ? { id } : {},
1308
1309
  ...retry !== void 0 ? { retry } : {}
1309
1310
  };
@@ -7493,7 +7494,7 @@ async function* observeStream(source, callbacks = {}) {
7493
7494
  }
7494
7495
  );
7495
7496
  };
7496
- let state = "running";
7497
+ let outcome;
7497
7498
  try {
7498
7499
  for await (const chunk of source) {
7499
7500
  if (onChunk !== void 0) {
@@ -7501,12 +7502,12 @@ async function* observeStream(source, callbacks = {}) {
7501
7502
  }
7502
7503
  yield chunk;
7503
7504
  }
7504
- state = "done";
7505
+ outcome = "done";
7505
7506
  if (onDone !== void 0) {
7506
7507
  dispatch2("done", () => onDone());
7507
7508
  }
7508
7509
  } catch (error) {
7509
- state = "error";
7510
+ outcome = "error";
7510
7511
  try {
7511
7512
  onError?.(error);
7512
7513
  } catch (listenerError) {
@@ -7514,8 +7515,7 @@ async function* observeStream(source, callbacks = {}) {
7514
7515
  }
7515
7516
  throw error;
7516
7517
  } finally {
7517
- if (state === "running") {
7518
- state = "abandoned";
7518
+ if (outcome === void 0) {
7519
7519
  try {
7520
7520
  onAbandon?.();
7521
7521
  } catch (listenerError) {