MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / read_batch_text_payload

Function read_batch_text_payload

app/workflow/workflow.cpp:202–223  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

run_batch_inputs_stepFunction · 0.85

Calls 7

parse_fileFunction · 0.85
is_stringMethod · 0.80
is_objectMethod · 0.80
lowercase_extensionFunction · 0.70
read_text_fileFunction · 0.70
findMethod · 0.45

Tested by

no test coverage detected