6 releases (breaking)
Uses new Rust 2024
0.5.1 | Jun 26, 2025 |
---|---|
0.5.0 | Jun 24, 2025 |
0.4.0 | Jun 20, 2025 |
0.3.0 | Jun 16, 2025 |
0.1.0 | Jun 7, 2025 |
#478 in Database interfaces
723 downloads per month
250KB
3.5K
SLoC
CosmoFlow
A lightweight, type-safe workflow engine for Rust, optimized for LLM applications.
CosmoFlow provides a minimal yet powerful framework for building complex workflows with clean abstractions and excellent performance. It is:
- Lightweight: Minimal dependencies with optional features
- Type-Safe: Full Rust type safety with async/await support
- LLM-Optimized: Built-in patterns for AI/LLM workflows
- Modular: Enable only what you need through feature flags
Guides | API Docs | Examples | Cookbook
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 lightweight, async-based workflow scheduler.
- Pluggable storage system (memory, file, Redis).
- Asynchronous node execution with retry logic and error handling.
These components provide the runtime infrastructure necessary for building complex workflow applications.
Quick Start
Add to your Cargo.toml
:
[dependencies]
cosmoflow = { version = "0.5.1", features = ["storage-memory"] }
Create your first workflow:
use cosmoflow::prelude::*;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create storage
let mut store = MemoryStorage::new();
// Build workflow
let mut flow = FlowBuilder::new()
.node("start", MyNode::new())
.terminal_route("start", "complete")
.build();
// Execute
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.
Project Structure
This workspace contains:
Core Library
cosmoflow/
- The main CosmoFlow library with modular featurescosmoflow/examples/
- Simple feature demonstrations and basic usage patterns
Cookbook
cookbook/
- Production-ready examples and real-world solutionschat-assistant/
- Complete chat assistant implementationllm-request-handler/
- Efficient LLM request handling patternsunified-workflow/
- Advanced workflow composition examples
Quick Start
Basic Examples (Learning):
cd cosmoflow/
cargo run --example hello_world_sync
cargo run --example simple_loops --features async
Production Examples (Real Use Cases):
cd cookbook/chat-assistant/
cargo run
cd cookbook/unified-workflow/
cargo run
Core Modules
CosmoFlow provides a focused set of core modules:
cosmoflow
: Main integration and API crate for CosmoFlow workflows.cosmoflow::flow
: Workflow orchestration engine for managing complex multi-node workflows.cosmoflow::node
: Execution nodes system with async support and retry logic.cosmoflow::action
: Control flow logic and condition evaluation.cosmoflow::shared_store
: Thread-safe data communication layer between workflow components.
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.
Dependencies
~0.8–10MB
~105K SLoC