Skip to main content

Module mock

Module mock 

Source
Expand description

Mock LLM classifier for unit testing.

Enabled by the mock Cargo feature (which implies llm).

MockLlmClassifier is a deterministic stub that derives an HS code directly from the SMILES pre-analysis embedded in the prompt, or falls back to a configurable default. It never makes a network call.

§Example

use hs_predict::llm::{MockLlmClassifier, LlmClassifier, LlmPrompt};
use hs_predict::llm::PromptBuilder;
use hs_predict::types::{ProductDescription, SubstanceIdentifier, PhysicalForm};

let product = ProductDescription {
    identifier: SubstanceIdentifier {
        cas: Some("64-19-7".to_string()),
        smiles: Some("CC(O)=O".to_string()),
        ..Default::default()
    },
    physical_form: Some(PhysicalForm::Liquid),
    purity_pct: Some(99.5),
    purity_type: None,
    mixture_components: None,
    intended_use: None,
    additional_context: None,
};

let prompt = PromptBuilder::new().build(&product);
let mock = MockLlmClassifier::new();
let response = mock.classify(&prompt).await.unwrap();
assert_eq!(response.hs_code.len(), 6);

Structs§

MockLlmClassifier
Deterministic mock LLM classifier for unit tests.