@alpic80/rivet-core 1.24.2-aidon.1 → 1.24.2-aidon.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.
|
@@ -9,12 +9,14 @@ function nodeMatches(spec, event) {
|
|
|
9
9
|
export async function* getProcessorEvents(processor, spec) {
|
|
10
10
|
const previousIndexes = new Map();
|
|
11
11
|
const usages = [];
|
|
12
|
+
let hasDelta = false;
|
|
12
13
|
for await (const event of processor.events()) {
|
|
13
14
|
if (event.type === 'partialOutput') {
|
|
14
15
|
if (spec.partialOutputs === true ||
|
|
15
16
|
nodeMatches(spec.partialOutputs, event)) {
|
|
16
17
|
const currentOutput = coerceType(event.outputs['response'], 'string');
|
|
17
18
|
const delta = currentOutput.slice(previousIndexes.get(event.node.id) ?? 0);
|
|
19
|
+
hasDelta = true;
|
|
18
20
|
yield {
|
|
19
21
|
type: 'partialOutput',
|
|
20
22
|
nodeId: event.node.id,
|
|
@@ -76,8 +78,8 @@ export async function* getProcessorEvents(processor, spec) {
|
|
|
76
78
|
usages.push(usage);
|
|
77
79
|
}
|
|
78
80
|
}
|
|
79
|
-
if (spec.nodeFinish === true ||
|
|
80
|
-
|
|
81
|
+
if ((spec.nodeFinish === true || nodeMatches(spec.nodeFinish, event)) &&
|
|
82
|
+
!(spec.removeFinalOutput && hasDelta)) {
|
|
81
83
|
yield {
|
|
82
84
|
type: 'nodeFinish',
|
|
83
85
|
outputs: event.outputs,
|
|
@@ -121,10 +123,11 @@ spec) {
|
|
|
121
123
|
return new ReadableStream({
|
|
122
124
|
async start(controller) {
|
|
123
125
|
const userEventHandler = async (eventName, data) => {
|
|
124
|
-
|
|
126
|
+
const graphEvent = {
|
|
125
127
|
name: eventName,
|
|
126
128
|
message: coerceType(data, 'string')
|
|
127
|
-
}
|
|
129
|
+
};
|
|
130
|
+
sendEvent(controller, 'event', { graphEvent });
|
|
128
131
|
};
|
|
129
132
|
const streamEvents = createOnStreamUserEvents(spec.userStreamEvents, userEventHandler);
|
|
130
133
|
if (streamEvents) {
|
|
@@ -159,6 +162,19 @@ export function getSingleNodeStream(processor, arg) {
|
|
|
159
162
|
return new ReadableStream({
|
|
160
163
|
async start(controller) {
|
|
161
164
|
try {
|
|
165
|
+
const userEventHandler = async (eventName, data) => {
|
|
166
|
+
const payload = {
|
|
167
|
+
name: eventName,
|
|
168
|
+
message: coerceType(data, 'string')
|
|
169
|
+
};
|
|
170
|
+
controller.enqueue(`event: ${JSON.stringify(payload)}\n\n`);
|
|
171
|
+
};
|
|
172
|
+
const streamEvents = createOnStreamUserEvents(spec.userStreamEvents, userEventHandler);
|
|
173
|
+
if (streamEvents) {
|
|
174
|
+
for (const [name, fn] of Object.entries(streamEvents)) {
|
|
175
|
+
processor.onUserEvent(name, fn);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
162
178
|
for await (const event of getProcessorEvents(processor, spec)) {
|
|
163
179
|
if (event.type === 'partialOutput') { //nodeIdOrTitle filter managed by spec
|
|
164
180
|
controller.enqueue(`data: ${JSON.stringify(event.delta)}\n\n`);
|
|
@@ -13,7 +13,6 @@ import { coerceTypeOptional } from '../utils/coerceType.js';
|
|
|
13
13
|
import { globalRivetNodeRegistry } from './Nodes.js';
|
|
14
14
|
import { getPluginConfig } from '../utils/index.js';
|
|
15
15
|
import { GptTokenizerTokenizer } from '../integrations/GptTokenizerTokenizer.js';
|
|
16
|
-
// eslint-disable-next-line import/no-cycle -- There has to be a cycle because CodeRunner needs to import the entirety of Rivet
|
|
17
16
|
import { IsomorphicCodeRunner } from '../integrations/CodeRunner.js';
|
|
18
17
|
// CJS compatibility, gets default.default for whatever reason
|
|
19
18
|
let PQueue = PQueueImport;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type NodeId, type Inputs, type Outputs, type GraphOutputs, type GraphProcessor, type DataValue, type RunGraphOptions } from '../index.js';
|
|
1
|
+
import { type NodeId, type Inputs, type Outputs, type GraphOutputs, type GraphProcessor, type DataValue, type RunGraphOptions, type GraphEvents } from '../index.js';
|
|
2
2
|
export type RivetEventStreamFilterSpec = {
|
|
3
3
|
/** Stream partial output deltas for the specified node IDs or node titles. */
|
|
4
4
|
partialOutputs?: string[] | true;
|
|
@@ -41,8 +41,7 @@ export type RivetEventStreamEvent = {
|
|
|
41
41
|
graphOutput: GraphOutputs;
|
|
42
42
|
};
|
|
43
43
|
event: {
|
|
44
|
-
|
|
45
|
-
message: string;
|
|
44
|
+
graphEvent: GraphEvents;
|
|
46
45
|
};
|
|
47
46
|
error: {
|
|
48
47
|
error: string;
|
|
@@ -126,6 +126,10 @@ export type ProcessEvent = {
|
|
|
126
126
|
}[keyof ProcessEvents];
|
|
127
127
|
export type GraphOutputs = Record<string, DataValue>;
|
|
128
128
|
export type GraphInputs = Record<string, DataValue>;
|
|
129
|
+
export type GraphEvents = {
|
|
130
|
+
name: string;
|
|
131
|
+
message: string;
|
|
132
|
+
};
|
|
129
133
|
export type NodeResults = Map<NodeId, Outputs>;
|
|
130
134
|
export type Inputs = Record<PortId, DataValue | undefined>;
|
|
131
135
|
export type Outputs = Record<PortId, DataValue | undefined>;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@alpic80/rivet-core",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"repository": "https://github.com/castortech/rivet",
|
|
5
|
-
"version": "1.24.2-aidon.
|
|
5
|
+
"version": "1.24.2-aidon.3",
|
|
6
6
|
"packageManager": "yarn@3.5.0",
|
|
7
7
|
"main": "dist/cjs/bundle.cjs",
|
|
8
8
|
"module": "dist/esm/index.js",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@google-cloud/vertexai": "^0.1.3",
|
|
49
49
|
"@google/genai": "^0.12.0",
|
|
50
50
|
"@huggingface/inference": "^2.6.4",
|
|
51
|
-
"@ironclad/rivet-core": "npm:@alpic80/rivet-core@1.24.2-aidon.
|
|
51
|
+
"@ironclad/rivet-core": "npm:@alpic80/rivet-core@1.24.2-aidon.3",
|
|
52
52
|
"assemblyai": "^4.6.0",
|
|
53
53
|
"autoevals": "^0.0.26",
|
|
54
54
|
"cron-parser": "^4.9.0",
|