Skip to main content

Module session

Module session 

Source
Expand description

Interactive Akinator-style classification session.

Instead of requiring all product information upfront, ClassificationSession asks targeted questions one at a time to progressively narrow down the HS code.

§Example

use hs_predict::session::{ClassificationSession, Answer, SessionResult};
use hs_predict::types::Language;

let mut session = ClassificationSession::new(); // English prompts

let q1 = session.start();
println!("{}", q1.prompt());

match session.answer(Answer::Text("1310-73-2".to_string())).unwrap() {
    SessionResult::NeedMoreInfo { next_question } => {
        println!("Next: {}", next_question.prompt());
    }
    SessionResult::Ready => {
        println!("Ready to classify!");
    }
    SessionResult::RequiresLlm => {
        println!("LLM needed");
    }
}

Re-exports§

pub use question::Answer;
pub use question::QAPair;
pub use question::Question;
pub use question::QuestionStep;
pub use question::SessionResult;
pub use state::ClassificationState;
pub use state::PartialComponent;

Modules§

flow
Question decision tree.
messages
Localised prompt strings for session questions.
question
state

Structs§

ClassificationSession
Interactive HS code classification session.