use serde::{Deserialize, Serialize}; use std::io::BufRead; use crate::VoiceError; /// Content types for voice generation. #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "snake_case")] pub enum ContentType { Behavior, Dialogue, Tell, } /// A single prompt payload, used in batch JSONL mode. #[derive(Debug, Clone, Serialize, Deserialize)] pub struct PromptPayload { pub id: String, pub content_type: ContentType, pub prompt: String, #[serde(default)] pub base_text: Option, #[serde(default)] pub semantic_core: Option, } /// Parse a JSONL file into a list of prompt payloads. pub fn parse_jsonl(reader: impl BufRead) -> Result, VoiceError> { let mut payloads = Vec::new(); for (i, line) in reader.lines().enumerate() { let line = line.map_err(|e| VoiceError::InvalidInput(format!("line {}: {}", i + 1, e)))?; let trimmed = line.trim(); if trimmed.is_empty() { continue; } let payload: PromptPayload = serde_json::from_str(trimmed) .map_err(|e| VoiceError::InvalidInput(format!("line {}: {}", i + 1, e)))?; payloads.push(payload); } Ok(payloads) }