Manages AI model downloads, caching, and registry. More...
| Import Statement: | import Clayground.Ai |
AiModelManager provides a central point for managing AI models used by SpeechToText, TextToSpeech, and TextInference components.
import Clayground.Ai AiModelManager { id: models Component.onCompleted: { console.log("Available LLM models:", availableModels("llm")) console.log("WebGPU available:", hasWebGPU) } onDownloadProgress: (modelId, progress) => { console.log(modelId, "download:", Math.round(progress * 100) + "%") } }
See also TextInference.
activeDownloads : list |
List of currently active downloads.
Each item contains: modelId, progress, bytesDownloaded, totalBytes
hasWebGPU : bool |
Whether WebGPU is available (browser only).
platform : string |
Current platform: "desktop", "wasm", "ios", or "android".
registryReady : bool |
Whether the model registry has been loaded.
registryUrl : url |
Custom model registry URL.
When set, the manager will fetch the model registry from this URL. Leave empty to use the embedded registry.
downloadCancelled(string modelId) |
Emitted when a download is cancelled.
Note: The corresponding handler is onDownloadCancelled.
downloadComplete(string modelId) |
Emitted when a download finishes successfully.
Note: The corresponding handler is onDownloadComplete.
downloadError(string modelId, string message) |
Emitted when a download fails.
Note: The corresponding handler is onDownloadError.
downloadProgress(string modelId, real progress, int bytesDownloaded, int totalBytes) |
Emitted during download with progress (0.0 to 1.0).
Note: The corresponding handler is onDownloadProgress.
downloadStarted(string modelId, int totalBytes) |
Emitted when a download begins.
Note: The corresponding handler is onDownloadStarted.
registryUpdated() |
Emitted when the model registry is updated.
Note: The corresponding handler is onRegistryUpdated.
list availableModels(string type) |
Returns list of model IDs for the given type.
type can be "llm", "stt", "tts", or empty for all models.
list cachedModels() |
Returns list of locally cached model IDs.
void cancelDownload(string modelId) |
Cancel an in-progress download.
bool checkMemory(string modelId) |
Returns true if there's likely enough memory to load the model.
void download(string modelId) |
Start downloading a model.
bool isAvailable(string modelId) |
Returns true if the model is cached locally.
object modelInfo(string modelId) |
Returns information about a model.
Returns an object with: name, type, description, size, platforms, quantization, memoryRequired
string modelPath(string modelId) |
Returns the local file path for a cached model.
void refreshRegistry() |
Refresh the model registry from registryUrl or embedded source.
void remove(string modelId) |
Remove a model from the local cache.