#agent #node #flow #system #pocketflow

pocketflow

A minimalist LLM framework. Let Agents build Agents!

1 unstable release

Uses new Rust 2024

new 0.1.0 Apr 28, 2025

#31 in #flow

Download history 88/week @ 2025-04-26

88 downloads per month

Apache-2.0

32KB
794 lines

pockerflow-rs

Pocket Flow: A minimalist LLM framework. Let Agents build Agents!

Rust version of PocketFlow


lib.rs:

PocketFlow

PocketFlow is a lightweight, composable workflow library for Rust that provides both synchronous and asynchronous execution patterns for data processing pipelines.

Features

  • Composable workflows: Build complex data processing pipelines from simple nodes
  • Synchronous and asynchronous support: Choose the execution model that fits your needs
  • Batch processing: Process multiple items efficiently
  • Parallel execution: Take advantage of multi-core systems

Examples

Simple synchronous flow

use pocketflow_rs::{Flow, Node};
use serde_json::json;

// Create a simple processing node
let node = Node::new(|data| {
    // Process the data
    let result = json!({"processed": data});
    Ok(result)
});

// Create a flow with the node
let mut flow = Flow::new();
flow.add_node(node);

// Run the flow with input data
let input = json!({"input": "value"});
let result = flow.run(&input).unwrap();

Asynchronous flow

use pocketflow_rs::{AsyncFlow, AsyncNode};
use serde_json::json;

// Create an async processing node
let node = AsyncNode::new(|data| {
    Box::pin(async move {
        // Asynchronous processing
        let result = json!({"processed": data});
        Ok(result)
    })
});

// Create an async flow with the node
let mut flow = AsyncFlow::new();
flow.add_node(node);

// Run the flow with input data
let input = json!({"input": "value"});
let result = flow.run_async(&input).await.unwrap();

Dependencies

~6–12MB
~136K SLoC