aien-sovereign-core-mv
AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination.
Brought by drakestapleton
aien-sovereign-core-mv / om / ribbon / q38-scoped-input-tokens.rs.txt
| 1 | // External input identity instrument; no model implementation. |
| 2 | use aien_inference_abi::tokenizer::{ChatOptions, ChatTokenizer}; |
| 3 | use serde_json::{json,Value}; |
| 4 | use std::path::Path; |
| 5 | fn main()->Result<(),Box<dyn std::error::Error>>{ |
| 6 | let a:Vec<String>=std::env::args().collect(); assert_eq!(a.len(),4); |
| 7 | let j:Value=serde_json::from_slice(&std::fs::read(&a[2])?)?; |
| 8 | let turns:Vec<(&str,&str)>=j["messages"].as_array().ok_or("messages")?.iter().map(|m|(m["role"].as_str().unwrap(),m["content"].as_str().unwrap())).collect(); |
| 9 | let t=ChatTokenizer::from_model_dir(Path::new(&a[1]),None)?; |
| 10 | let text=t.try_format_chat_with(&turns,&ChatOptions{enable_thinking:Some(false),..Default::default()})?; |
| 11 | let ids=t.encode(&text)?; |
| 12 | std::fs::write(&a[3],serde_json::to_vec_pretty(&json!({"input_ids":ids,"count":ids.len(),"enable_thinking":false}))?)?; |
| 13 | Ok(()) |
| 14 | } |