@alpic80/rivet-core 1.24.0-aidon.4 → 1.24.0-aidon.5
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/cjs/bundle.cjs +13 -4
- package/dist/cjs/bundle.cjs.map +2 -2
- package/dist/esm/api/streaming.js +12 -6
- package/package.json +2 -2
package/dist/cjs/bundle.cjs
CHANGED
|
@@ -21882,13 +21882,16 @@ var dotProductSimilarity = (a, b) => {
|
|
|
21882
21882
|
};
|
|
21883
21883
|
|
|
21884
21884
|
// src/api/streaming.ts
|
|
21885
|
+
function nodeMatches(spec, event) {
|
|
21886
|
+
var _a;
|
|
21887
|
+
return (spec == null ? void 0 : spec.includes(event.node.id)) || (spec == null ? void 0 : spec.includes((_a = event.node.data) == null ? void 0 : _a.id)) || (spec == null ? void 0 : spec.includes(event.node.title));
|
|
21888
|
+
}
|
|
21885
21889
|
async function* getProcessorEvents(processor, spec) {
|
|
21886
|
-
var _a, _b, _c, _d, _e, _f;
|
|
21887
21890
|
const previousIndexes = /* @__PURE__ */ new Map();
|
|
21888
21891
|
const usages = [];
|
|
21889
21892
|
for await (const event of processor.events()) {
|
|
21890
21893
|
if (event.type === "partialOutput") {
|
|
21891
|
-
if (spec.partialOutputs === true || (
|
|
21894
|
+
if (spec.partialOutputs === true || nodeMatches(spec.partialOutputs, event)) {
|
|
21892
21895
|
const currentOutput = coerceType(event.outputs["response"], "string");
|
|
21893
21896
|
const delta = currentOutput.slice(previousIndexes.get(event.node.id) ?? 0);
|
|
21894
21897
|
yield {
|
|
@@ -21931,7 +21934,7 @@ async function* getProcessorEvents(processor, spec) {
|
|
|
21931
21934
|
};
|
|
21932
21935
|
}
|
|
21933
21936
|
} else if (event.type === "nodeStart") {
|
|
21934
|
-
if (spec.nodeStart === true || (
|
|
21937
|
+
if (spec.nodeStart === true || nodeMatches(spec.nodeStart, event)) {
|
|
21935
21938
|
yield {
|
|
21936
21939
|
type: "nodeStart",
|
|
21937
21940
|
inputs: event.inputs,
|
|
@@ -21946,7 +21949,7 @@ async function* getProcessorEvents(processor, spec) {
|
|
|
21946
21949
|
usages.push(usage);
|
|
21947
21950
|
}
|
|
21948
21951
|
}
|
|
21949
|
-
if (spec.nodeFinish === true || (
|
|
21952
|
+
if (spec.nodeFinish === true || nodeMatches(spec.nodeFinish, event)) {
|
|
21950
21953
|
yield {
|
|
21951
21954
|
type: "nodeFinish",
|
|
21952
21955
|
outputs: event.outputs,
|
|
@@ -21992,11 +21995,17 @@ function getSingleNodeStream(processor, arg) {
|
|
|
21992
21995
|
}
|
|
21993
21996
|
return new ReadableStream({
|
|
21994
21997
|
async start(controller) {
|
|
21998
|
+
var _a;
|
|
21995
21999
|
try {
|
|
21996
22000
|
for await (const event of getProcessorEvents(processor, spec)) {
|
|
21997
22001
|
if (event.type === "partialOutput") {
|
|
21998
22002
|
controller.enqueue(`data: ${JSON.stringify(event.delta)}
|
|
21999
22003
|
|
|
22004
|
+
`);
|
|
22005
|
+
} else if (event.type === "nodeFinish") {
|
|
22006
|
+
const value = (_a = event.outputs["valueOutput"]) == null ? void 0 : _a.value;
|
|
22007
|
+
controller.enqueue(`data: ${JSON.stringify(value)}
|
|
22008
|
+
|
|
22000
22009
|
`);
|
|
22001
22010
|
} else if (event.type === "error") {
|
|
22002
22011
|
controller.enqueue(`error: ${JSON.stringify(event.error)}
|