Expand description
Tensor-free core for Laya typed decisions.
Everything here is independent of the inference backend: prompt
construction, question validation, routing signals, calibration and the
question presets. The laya crate adds the candle model on top.
Keeping this crate free of tensor dependencies means a service that only needs routing or prompt construction — an API gateway deciding which checkpoint a request belongs to, say — can depend on it without pulling in candle or any GPU runtime.
use laya_core::lang;
use serde_json::json;
let detection = lang::analyse(&json!(
"Mein Konto wurde zweimal belastet und ich möchte eine Rückerstattung"
));
assert_eq!(detection.language.as_deref(), Some("de"));
assert!(!detection.is_english);The heuristic needs a few function words before it commits: a short German
phrase such as "Mein Konto wurde zweimal belastet" is still reported as
English, matching upstream exactly (its own Router docstring claims
otherwise, but the implementation does not).
Re-exports§
pub use error::Error;pub use error::Result;pub use question::Criteria;pub use question::Question;pub use question::QuestionKind;pub use tokenizer::Tokenizer;
Modules§
- calibrate
- Temperature calibration and the confidence metric, ported from upstream.
- Email utilities for cleaning and structuring email inputs.
- error
- json_
compat json.dumpscompatibility.- lang
- Dependency-free script and language detection used to route between checkpoints.
- presets
- Ready-to-use question presets for common production decision workflows.
- prompt
- Prompt construction.
- pycompat
- Exact-parity helpers for the handful of places where Rust’s defaults differ from CPython’s. These are small, but every one of them is load-bearing for matching the upstream output byte for byte.
- question
- Typed question definitions, validated and rendered exactly as upstream does.
- tokenizer
- Checkpoint tokenizer.