Skip to main content

Crate flowgentra_ai

Crate flowgentra_ai 

Source
Expand description

FlowgentraAI: A Rust library for building AI agents with graphs

Build AI agent workflows using a declarative graph structure with:

  • Typed State: Define state as a Rust struct with #[derive(State)] — compile-time schema
  • Per-field Reducers: Control merge behavior with #[reducer(Append)], etc.
  • Nodes: Async functions that return partial state updates
  • Edges: Connections with optional conditional logic
  • 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::{Serialize, Deserialize};
use std::sync::Arc;

#[derive(State, Clone, Debug, Serialize, Deserialize)]
struct MyState {
    input: String,
    output: Option<String>,
}

// Build a graph — use #[node] + add_node, or FunctionNode directly
#[node]
async fn process(state: &MyState, _ctx: &Context) {
    update! { output: state.input.to_uppercase() }
}

let graph = StateGraph::<MyState>::builder()
    .add_node("process", process_node())
    .set_entry_point("process")
    .add_edge("process", "__end__")
    .compile()?;

Re-exports§

pub use core::agent::from_config_path;
pub use core::agent::from_config_path_with_extra_handlers;
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 flowgentra_ai_macros as macros;
pub use crate::prelude::*;

Modules§

core
FlowgentraAI Core Modules
prelude
Prelude module for commonly used types and macros.

Macros§

update
Build a partial state update with minimal syntax.

Attribute Macros§

register_handler
Register a handler function for automatic discovery.

Derive Macros§

State
Derive the State trait for a struct.