Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
model_registry.hpp
Go to the documentation of this file.
1#pragma once
2
3// Generic model registry primitive (promoted from tools/audio so plugins/apps —
4// not just the CLI — can use it). A `ModelEntry` describes a downloadable ML model
5// (HuggingFace or any URL); `resolve_checkpoint_url` turns an `hf://` ref into a
6// direct HTTPS URL with path hardening. The available-models list (the catalog) is
7// supplied by the consumer (e.g. tools/audio's audio catalog, or the Magenta demo's
8// mrt2 catalog) — this module owns the type + resolution + lookup, not the data.
9
10#include <cstdint>
11#include <string>
12#include <string_view>
13#include <vector>
14
15namespace pulp::runtime {
16
17struct ModelAsset {
18 std::string role;
19 std::string checkpoint_ref;
20 std::string
22 std::uint64_t size_bytes = 0;
23};
24
25struct ModelEntry {
26 std::string model_id;
27 std::string display_name;
28 std::string description;
29 std::string backend;
30 std::string checkpoint_ref;
31 std::vector<std::string> task_tags;
32 std::uint64_t size_bytes = 0;
33
34 std::string download_url;
35 std::string sha256;
36 bool auto_downloadable = true;
37
38 // Multi-asset bundles (e.g. Magenta: weights + vocab + encoder). When empty the
39 // entry is single-file (checkpoint_ref). The downloader fetches all assets.
40 std::vector<ModelAsset> assets;
41
42 bool is_recommended = false;
43 std::string license;
44 std::string attribution;
45 std::string min_device;
46};
47
52std::string resolve_checkpoint_url(const std::string& checkpoint_ref);
53
55const ModelEntry* find_model(const std::vector<ModelEntry>& registry, std::string_view model_id);
56
57} // namespace pulp::runtime
Definition generated_event_source.hpp:33
std::string resolve_checkpoint_url(const std::string &checkpoint_ref)
Resolve a checkpoint_ref to a direct download URL.
const ModelEntry * find_model(const std::vector< ModelEntry > &registry, std::string_view model_id)
Find a model by id in a caller-supplied registry/catalog. Returns nullptr if absent.
Definition model_registry.hpp:17
std::string checkpoint_ref
"hf://user/repo/file" or "https://…"
Definition model_registry.hpp:19
std::uint64_t size_bytes
Definition model_registry.hpp:22
std::string role
e.g. "weights", "vocab", "encoder" (multi-file bundles)
Definition model_registry.hpp:18
std::string sha256
Expected hash of this asset (empty = install needs an unverified opt-in).
Definition model_registry.hpp:21
Definition model_registry.hpp:25
std::string sha256
Expected hash of the primary checkpoint.
Definition model_registry.hpp:35
std::string license
e.g. "CC-BY-4.0".
Definition model_registry.hpp:43
bool auto_downloadable
false ⇒ manual steps required.
Definition model_registry.hpp:36
std::string display_name
Definition model_registry.hpp:27
bool is_recommended
⭐ in the model manager.
Definition model_registry.hpp:42
std::string backend
e.g. "clap", "mlx".
Definition model_registry.hpp:29
std::string checkpoint_ref
Primary asset, e.g. "hf://user/repo/file.pt".
Definition model_registry.hpp:30
std::string description
Definition model_registry.hpp:28
std::string min_device
Optional hint, e.g. "Pro/Max".
Definition model_registry.hpp:45
std::string attribution
e.g. "Google DeepMind".
Definition model_registry.hpp:44
std::uint64_t size_bytes
Definition model_registry.hpp:32
std::vector< std::string > task_tags
Definition model_registry.hpp:31
std::string download_url
Direct HTTPS URL (resolved from checkpoint_ref).
Definition model_registry.hpp:34
std::string model_id
Stable id (e.g. "mrt2_base"), NOT the HF repo.
Definition model_registry.hpp:26
std::vector< ModelAsset > assets
Definition model_registry.hpp:40