Value Referencing

Composing a Pipeline consists of chaining different Nodes together. Each Node can reference a value from any previous executed nodes (all fully typed of course 🎉).

You can configure the input of a Node using the Input Function which is the second parameter of the flow.node function. The Input Function receives a callback that accepts five arguments: input, prev, nodes, memory and userId

Input

The input argument references the values that were passed as arguments to the Pipeline itself with the invoke method.

index.ts

_10
myPipeline.invoke({ name: 'Boopsy' });
_10
_10
//...
_10
flow.node(replaceString, ({ input }) => ({
_10
text: input.name, // <-- 'Boopsy'
_10
modifier: 'tell me a joke about $(text)$',
_10
}))
_10
// ...

Prev

The prev argument references the output of the immediately previous node.

index.ts

_11
myPipeline.invoke({ name: 'Boopsy' });
_11
_11
//...
_11
flow.node(replaceString, ({ input }) => ({
_11
text: input.subject,
_11
modifier: 'tell me a joke about $(text)$',
_11
}))
_11
.node(gpt3Prediction, ({ prev }) => ({
_11
prompt: prev.text, // <-- 'tell me a joke about Boopsy'
_11
}))
_11
// ...

Nodes

The nodes argument gives you access to all previously executed nodes' outputs. The access is by their index in the pipeline definition.

Additional access methods are planned for future versions.

index.ts

_14
_14
//...
_14
flow.node(replaceString, ({ input }) => ({
_14
text: 'aaa',
_14
modifier: 'AAA $(text)$',
_14
}))
_14
.node(replaceString, ({ prev }) => ({
_14
text: 'bbb',
_14
modifier: 'BBB $(text)$',
_14
}))
_14
.node(gpt3Prediction, ({ nodes }) => ({
_14
prompt: `${nodes[0].output.text} ${nodes[1].output.text}`, // <-- 'AAA aaa BBB bbb'
_14
}))
_14
// ...

Memory

See Memory for more details.

UserId

See UserId for more details.