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

Function run_model_step_impl

app/workflow/workflow.cpp:579–658  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

577 throw std::runtime_error("workflow step cannot specify both device and device_name");
578 }
579 if (backend.has_value()) {
580 fallback.type = minitts::cli::parse_backend(*backend);
581 fallback.impl.clear();
582 }
583 if (device_name.has_value()) {
584 const std::optional<engine::core::BackendType> filter =
585 backend.has_value() ? std::optional<engine::core::BackendType>(fallback.type) : std::nullopt;
586 const auto resolved = engine::core::resolve_backend_device(*device_name, filter);
587 if (resolved.type != fallback.type) {
588 fallback.impl.clear();
589 }
590 fallback.type = resolved.type;
591 fallback.device = resolved.device;
592 } else if (device.has_value()) {
593 fallback.device = static_cast<int>(*device);
594 }
595 if (impl.has_value()) {
596 fallback.impl = *impl;
597 }
598 if (const auto threads = workflow_optional_number(step, "threads")) {
599 fallback.threads = static_cast<int>(*threads);
600 }
601 if (fallback.threads <= 0) {
602 throw std::runtime_error("workflow step threads must be positive");
603 }
604 return fallback;
605}
606
607void run_model_step_impl(
608 const engine::runtime::ModelRegistry & registry,
609 const engine::io::json::Value & step,
610 const WorkflowRunOptions & options,
611 WorkflowContext & context) {
612 const std::string id = workflow_string(step, "id");
613 const auto request_value = step.find("request");
614 if (request_value == nullptr || request_value->is_null()) {
615 throw std::runtime_error("model step requires request object: " + id);
616 }
617
618 engine::runtime::ModelLoadRequest load_request;
619 load_request.model_path = resolve_workflow_path(workflow_string(step, "model"), context);
620 load_request.model_spec_override = options.model_spec_override;
621 if (const auto family = workflow_optional_string(step, "family")) {
622 load_request.family_hint = *family;
623 }
624 if (const auto config = workflow_optional_string(step, "config")) {
625 load_request.config_id = *config;
626 }
627 if (const auto weight = workflow_optional_string(step, "weight")) {
628 load_request.weight_id = *weight;
629 }
630 load_request.options = merged_options(options.load_options, step.find("load_options"), context);
631
632 engine::runtime::SessionOptions session_options;
633 session_options.backend = parse_step_backend(step, options.backend);
634 session_options.options = merged_options(options.session_options, step.find("session_options"), context);
635
636 const engine::runtime::TaskSpec task_spec{

Callers 1

run_workflow_step_onceFunction · 0.85

Calls 15

workflow_stringFunction · 0.85
resolve_workflow_pathFunction · 0.85
workflow_optional_stringFunction · 0.85
merged_optionsFunction · 0.85
parse_step_backendFunction · 0.85
parse_voice_task_kindFunction · 0.85
parse_run_modeFunction · 0.85
workflow_string_orFunction · 0.85
expanded_jsonFunction · 0.85
build_request_from_jsonFunction · 0.85
emit_task_resultFunction · 0.85

Tested by

no test coverage detected