@acosmi/sdk-ts 2.19.2 → 2.19.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.
- package/CHANGELOG.md +6 -0
- package/dist/browser/index.mjs +6 -2
- package/dist/browser/index.mjs.map +1 -1
- package/dist/index.mjs +6 -2
- package/dist/index.mjs.map +1 -1
- package/dist/node/adapters/openai.cjs +1 -1
- package/dist/node/adapters/openai.cjs.map +1 -1
- package/dist/node/adapters/openai.mjs +1 -1
- package/dist/node/adapters/openai.mjs.map +1 -1
- package/dist/node/index.cjs +6 -2
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +6 -1
- package/dist/node/index.d.ts +6 -1
- package/dist/node/index.mjs +6 -2
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1084,7 +1084,7 @@ var init_openai = __esm({
|
|
|
1084
1084
|
throw new Error(`parse openai stream chunk: ${e instanceof Error ? e.message : String(e)}`);
|
|
1085
1085
|
}
|
|
1086
1086
|
const events = [];
|
|
1087
|
-
if (chunk.choices.length === 0) {
|
|
1087
|
+
if (!Array.isArray(chunk.choices) || chunk.choices.length === 0) {
|
|
1088
1088
|
return { events, done: false };
|
|
1089
1089
|
}
|
|
1090
1090
|
const choice = chunk.choices[0];
|
|
@@ -4355,13 +4355,17 @@ var Client = class _Client {
|
|
|
4355
4355
|
}
|
|
4356
4356
|
if (adapter.format() === 1 /* OpenAI */) {
|
|
4357
4357
|
const converter = newOpenAIStreamConverter();
|
|
4358
|
+
let currentEvent = "";
|
|
4358
4359
|
for await (const line of iterSSELines(resp.body)) {
|
|
4359
4360
|
notifyUpstreamActivity(onUpstreamActivity);
|
|
4360
4361
|
if (isSSECommentLine(line)) continue;
|
|
4361
4362
|
if (line.startsWith("event:")) {
|
|
4362
|
-
line.slice("event:".length).trim();
|
|
4363
|
+
currentEvent = line.slice("event:".length).trim();
|
|
4363
4364
|
} else if (line.startsWith("data:")) {
|
|
4364
4365
|
const data = line.slice("data:".length).trim();
|
|
4366
|
+
if (currentEvent === "failed" || currentEvent === "error") {
|
|
4367
|
+
throw parseStreamError(data);
|
|
4368
|
+
}
|
|
4365
4369
|
const { events, done } = converter.convert(data);
|
|
4366
4370
|
for (const ev of events) yield ev;
|
|
4367
4371
|
if (done) return;
|