hs_predict/lib.rs
1//! # hs-predict
2//!
3//! HS (Harmonized System) code prediction for chemical products.
4//!
5//! Uses an **Akinator-style interactive session** to collect just enough
6//! information to classify the product, then applies a hybrid rule-based
7//! and LLM prediction engine.
8//!
9//! ## Disclaimer
10//! Predictions are advisory only and must not be used as the sole basis for
11//! customs declarations. Always verify with a qualified trade-compliance expert.
12//!
13//! ## Quick start — interactive (Akinator-style)
14//! ```rust,no_run
15//! use hs_predict::session::{ClassificationSession, Answer, SessionResult};
16//! use hs_predict::pipeline::HsPipeline;
17//!
18//! let mut session = ClassificationSession::new();
19//! let pipeline = HsPipeline::new();
20//!
21//! // Q1: provide an identifier
22//! let q = session.start();
23//! println!("{}", q.prompt());
24//!
25//! // User answers with a CAS number; answer remaining questions the same way.
26//! // When SessionResult::Ready is returned, call to_product_description().
27//! let result = session.answer(Answer::Text("1310-73-2".to_string())).unwrap();
28//! ```
29//!
30//! ## Quick start — direct (known CAS + physical form)
31//! ```rust
32//! use hs_predict::pipeline::HsPipeline;
33//! use hs_predict::types::{ProductDescription, SubstanceIdentifier, PhysicalForm};
34//!
35//! let pipeline = HsPipeline::new();
36//!
37//! let product = ProductDescription {
38//! identifier: SubstanceIdentifier::from_cas("1310-73-2"),
39//! physical_form: Some(PhysicalForm::Solid),
40//! purity_pct: None,
41//! purity_type: None,
42//! mixture_components: None,
43//! intended_use: None,
44//! additional_context: None,
45//! };
46//!
47//! let p = pipeline.classify(&product).unwrap();
48//! assert_eq!(&p.hs_code, "281511");
49//! assert_eq!(p.display(), "28.15.11");
50//! ```
51
52pub mod error;
53pub mod pipeline;
54pub mod rules;
55pub mod session;
56pub mod smiles;
57pub mod types;
58
59// Feature-gated modules
60#[cfg(feature = "pubchem")]
61pub mod pubchem;
62
63#[cfg(feature = "pubchem")]
64pub use pubchem::{PubChemClient, PubChemCompound};
65
66#[cfg(feature = "llm")]
67pub mod llm;
68
69// Top-level convenience re-exports
70pub use error::{HsPredictError, Result};
71pub use pipeline::HsPipeline;
72pub use session::{ClassificationSession, QuestionStep};
73pub use types::{HsPrediction, Language, ProductDescription, SubstanceIdentifier};