feat: ollama unload model

This commit is contained in:
Timothy Jaeryang Baek
2025-05-23 19:45:29 +04:00
parent 19b69fcb66
commit 1cf21d3fa2
3 changed files with 127 additions and 6 deletions
+25
View File
@@ -355,6 +355,31 @@ export const generateChatCompletion = async (token: string = '', body: object) =
return [res, controller];
};
export const unloadModel = async (token: string, tagName: string) => {
let error = null;
const res = await fetch(`${OLLAMA_API_BASE_URL}/api/unload`, {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`
},
body: JSON.stringify({
name: tagName
})
}).catch((err) => {
error = err;
return null;
});
if (error) {
throw error;
}
return res;
};
export const createModel = async (token: string, payload: object, urlIdx: string | null = null) => {
let error = null;