Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aien-sovereign-core-mv/blob/main/crates/spark-harvester/src/export.rs # 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 Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aien-sovereign-core-mv / crates / spark-harvester / src / export.rs` 87 lines ยท 2943 bytes Raw Blame History 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2026 Drake Stapleton (AIEN / aien-dev) 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 16 use crate::extractor::ExtractedPair; 17 use serde_json::json; 18 use std::fs::OpenOptions; 19 use std::io::{self, Write}; 20 use std::path::Path; 21 22 pub struct DatasetExporter; 23 24 impl DatasetExporter { 25 #[allow(dead_code)] 26 pub(crate) fn append_to_jsonl(path: &Path, pairs: &[ExtractedPair]) -> io::Result { 27 let mut file = OpenOptions::new().create(true).append(true).open(path)?; 28 29 let mut written = 0; 30 for pair in pairs { 31 let record = json!({ 32 "instruction": pair.prompt, 33 "reasoning": pair.reasoning, 34 "response": pair.completion, 35 "metadata": { 36 "source_provider": pair.provider, 37 "source_model": pair.model, 38 "tokens": pair.token_count, 39 "quality": pair.quality_score, 40 "license": "PolyForm-Noncommercial-1.0.0 Sovereign Defense Covenant" 41 } 42 }); 43 writeln!(file, "{}", record)?; 44 written += 1; 45 } 46 Ok(written) 47 } 48 49 pub fn to_sharegpt_format(pair: &ExtractedPair) -> serde_json::Value { 50 let human_text = pair.prompt.clone(); 51 let gpt_text = if let Some(r) = &pair.reasoning { 52 format!("\n{}\n\n\n{}", r, pair.completion) 53 } else { 54 pair.completion.clone() 55 }; 56 57 json!({ 58 "conversations": [ 59 {"from": "human", "value": human_text}, 60 {"from": "gpt", "value": gpt_text} 61 ], 62 "source": pair.provider 63 }) 64 } 65 } 66 67 #[cfg(test)] 68 mod tests { 69 use super::*; 70 71 #[test] 72 fn test_sharegpt_format() { 73 let pair = ExtractedPair { 74 prompt: "Say hi".to_string(), 75 reasoning: Some("Greeting thought".to_string()), 76 completion: "Hello".to_string(), 77 provider: "gemini".to_string(), 78 model: "gemini-2.5-pro".to_string(), 79 token_count: 20, 80 quality_score: 0.9, 81 }; 82 let val = DatasetExporter::to_sharegpt_format(&pair); 83 let convos = val["conversations"].as_array().unwrap(); 84 assert_eq!(convos.len(), 2); 85 assert!(convos[1]["value"].as_str().unwrap().contains("")); 86 } 87 }