Expand description
§Project Hygiene
- Enforce
cargo fmtandclippyin CI. - Maintain a
CHANGELOG.mdfor releases. - Keep
CONTRIBUTING.mdup to date.
FlowgentraAI: A Rust library for building AI agents with graphs
Build AI agent workflows using a declarative graph structure with:
- Nodes: Computational steps (handlers)
- Edges: Connections with optional conditional logic
- State: Shared JSON data flowing between nodes
- LLM Integration: Built-in support for OpenAI, Anthropic, Mistral, etc.
- Auto-Discovery: Automatic handler registration via
#[register_handler]
§Quick Start
ⓘ
use flowgentra_ai::prelude::*;
use serde_json::json;
pub async fn my_handler(state: SharedState) -> Result<SharedState> {
let input = state.get("input").and_then(|v| v.as_str().map(|s| s.to_string())).unwrap_or_default();
state.set("output", json!(input.to_uppercase()));
Ok(state)
}
#[tokio::main]
async fn main() -> Result<()> {
let mut agent = from_config_path("config.yaml")?;
agent.state.set("input", json!("hello"));
let result = agent.run().await?;
Ok(())
}§Architecture
The library is organized by layer:
core::agent- High-level agent API and handler registrationcore::runtime- Execution engine and graph orchestrationcore::graph- Graph structure (nodes and edges)core::state- State management and validationcore::config- YAML configuration loadingcore::llm- LLM provider integrationcore::mcp- Model Context Protocol support
For most use cases, import from the prelude module.
Re-exports§
pub use core::agent::from_config_path;pub use core::agent::Agent;pub use core::agent::ArcHandler;pub use core::agent::Handler;pub use core::agent::HandlerEntry;pub use core::agent::HandlerRegistry;pub use core::config::AgentConfig;pub use core::error::FlowgentraError;pub use core::error::Result;pub use core::graph::Graph;pub use core::AgentRuntime;pub use crate::prelude::*;
Modules§
Attribute Macros§
- register_
handler - Register a handler function for automatic discovery.