// Define a custom node in Rust — 15 lines
use flow_like::prelude::*;
#[derive(Node)]
pub struct SentimentAnalyzer {
#[input] text: String,
#[output] score: f64,
#[output] label: String,
}
impl Execute for SentimentAnalyzer {
async fn run(&self, ctx: &Context) -> Result<()> {
let result = ctx.analyze(&self.text).await?;
self.score.set(result.score);
self.label.set(result.label);
Ok(())
}
}# Define a custom node in Python — 12 lines
from flow_like import Node, Input, Output, Context
class SentimentAnalyzer(Node):
text: Input[str]
score: Output[float]
label: Output[str]
async def run(self, ctx: Context):
result = await ctx.analyze(self.text)
self.score.set(result.score)
self.label.set(result.label)// Define a custom node in TypeScript — 14 lines
import { Node, Input, Output, Context } from '@flow-like/sdk';
export class SentimentAnalyzer extends Node {
@Input() text: string;
@Output() score: number;
@Output() label: string;
async run(ctx: Context): Promise<void> {
const result = await ctx.analyze(this.text);
this.score.set(result.score);
this.label.set(result.label);
}
}// Define a custom node in Go — 20 lines
package nodes
import "github.com/tm9657/flow-like-sdk-go"
type SentimentAnalyzer struct {
Text flowlike.Input[string]
Score flowlike.Output[float64]
Label flowlike.Output[string]
}
func (n *SentimentAnalyzer) Run(ctx *flowlike.Context) error {
result, err := ctx.Analyze(n.Text.Get())
if err != nil { return err }
n.Score.Set(result.Score)
n.Label.Set(result.Label)
return nil
}