mirror of
https://github.com/open-webui/open-webui
synced 2024-11-16 21:42:58 +00:00
fix: check existing model before model creation
This commit is contained in:
parent
59fb1b933d
commit
fbb64406d8
@ -97,8 +97,6 @@
|
|||||||
|
|
||||||
console.log();
|
console.log();
|
||||||
await settings.set(JSON.parse(localStorage.getItem('settings') ?? '{}'));
|
await settings.set(JSON.parse(localStorage.getItem('settings') ?? '{}'));
|
||||||
// await models.set(await getModels());
|
|
||||||
// JSON.parse(localStorage.getItem('modelfiles') ?? '[]')
|
|
||||||
await modelfiles.set(await getModelfiles(localStorage.token));
|
await modelfiles.set(await getModelfiles(localStorage.token));
|
||||||
console.log($modelfiles);
|
console.log($modelfiles);
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
import { splitStream } from '$lib/utils';
|
import { splitStream } from '$lib/utils';
|
||||||
import { onMount, tick } from 'svelte';
|
import { onMount, tick } from 'svelte';
|
||||||
import { createModel } from '$lib/apis/ollama';
|
import { createModel } from '$lib/apis/ollama';
|
||||||
import { createNewModelfile, getModelfiles } from '$lib/apis/modelfiles';
|
import { createNewModelfile, getModelfileByTagName, getModelfiles } from '$lib/apis/modelfiles';
|
||||||
|
|
||||||
let loading = false;
|
let loading = false;
|
||||||
|
|
||||||
@ -117,7 +117,10 @@ SYSTEM """${system}"""`.replace(/^\s*\n/gm, '');
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($models.includes(tagName)) {
|
if (
|
||||||
|
$models.map((model) => model.name).includes(tagName) ||
|
||||||
|
(await getModelfileByTagName(localStorage.token, tagName).catch(() => false))
|
||||||
|
) {
|
||||||
toast.error(
|
toast.error(
|
||||||
`Uh-oh! It looks like you already have a model named '${tagName}'. Please choose a different name to complete your modelfile.`
|
`Uh-oh! It looks like you already have a model named '${tagName}'. Please choose a different name to complete your modelfile.`
|
||||||
);
|
);
|
||||||
|
@ -85,17 +85,6 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
const updateModelfile = async (modelfile) => {
|
const updateModelfile = async (modelfile) => {
|
||||||
// await modelfiles.set(
|
|
||||||
// $modelfiles.map((e) => {
|
|
||||||
// if (e.tagName === modelfile.tagName) {
|
|
||||||
// return modelfile;
|
|
||||||
// } else {
|
|
||||||
// return e;
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// );
|
|
||||||
// localStorage.setItem('modelfiles', JSON.stringify($modelfiles));
|
|
||||||
|
|
||||||
await updateModelfileByTagName(localStorage.token, modelfile.tagName, modelfile);
|
await updateModelfileByTagName(localStorage.token, modelfile.tagName, modelfile);
|
||||||
await modelfiles.set(await getModelfiles(localStorage.token));
|
await modelfiles.set(await getModelfiles(localStorage.token));
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user