Files
LocalAI/addons/quantization/ui/src/api.js
T
Ettore Di Giacinto 1604a67c1f feat(addons): add the add-on runtime, navigation and first-party add-ons
Add the add-on runtime to LocalAI: manifests, the host operation broker,
admin gating by account role, the add-on UI bundle builder and the SDK
for add-on pages. Move the navigation to Chat, Models, Add-ons and
Settings, with pinned add-ons in the sidebar and an Add-ons drawer.

Ship the first-party add-ons (voice, face, fine-tuning, quantization) as
packages for linux/amd64, linux/arm64 and darwin/arm64. Intel macOS
(darwin/amd64) is enabled in the platform files.

Squashed from the review branch. The tree is unchanged; the pre-squash
history is kept on a local backup branch.

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
2026-10-20 20:54:43 +00:00

31 lines
1.5 KiB
JavaScript

// The core routes the quantization add-on uses, reached with the signed-in
// user's own session (sdk.core.fetch). Paths and bodies are the ones of
// quantizationApi and resourcesApi in core/http/react-ui/src/utils/api.js; only
// the transport changed.
export function createApi(ctx) {
const { json } = ctx
const enc = encodeURIComponent
const post = (path, data) => json(path, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) })
return {
quantize: {
listBackends: () => json('/api/quantization/backends'),
startJob: (data) => post('/api/quantization/jobs', data),
listJobs: () => json('/api/quantization/jobs'),
getJob: (id) => json(`/api/quantization/jobs/${enc(id)}`),
stopJob: (id) => json(`/api/quantization/jobs/${enc(id)}/stop`, { method: 'POST' }),
deleteJob: (id) => json(`/api/quantization/jobs/${enc(id)}`, { method: 'DELETE' }),
importModel: (id, data) => post(`/api/quantization/jobs/${enc(id)}/import`, data),
// The response is a stream of events; the caller reads it with readSse
// and aborts the signal to close it.
progress: (id, signal) => ctx.core.fetch(`/api/quantization/jobs/${enc(id)}/progress`, { signal }),
},
// The one request the page makes for the machine facts of the checks.
resources: {
get: () => json('/api/resources'),
},
// The link the browser follows to download the result of a job.
downloadHref: (id) => `${ctx.basePath}/api/quantization/jobs/${enc(id)}/download`,
}
}