cosmoflow 0.1.0

CosmoFlow - A type-safe workflow engine for Rust, inspired by PocketFlow and optimized for LLM applications
Documentation

CosmoFlow

A runtime for writing reliable, asynchronous, and scalable workflow applications with the Rust programming language. It is:

  • Fast: CosmoFlow's zero-cost abstractions give you bare-metal performance for workflow orchestration.

  • Reliable: CosmoFlow leverages Rust's ownership, type system, and concurrency model to reduce bugs and ensure thread safety.

  • Scalable: CosmoFlow has a minimal footprint, and handles backpressure and cancellation naturally.

Crates.io MIT licensed Documentation

Guides | API Docs

Overview

CosmoFlow is a next-generation workflow engine that brings the elegant design philosophy of PocketFlow to the Rust ecosystem. Built from the ground up for LLM applications, high-performance scenarios, and production reliability. it provides a few major components:

  • A multithreaded, async-based workflow scheduler.
  • A pluggable storage system backed by memory, files, or custom backends.
  • Asynchronous node execution with retry logic and error handling.

These components provide the runtime infrastructure necessary for building complex workflow applications.

Example

A basic workflow with CosmoFlow.

Make sure you activated the full features of the cosmoflow crate on Cargo.toml:

[dependencies]
cosmoflow = { version = "0.1.0", features = ["full"] }

Then, on your main.rs:

use cosmoflow::prelude::*;
use std::time::Duration;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create a shared store with memory backend
    let mut store = SharedStore::memory();
    
    // Create a flow builder
    let flow = Flow::builder("hello-workflow")
        .with_store(&mut store)
        .build()?;

    // Execute the workflow
    let context = ExecutionContext::new(3, Duration::from_secs(30));
    let result = flow.execute(&mut store).await?;
    
    println!("Workflow completed: {:?}", result);
    Ok(())
}

To see a list of the available features flags that can be enabled, check our docs.

Getting Help

First, see if the answer to your question can be found in the Guides or the API documentation. If the answer is not there, there is an active community in the CosmoFlow Discord server. We would be happy to try to answer your question. You can also ask your question on the discussions page.

Module Ecosystem

CosmoFlow is built with a modular architecture. Each component is a module within the main cosmoflow crate, allowing you to use only what you need through feature flags while maintaining full composability:

License

This project is licensed under the MIT license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in CosmoFlow by you, shall be licensed as MIT, without any additional terms or conditions.