mirror of
https://github.com/mudler/LocalAI.git
synced 2026-07-31 10:28:43 -04:00
Splits option entries on the first colon so path values survive, and routes load./session. prefixes to the upstream load and session option maps. Assisted-by: Claude:claude-opus-5 [Claude Code] Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
43 lines
1.4 KiB
C++
43 lines
1.4 KiB
C++
#pragma once
|
|
|
|
// Parses the model YAML's `options:` list (ModelOptions.Options in
|
|
// backend.proto) into a struct. Standard library only: this unit is compiled
|
|
// and tested by backend/cpp/run-unit-tests.sh without an audio.cpp checkout.
|
|
|
|
#include <map>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace audiocpp_backend {
|
|
|
|
struct ModelOptions {
|
|
// audio.cpp model family. Empty means "derive from the GGUF's embedded
|
|
// audiocpp.model_spec.family key"; a non-GGUF path with an empty family is
|
|
// rejected at load time, not here.
|
|
std::string family;
|
|
// Pins the audio.cpp task, overriding RPC-based routing. Empty means route.
|
|
std::string task;
|
|
// ggml backend: cpu, cuda, vulkan, metal, best.
|
|
std::string backend = "cpu";
|
|
int device = 0;
|
|
// 0 means "let the runtime decide".
|
|
int threads = 0;
|
|
std::string model_spec_override;
|
|
// 0 disables the run guard's fail-fast, restoring an unbounded wait.
|
|
int busy_timeout_ms = 0;
|
|
// `load.<key>:<value>` entries, prefix stripped.
|
|
std::map<std::string, std::string> load_options;
|
|
// `session.<key>:<value>` entries, prefix stripped.
|
|
std::map<std::string, std::string> session_options;
|
|
};
|
|
|
|
struct ParsedOptions {
|
|
ModelOptions options;
|
|
// Non-empty means the caller must fail the load with INVALID_ARGUMENT.
|
|
std::string error;
|
|
};
|
|
|
|
ParsedOptions parse_model_options(const std::vector<std::string> &entries);
|
|
|
|
} // namespace audiocpp_backend
|