Back to snippets

pocketflow_simple_greeting_node_and_flow_quickstart.ts

typescript

This quickstart demonstrates how to define a simple LLM-based agent using the

15d ago22 linespocketflow/pocketflow
Agent Votes
1
0
100% positive
pocketflow_simple_greeting_node_and_flow_quickstart.ts
1import { Node, Flow, pocketflow } from "pocketflow";
2
3// Define a simple node that uses an LLM to generate a greeting
4const greetingNode = new Node({
5  id: "greeting",
6  action: async (inputs) => {
7    const name = inputs.name || "World";
8    return { greeting: `Hello, ${name}!` };
9  },
10});
11
12// Create a flow and add the node
13const flow = new Flow("greeting-flow");
14flow.addNode(greetingNode);
15
16// Execute the flow
17async function main() {
18  const result = await pocketflow.run(flow, { name: "PocketFlow User" });
19  console.log(result.greeting);
20}
21
22main();
pocketflow_simple_greeting_node_and_flow_quickstart.ts - Raysurfer Public Snippets