@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.
@@ -1,5 +1,10 @@
1
1
  import {} from '../index.js';
2
2
  import { coerceType } from '../utils/coerceType.js';
3
+ function nodeMatches(spec, event) {
4
+ return spec?.includes(event.node.id) ||
5
+ spec?.includes(event.node.data?.id) ||
6
+ spec?.includes(event.node.title);
7
+ }
3
8
  /** A simplified way to listen and stream processor events, including filtering. */
4
9
  export async function* getProcessorEvents(processor, spec) {
5
10
  const previousIndexes = new Map();
@@ -7,8 +12,7 @@ export async function* getProcessorEvents(processor, spec) {
7
12
  for await (const event of processor.events()) {
8
13
  if (event.type === 'partialOutput') {
9
14
  if (spec.partialOutputs === true ||
10
- spec.partialOutputs?.includes(event.node.id) ||
11
- spec.partialOutputs?.includes(event.node.title)) {
15
+ nodeMatches(spec.partialOutputs, event)) {
12
16
  const currentOutput = coerceType(event.outputs['response'], 'string');
13
17
  const delta = currentOutput.slice(previousIndexes.get(event.node.id) ?? 0);
14
18
  yield {
@@ -56,8 +60,7 @@ export async function* getProcessorEvents(processor, spec) {
56
60
  }
57
61
  else if (event.type === 'nodeStart') {
58
62
  if (spec.nodeStart === true ||
59
- spec.nodeStart?.includes(event.node.id) ||
60
- spec.nodeStart?.includes(event.node.title)) {
63
+ nodeMatches(spec.nodeStart, event)) {
61
64
  yield {
62
65
  type: 'nodeStart',
63
66
  inputs: event.inputs,
@@ -74,8 +77,7 @@ export async function* getProcessorEvents(processor, spec) {
74
77
  }
75
78
  }
76
79
  if (spec.nodeFinish === true ||
77
- spec.nodeFinish?.includes(event.node.id) ||
78
- spec.nodeFinish?.includes(event.node.title)) {
80
+ nodeMatches(spec.nodeFinish, event)) {
79
81
  yield {
80
82
  type: 'nodeFinish',
81
83
  outputs: event.outputs,
@@ -134,6 +136,10 @@ export function getSingleNodeStream(processor, arg) {
134
136
  if (event.type === 'partialOutput') { //nodeIdOrTitle filter managed by spec
135
137
  controller.enqueue(`data: ${JSON.stringify(event.delta)}\n\n`);
136
138
  }
139
+ else if (event.type === 'nodeFinish') {
140
+ const value = event.outputs['valueOutput']?.value;
141
+ controller.enqueue(`data: ${JSON.stringify(value)}\n\n`);
142
+ }
137
143
  else if (event.type === 'error') {
138
144
  controller.enqueue(`error: ${JSON.stringify(event.error)}\n\n`);
139
145
  }
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.0-aidon.4",
5
+ "version": "1.24.0-aidon.5",
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/generative-ai": "^0.24.0",
50
50
  "@huggingface/inference": "^2.6.4",
51
- "@ironclad/rivet-core": "npm:@alpic80/rivet-core@1.24.0-aidon.4",
51
+ "@ironclad/rivet-core": "npm:@alpic80/rivet-core@1.24.0-aidon.5",
52
52
  "assemblyai": "^4.6.0",
53
53
  "autoevals": "^0.0.26",
54
54
  "cron-parser": "^4.9.0",