pub struct ClassificationSession { /* private fields */ }Expand description
Interactive HS code classification session.
Maintains state across multiple question-answer rounds and builds up a
ProductDescription that can be passed to the classification pipeline.
Implementations§
Source§impl ClassificationSession
impl ClassificationSession
Sourcepub fn with_language(self, language: Language) -> Self
pub fn with_language(self, language: Language) -> Self
Set the language for question prompts (builder style).
Must be called before start().
Sourcepub fn start(&mut self) -> Question
pub fn start(&mut self) -> Question
Return the first question and mark it as the active question.
Must be called once before the first answer() call.
Sourcepub fn answer(&mut self, answer: Answer) -> Result<SessionResult>
pub fn answer(&mut self, answer: Answer) -> Result<SessionResult>
Submit an answer to the current active question.
Returns the next SessionResult:
SessionResult::NeedMoreInfo— more questions remainSessionResult::Ready— callto_product_description()SessionResult::RequiresLlm— insufficient info for rule engine alone
§Errors
HsPredictError::NoActiveQuestion— called beforestart().HsPredictError::AnswerTypeMismatch— answer type doesn’t match the question.HsPredictError::InvalidChoiceIndex— choice index out of range.HsPredictError::NumberOutOfRange— number outside[min, max].
Sourcepub fn to_product_description(&self) -> ProductDescription
pub fn to_product_description(&self) -> ProductDescription
Convert the accumulated session state into a ProductDescription.
Call after receiving SessionResult::Ready or SessionResult::RequiresLlm.
Sourcepub fn state(&self) -> &ClassificationState
pub fn state(&self) -> &ClassificationState
Current session state (read-only).
Sourcepub fn question_count(&self) -> usize
pub fn question_count(&self) -> usize
Number of questions answered so far.
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
Whether the session has collected enough information.
Sourcepub fn current_step(&self) -> Option<QuestionStep>
pub fn current_step(&self) -> Option<QuestionStep>
The logical step of the current active question, if any.
Trait Implementations§
Source§impl Clone for ClassificationSession
impl Clone for ClassificationSession
Source§fn clone(&self) -> ClassificationSession
fn clone(&self) -> ClassificationSession
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more