@@ -37,6 +37,10 @@ pub static PARALLEL_LORA_ENGINE: OnceLock<
3737pub static LORA_TOKEN_CLASSIFIER : OnceLock <
3838 Arc < crate :: classifiers:: lora:: token_lora:: LoRATokenClassifier > ,
3939> = OnceLock :: new ( ) ;
40+ // LoRA intent classifier for sequence classification
41+ pub static LORA_INTENT_CLASSIFIER : OnceLock <
42+ Arc < crate :: classifiers:: lora:: intent_lora:: IntentLoRAClassifier > ,
43+ > = OnceLock :: new ( ) ;
4044
4145/// Model type detection for intelligent routing
4246#[ derive( Debug , Clone , PartialEq ) ]
@@ -604,28 +608,53 @@ pub extern "C" fn init_candle_bert_classifier(
604608 num_classes : i32 ,
605609 use_cpu : bool ,
606610) -> bool {
607- // Migrated from lib.rs:1555-1578
608611 let model_path = unsafe {
609612 match CStr :: from_ptr ( model_path) . to_str ( ) {
610613 Ok ( s) => s,
611614 Err ( _) => return false ,
612615 }
613616 } ;
614617
615- // Initialize TraditionalBertClassifier
616- match crate :: model_architectures:: traditional:: bert:: TraditionalBertClassifier :: new (
617- model_path,
618- num_classes as usize ,
619- use_cpu,
620- ) {
621- Ok ( _classifier) => {
622- // Store in global static (would need to add this to the lazy_static block)
618+ // Intelligent model type detection (same as token classifier)
619+ let model_type = detect_model_type ( model_path) ;
623620
624- true
621+ match model_type {
622+ ModelType :: LoRA => {
623+ // Check if already initialized
624+ if LORA_INTENT_CLASSIFIER . get ( ) . is_some ( ) {
625+ return true ; // Already initialized, return success
626+ }
627+
628+ // Route to LoRA intent classifier initialization
629+ match crate :: classifiers:: lora:: intent_lora:: IntentLoRAClassifier :: new (
630+ model_path, use_cpu,
631+ ) {
632+ Ok ( classifier) => LORA_INTENT_CLASSIFIER . set ( Arc :: new ( classifier) ) . is_ok ( ) ,
633+ Err ( e) => {
634+ eprintln ! (
635+ " ERROR: Failed to initialize LoRA intent classifier: {}" ,
636+ e
637+ ) ;
638+ false
639+ }
640+ }
625641 }
626- Err ( e) => {
627- eprintln ! ( "Failed to initialize Candle BERT classifier: {}" , e) ;
628- false
642+ ModelType :: Traditional => {
643+ // Initialize TraditionalBertClassifier
644+ match crate :: model_architectures:: traditional:: bert:: TraditionalBertClassifier :: new (
645+ model_path,
646+ num_classes as usize ,
647+ use_cpu,
648+ ) {
649+ Ok ( _classifier) => {
650+ // Store in global static (would need to add this to the lazy_static block)
651+ true
652+ }
653+ Err ( e) => {
654+ eprintln ! ( "Failed to initialize Candle BERT classifier: {}" , e) ;
655+ false
656+ }
657+ }
629658 }
630659 }
631660}
0 commit comments