Examples
import { CustomNode, ProcessContext } from '@inworld/runtime/graph';
// Define a custom node that processes the input text
class CustomTextNode extends CustomNode {
async process(
context: ProcessContext,
input: string,
): Promise<{ processedText: string }> {
return {
processedText: input.toUpperCase(),
};
}
}
// Create an instance of the custom node
const customTextNode = new CustomTextNode();
Constructors
Methods
Interfaces
Constructors
constructor
new CustomNode(props?: CustomNodeProps<ExecutionConfigType>): CustomNode
Creates a new CustomNode.
Parameters
props
CustomNodeProps<ExecutionConfigType>
Custom node options including optional executionConfig.
Returns
CustomNode
Methods
process
process(context: ProcessContext, inputs: InputType[]): OutputType | Promise<OutputType>
The execution function of the custom node. Must be implemented by subclasses.
Parameters
Returns
OutputType | Promise<OutputType>
Interfaces
CustomNodeProps
Configuration for a CustomNode.
Properties
executionConfig?: ExecutionConfigType
Execution configuration for the custom node.