Expand description
Functional API for defining workflows with plain functions
This module provides the functional entrypoint/task API as an alternative
to StateGraph. Users can define workflows
using ordinary async functions with runtime context instead of manually
building graphs.
§Concepts
- Entrypoint functions - Main workflow functions that can be compiled into graphs
- Task configuration - Reusable functions with retry/cache/timeout policies
Runtime<S>- Provides access to previous state, checkpointer, and store
§Architecture
The functional API is a lightweight wrapper around StateGraph:
- Entrypoint functions compile to single-node graphs
- Task functions use
TaskConfigfor per-node configuration Runtime<S>provides the same context asCoreRuntimewith additional functional-API-specific features
§Example
ⓘ
use juncture_core::func::{compile_entrypoint, Runtime};
use juncture_core::checkpoint::MemorySaver;
use juncture_core::state::CowState;
use juncture_core::runtime::Runtime as CoreRuntime;
// Define the workflow function
async fn my_workflow(
state: CowState<MyState>,
runtime: &CoreRuntime<MyState>,
) -> Result<MyStateUpdate, JunctureError> {
Ok(MyStateUpdate::default())
}
// Compile into a graph
let graph = compile_entrypoint::<MyState, Input, Output, _>(
my_workflow,
Some(Arc::new(MemorySaver::new()))
)?;
// Execute
let result = graph.invoke(input, &config).await?;Structs§
- Runtime
- Runtime context for functional API workflows
Functions§
- compile_
entrypoint - Compile a functional workflow entrypoint into an executable graph
- compile_
entrypoint_ with_ config - Compile a functional workflow entrypoint with task configuration