Building Node
Install Git
First, install Git and clone Flowise repository. You can follow the steps from the Get Started guide.
Structure
Flowise separate every node integration under the folder packages/components/nodes
. Let's try to create a simple Tool!
Create Calculator Tool
Create a new folder named Calculator
under the packages/components/nodes/tools
folder. Then create a new file named Calculator.ts
. Inside the file, we will first write the base class.
Every node will implements the INode
base class. Breakdown of what each property means:
label
The name of the node that appears on the UI
name
The name that is used by code. Must be camelCase
version
Version of the node
type
Usually the same as label. To define which node can be connected to this specific type on UI
icon
Icon of the node
category
Category of the node
author
Creator of the node
description
Node description
baseClasses
The base classes from the node, since a node can extends from a base component. Used to define which node can be connected to this node on UI
Define Class
Now the component class is partially finished, we can go ahead to define the actual Tool class, in this case - Calculator
.
Create a new file under the same Calculator
folder, and named as core.ts
Finishing
Head back to the Calculator.ts
file, we can finish this up by having the async init
function. In this function, we will initialize the Calculator class we created above. When the flow is being executed, the init
function in each node will be called, and the _call
function will be executed when LLM decides to call this tool.
Build and Run
In the .env
file inside packages/server
, create a new env variable:
Now we can use pnpm build
and pnpm start
to bring the component alive!
Last updated