| 200 | in_space = false; |
| 201 | } |
| 202 | normalized.push_back(static_cast<char>(ch)); |
| 203 | } |
| 204 | return normalized; |
| 205 | } |
| 206 | |
| 207 | std::string read_batch_text_payload(const std::filesystem::path & path) { |
| 208 | const auto ext = lowercase_extension(path); |
| 209 | if (ext == ".txt" || ext == ".md") { |
| 210 | return normalize_text_as_paragraph(read_text_file(path)); |
| 211 | } |
| 212 | if (ext == ".json") { |
| 213 | const auto root = engine::io::json::parse_file(path); |
| 214 | if (root.is_string()) { |
| 215 | return normalize_text_as_paragraph(root.as_string()); |
| 216 | } |
| 217 | if (root.is_object()) { |
| 218 | if (const auto * input = root.find("input"); input != nullptr && input->is_string()) { |
| 219 | return normalize_text_as_paragraph(input->as_string()); |
| 220 | } |
| 221 | if (const auto * text = root.find("text"); text != nullptr && text->is_string()) { |
| 222 | return normalize_text_as_paragraph(text->as_string()); |
| 223 | } |
| 224 | } |
| 225 | throw std::runtime_error("workflow batch JSON text file requires a string root, input, or text: " + path.string()); |
| 226 | } |
no test coverage detected