Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
6df1b197
Commit
6df1b197
authored
Dec 03, 2023
by
Timothy J. Baek
Browse files
feat: duplicate tag name prevention
parent
ab5e7abf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
3 deletions
+23
-3
src/routes/(app)/modelfiles/create/+page.svelte
src/routes/(app)/modelfiles/create/+page.svelte
+15
-2
src/routes/(app)/modelfiles/edit/[tag]/+page.svelte
src/routes/(app)/modelfiles/edit/[tag]/+page.svelte
+8
-1
No files found.
src/routes/(app)/modelfiles/create/+page.svelte
View file @
6df1b197
...
...
@@ -3,7 +3,7 @@
import { toast } from 'svelte-french-toast';
import { goto } from '$app/navigation';
import { OLLAMA_API_BASE_URL } from '$lib/constants';
import { settings, db, user, config, modelfiles } from '$lib/stores';
import { settings, db, user, config, modelfiles
, models
} from '$lib/stores';
import Advanced from '$lib/components/chat/Settings/Advanced.svelte';
import { splitStream } from '$lib/utils';
...
...
@@ -101,13 +101,26 @@ SYSTEM """${system}"""`.replace(/^\s*\n/gm, '');
toast.error(
'Uh-oh! It looks like you missed selecting a category. Please choose one to complete your modelfile.'
);
loading = false;
success = false;
return success;
}
if ($models.includes(tagName)) {
toast.error(
`Uh-oh! It looks like you already have a model named '${tagName}'. Please choose a different name to complete your modelfile.`
);
loading = false;
success = false;
return success;
}
if (
title !== '' &&
desc !== '' &&
content !== '' &&
Object.keys(categories).filter((category) => categories[category]).length > 0
Object.keys(categories).filter((category) => categories[category]).length > 0 &&
!$models.includes(tagName)
) {
const res = await fetch(`${$settings?.API_BASE_URL ?? OLLAMA_API_BASE_URL}/create`, {
method: 'POST',
...
...
src/routes/(app)/modelfiles/edit/[tag]/+page.svelte
View file @
6df1b197
...
...
@@ -60,7 +60,14 @@
title = modelfile.title;
desc = modelfile.desc;
content = modelfile.content;
suggestions = modelfile.suggestionPrompts;
suggestions =
modelfile.suggestionPrompts.length != 0
? modelfile.suggestionPrompts
: [
{
content: ''
}
];
for (const category of modelfile.categories) {
categories[category.toLowerCase()] = true;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment