use candle_core::{DType, Device};
use mlmf::{
loader::load_safetensors,
smart_mapping::{ChatBasedOracle, MappingContext},
LoadOptions,
};
use std::collections::HashMap;
fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("π§ Testing Smart Mapping Integration");
println!("===================================\n");
let device = Device::cuda_if_available(0).unwrap_or(Device::Cpu);
let dtype = DType::F16;
let mock_oracle = ChatBasedOracle::new(
"Mock ML Oracle",
|prompt: &str| -> mlmf::Result<String> {
println!("π€ Oracle received prompt (excerpt):");
println!("{}", &prompt[..std::cmp::min(200, prompt.len())]);
if prompt.len() > 200 {
println!("...");
}
Ok("embed_tokens.weight -> embeddings.word_embeddings.weight\nqkv.weight -> attention.query_key_value.weight".to_string())
},
);
let options = LoadOptions::new(device, dtype)
.with_progress()
.with_smart_mapping(Box::new(mock_oracle));
println!("π Testing with mock model directory (will fail gracefully)...");
let test_path = "./nonexistent_model";
match load_safetensors(test_path, options) {
Ok(loaded) => {
println!("β
Model loaded successfully!");
println!(
"πΊοΈ Smart mapper created with {} mappings",
loaded.name_mapper.all_mappings().len()
);
}
Err(e) => {
println!("β οΈ Expected error (test directory doesn't exist): {}", e);
println!("β
Smart mapping integration is working - the oracle would be called for real models");
}
}
println!("\nπ‘ To test with real models:");
println!(" cargo run --example smart_mapping_test --features gguf -- /path/to/real/model");
Ok(())
}