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 in_space = false;
201 }
202 normalized.push_back(static_cast<char>(ch));
203 }
204 return normalized;
205}
206
207std::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 }

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