Skip to main content

noema_router/
lib.rs

1//! The initial text router for Noema.
2//!
3//! Plain-text user requests are routed before any reasoning model runs.
4//! [`NeedleRouter`] uses Needle 2 to decide whether a request is a simple,
5//! deterministic application action — "open my flashcards", "go to
6//! settings" — or whether it needs the full model:
7//!
8//! ```text
9//! User request
10//!     ↓
11//! NeedleRouter (Needle 2)
12//!     ├── simple action → RoutedAction (model never runs)
13//!     └── not recognised → Escalate → Gemma 4
14//! ```
15//!
16//! The actions come from an [`ActionRegistry`] (defaulting to the six simple
17//! Agora actions from the plan); each action is exposed to Needle as a tool
18//! with a name and description, so the router needs no custom prompts to
19//! stay on-schema.
20//!
21//! # Usage
22//!
23//! ```no_run
24//! use noema_core::Noema;
25//! use noema_router::NeedleRouter;
26//!
27//! # async fn example() -> noema_core::Result<()> {
28//! let router = NeedleRouter::from_default()?;
29//! let noema = Noema::builder()
30//!     .with_router(router)
31//!     // .with_model(gemma)  // handles escalated requests
32//!     .build()
33//!     .await?;
34//! # Ok(())
35//! # }
36//! ```
37
38pub mod action;
39pub mod formatter;
40pub mod router;
41
42pub use action::{ActionRegistry, ActionSpec};
43pub use formatter::NeedleToolFormatter;
44pub use router::NeedleRouter;