Skip to main content

Crate flowgentra_ai

Crate flowgentra_ai 

Source
Expand description

§Project Hygiene

  • Enforce cargo fmt and clippy in CI.
  • Maintain a CHANGELOG.md for releases.
  • Keep CONTRIBUTING.md up 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:

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§

core
API Consistency
prelude
Prelude module for commonly used types and macros.

Attribute Macros§

register_handler
Register a handler function for automatic discovery.