This commit is contained in:
Timothy Jaeryang Baek
2026-05-09 01:13:16 +09:00
parent a32d26e61d
commit 4fe2de7864
8 changed files with 222 additions and 36 deletions
+33
View File
@@ -159,6 +159,39 @@ export const getModels = async (
return models;
};
export const unloadModel = async (token: string, model: string) => {
let error = null;
const res = await fetch(`${WEBUI_BASE_URL}/api/models/unload`, {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
...(token && { authorization: `Bearer ${token}` })
},
body: JSON.stringify({ model })
})
.then(async (res) => {
if (!res.ok) throw await res.json();
return res.json();
})
.catch((err) => {
console.error(err);
if ('detail' in err) {
error = err.detail;
} else {
error = err;
}
return null;
});
if (error) {
throw error;
}
return res;
};
type ChatCompletedForm = {
model: string;
messages: Record<string, unknown>[];