mirror of
https://github.com/Anil-matcha/Open-Generative-AI.git
synced 2026-05-07 01:17:18 +00:00
- Scaffold full IPC bridge: preload.js exposes localAI API to renderer - electron/lib/localInference.js: binary download (Metal-enabled macOS build), model management, auxiliary file downloads (Qwen3-4B LLM + FLUX VAE for Z-Image), and generation via sd-cli with DYLD_LIBRARY_PATH + xattr quarantine stripping - electron/lib/modelCatalog.js: Z-Image Turbo/Base (featured) + SD 1.5/SDXL models - Z-Image requires 3 components loaded via --diffusion-model + --llm + --vae flags - ImageStudio: Local/API toggle (Electron-only), local model selector, progress bar - SettingsModal: tabbed UI with Local Models tab (hidden on web/hosted version) - LocalModelManager: engine status bar, per-model download cards, auxiliary component download UI (text encoder + VAE) for Z-Image models - localInferenceClient.js: safe wrapper with isLocalAIAvailable() guard - All local features gated behind isLocalAIAvailable() — web version unaffected Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
32 lines
1.4 KiB
JavaScript
32 lines
1.4 KiB
JavaScript
const { contextBridge, ipcRenderer } = require('electron');
|
|
|
|
contextBridge.exposeInMainWorld('localAI', {
|
|
isElectron: true,
|
|
|
|
// Binary management
|
|
getBinaryStatus: () => ipcRenderer.invoke('local-ai:binary-status'),
|
|
downloadBinary: () => ipcRenderer.invoke('local-ai:download-binary'),
|
|
|
|
// Model management
|
|
listModels: () => ipcRenderer.invoke('local-ai:list-models'),
|
|
downloadModel: (modelId) => ipcRenderer.invoke('local-ai:download-model', modelId),
|
|
downloadAuxiliary: (auxKey) => ipcRenderer.invoke('local-ai:download-auxiliary', auxKey),
|
|
deleteModel: (modelId) => ipcRenderer.invoke('local-ai:delete-model', modelId),
|
|
cancelDownload: (modelId) => ipcRenderer.invoke('local-ai:cancel-download', modelId),
|
|
|
|
// Generation
|
|
generate: (params) => ipcRenderer.invoke('local-ai:generate', params),
|
|
cancelGeneration: () => ipcRenderer.invoke('local-ai:cancel-generation'),
|
|
|
|
// Progress events — returns an unsubscribe function
|
|
onProgress: (callback) => {
|
|
const listener = (_, data) => callback(data);
|
|
ipcRenderer.on('local-ai:progress', listener);
|
|
return () => ipcRenderer.removeListener('local-ai:progress', listener);
|
|
},
|
|
onDownloadProgress: (callback) => {
|
|
const listener = (_, data) => callback(data);
|
|
ipcRenderer.on('local-ai:download-progress', listener);
|
|
return () => ipcRenderer.removeListener('local-ai:download-progress', listener);
|
|
}
|
|
});
|