feat: model pull/delete added

This commit is contained in:
Timothy J. Baek 2023-10-22 16:40:17 -07:00
parent e1361e68ec
commit 08b43fc987
4 changed files with 249 additions and 25 deletions

View file

@ -32,24 +32,7 @@
onMount(async () => {
console.log(API_BASE_URL);
const res = await fetch(`${API_BASE_URL}/tags`, {
method: 'GET',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json'
}
})
.then(async (res) => {
if (!res.ok) throw await res.json();
return res.json();
})
.catch((error) => {
console.log(error);
return { models: [] };
});
const data = res;
models = data.models;
await getModelTags();
let settings = localStorage.getItem('settings');
if (settings) {
@ -233,6 +216,27 @@
// Ollama functions
//////////////////////////
const getModelTags = async () => {
const res = await fetch(`${API_BASE_URL}/tags`, {
method: 'GET',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json'
}
})
.then(async (res) => {
if (!res.ok) throw await res.json();
return res.json();
})
.catch((error) => {
console.log(error);
return { models: [] };
});
const data = res;
models = data.models;
};
const submitPrompt = async (user_prompt) => {
console.log('submitPrompt');
@ -493,7 +497,7 @@
{openSettings}
/>
<SettingsModal bind:show={showSettings} {saveSettings} />
<SettingsModal bind:show={showSettings} {saveSettings} {getModelTags} />
<div class="min-h-screen w-full flex justify-center">
<div class=" py-2.5 flex flex-col justify-between w-full">