| |
| |
| |
| |
| |
| |
| |
|
|
| use serde::Deserialize; |
| use std::fs::File; |
| use std::io::{BufRead, BufReader}; |
|
|
| #[derive(Debug, Deserialize)] |
| #[allow(dead_code)] |
| struct BrainEntry { |
| label: i32, |
| source: String, |
| text: String, |
| tool: String, |
| weight: f32, |
| } |
|
|
| fn main() { |
| let collection = "flint_episodic"; |
| let input_path = "/data/data/com.termux/files/home/SPFsmartGATE/LIVE/TMP/stoneshell-brain/training_data/raw/brain_index_pruned.jsonl"; |
|
|
| println!("[*] brain_index_training — Index training data to brain"); |
| println!("[*] Input: {}", input_path); |
| println!("[*] Collection: {}", collection); |
| println!(""); |
|
|
| |
| spf_smart_gate::brain_local::init_brain(); |
| println!("[+] Brain initialized"); |
|
|
| |
| let file = File::open(&input_path).expect("Failed to open input file"); |
| let reader = BufReader::new(file); |
|
|
| let mut count = 0; |
| let mut success = 0; |
| let mut error_count = 0; |
|
|
| for line in reader.lines() { |
| let line = line.expect("Failed to read line"); |
| if line.trim().is_empty() { continue; } |
|
|
| match serde_json::from_str::<BrainEntry>(&line) { |
| Ok(entry) => { |
| |
| let title = format!("[{:+}] {}", entry.label, entry.tool); |
|
|
| |
| let result = spf_smart_gate::brain_local::brain_store(&entry.text, &title, collection); |
|
|
| count += 1; |
| if result.starts_with("Error") || result.starts_with("Failed") { |
| error_count += 1; |
| if error_count <= 5 { |
| println!(" [!] Entry {} error: {}", count, result); |
| } |
| } else { |
| success += 1; |
| } |
|
|
| if count % 500 == 0 { |
| println!(" Processed: {}/{} (success: {}, errors: {})", |
| count, count, success, error_count); |
| } |
| } |
| Err(e) => { |
| error_count += 1; |
| if error_count <= 5 { |
| println!(" [!] Parse error: {}", e); |
| } |
| } |
| } |
| } |
|
|
| println!("\n[=] INDEXING COMPLETE"); |
| println!(" Total entries: {}", count); |
| println!(" Success: {}", success); |
| println!(" Errors: {}", error_count); |
| println!("\n Training data indexed to 'flint_episodic' collection"); |
| println!(" FLINT can now recall these patterns on similar queries"); |
| } |