Wesichain

Quick Start - ReAct Agent

This quick start uses the composable ReAct subgraph builder (ReActGraphBuilder).

1) Add Dependencies

[dependencies]
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
wesichain-core = "0.3.0"
wesichain-llm = "0.3.0"
wesichain-graph = "0.3.0"

2) Build the Graph

use std::sync::Arc;

use wesichain_core::{HasFinalOutput, HasUserInput, ScratchpadState, Tool, ToolCallingLlm};
use wesichain_graph::{GraphState, ReActGraphBuilder, StateSchema};

// AppState should implement:
// StateSchema<Update = AppState> + ScratchpadState + HasUserInput + HasFinalOutput + Default

let llm: Arc<dyn ToolCallingLlm> = Arc::new(my_llm);
let tools: Vec<Arc<dyn Tool>> = vec![Arc::new(CalculatorTool), Arc::new(SearchTool)];

let graph = ReActGraphBuilder::new()
    .llm(llm)
    .tools(tools)
    .build::<AppState>()?;

let initial = GraphState::new(AppState::from_input("Find 2+2 and explain it."));
let result = graph.invoke_graph(initial).await?;
println!("{:?}", result.data);

3) Run a Working Example

From the Wesichain repository root:

cargo run -p wesichain-examples --bin react_agent_subgraph

You can also run graph-level examples:

cargo run -p wesichain-graph --example react_agent
cargo run -p wesichain-graph --example persistent_conversation

Notes

  • ReActAgentNode is still available for compatibility.
  • For new code, prefer ReActGraphBuilder because it aligns with the v0.3 runtime direction.
Updated Edit on GitHub