fix: delete model issue

This commit is contained in:
Timothy J. Baek 2024-01-04 13:12:00 -08:00
parent 30aff2db53
commit 754ea1625b

View file

@ -471,45 +471,12 @@
}; };
const deleteModelHandler = async () => { const deleteModelHandler = async () => {
const res = await deleteModel(localStorage.token, deleteModelTag); const res = await deleteModel(localStorage.token, deleteModelTag).catch((error) => {
toast.error(error);
});
if (res) { if (res) {
const reader = res.body toast.success(`Deleted ${deleteModelTag}`);
.pipeThrough(new TextDecoderStream())
.pipeThrough(splitStream('\n'))
.getReader();
while (true) {
const { value, done } = await reader.read();
if (done) break;
try {
let lines = value.split('\n');
for (const line of lines) {
if (line !== '' && line !== 'null') {
console.log(line);
let data = JSON.parse(line);
console.log(data);
if (data.error) {
throw data.error;
}
if (data.detail) {
throw data.detail;
}
if (data.status) {
}
} else {
toast.success(`Deleted ${deleteModelTag}`);
}
}
} catch (error) {
console.log(error);
toast.error(error);
}
}
} }
deleteModelTag = ''; deleteModelTag = '';
@ -1004,7 +971,7 @@
<div class="flex-1 mr-2"> <div class="flex-1 mr-2">
<input <input
class="w-full rounded py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none" class="w-full rounded py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none"
placeholder="Enter URL (e.g. http://localhost:8080/ollama/api)" placeholder="Enter URL (e.g. http://localhost:11434/api)"
bind:value={API_BASE_URL} bind:value={API_BASE_URL}
/> />
</div> </div>
@ -1030,11 +997,9 @@
</div> </div>
<div class="mt-2 text-xs text-gray-400 dark:text-gray-500"> <div class="mt-2 text-xs text-gray-400 dark:text-gray-500">
The field above should be set to <span Trouble accessing Ollama?
class=" text-gray-500 dark:text-gray-300 font-medium">'/ollama/api'</span
>;
<a <a
class=" text-gray-500 dark:text-gray-300 font-medium" class=" text-gray-300 font-medium"
href="https://github.com/ollama-webui/ollama-webui#troubleshooting" href="https://github.com/ollama-webui/ollama-webui#troubleshooting"
target="_blank" target="_blank"
> >