laya/lib.rs
1//! # laya
2//!
3//! Pure-Rust port of the [Laya](https://github.com/NandhaKishorM/laya) non-autoregressive
4//! System-1 decision engine (the **Laya-Decision** project).
5//!
6//! Given a *state* (text, JSON, or a conversation list) and a set of *typed questions*
7//! (`choice`, `score`, `noul`), Laya scores every question in a single forward pass — no
8//! text generation. Inference runs natively on [candle]; the routing, language-detection,
9//! email-cleaning, preset and shortlist logic is dependency-free.
10//!
11//! The pure-logic modules build without the `model` feature; enabling it (on by default)
12//! pulls in candle + the Hugging Face tokenizer and Hub download.
13//!
14//! [candle]: https://github.com/huggingface/candle
15
16use indexmap::IndexMap;
17use serde_json::Value;
18
19pub mod common;
20pub mod email;
21pub mod error;
22pub mod lang;
23pub mod presets;
24pub mod router;
25
26#[cfg(feature = "model")]
27pub mod agent;
28#[cfg(feature = "model")]
29pub mod model;
30#[cfg(feature = "model")]
31pub mod shortlist;
32#[cfg(feature = "model")]
33pub mod tokenizer;
34
35/// A state to evaluate: a string, a JSON object, or a conversation list — represented as a
36/// [`serde_json::Value`]. A bare string is `Value::String`.
37pub type State = Value;
38
39/// An ordered map of question id → question definition. Order is significant (it determines
40/// choice-label and probability ordering), so this is an [`IndexMap`].
41pub type Questions = IndexMap<String, Value>;
42
43pub use error::{LayaError, Result};
44
45pub use common::{QType, TEMP_MAX, TEMP_MIN};
46pub use email::{clean_email_body, email_state};
47pub use lang::{analyse, detect_script, is_english};
48pub use presets::{
49 email_questions, guard_questions, moderation_questions, router_questions, triage_questions,
50};
51pub use router::{RouteDecision, RouteHints, Router, RouterOptions};
52
53#[cfg(feature = "model")]
54pub use agent::{Agent, SystemOneResult};
55#[cfg(feature = "model")]
56pub use shortlist::{embed_fn_from_agent, predict_shortlist, shortlist_choice};
57
58/// Crate version, mirroring the upstream Laya release this port tracks.
59pub const UPSTREAM_VERSION: &str = "0.4.13";