mirror of
https://github.com/open-webui/open-webui
synced 2025-01-18 00:30:51 +00:00
enh: validate required open webui version
This commit is contained in:
parent
bd45b7a04b
commit
b875efab1f
@ -7,6 +7,8 @@
|
||||
import { createNewFunction, getFunctions } from '$lib/apis/functions';
|
||||
import FunctionEditor from '$lib/components/workspace/Functions/FunctionEditor.svelte';
|
||||
import { getModels } from '$lib/apis';
|
||||
import { compareVersion, extractFrontmatter } from '$lib/utils';
|
||||
import { WEBUI_VERSION } from '$lib/constants';
|
||||
|
||||
const i18n = getContext('i18n');
|
||||
|
||||
@ -16,6 +18,14 @@
|
||||
|
||||
const saveHandler = async (data) => {
|
||||
console.log(data);
|
||||
|
||||
const manifest = extractFrontmatter(data.content);
|
||||
if (compareVersion(manifest?.required_open_webui_version ?? '0.0.0', WEBUI_VERSION)) {
|
||||
console.log('Version is lower than required');
|
||||
toast.error($i18n.t('Open WebUI version is lower than required version'));
|
||||
return;
|
||||
}
|
||||
|
||||
const res = await createNewFunction(localStorage.token, {
|
||||
id: data.id,
|
||||
name: data.name,
|
||||
|
@ -10,6 +10,8 @@
|
||||
import FunctionEditor from '$lib/components/workspace/Functions/FunctionEditor.svelte';
|
||||
import Spinner from '$lib/components/common/Spinner.svelte';
|
||||
import { getModels } from '$lib/apis';
|
||||
import { compareVersion, extractFrontmatter } from '$lib/utils';
|
||||
import { WEBUI_VERSION } from '$lib/constants';
|
||||
|
||||
const i18n = getContext('i18n');
|
||||
|
||||
@ -17,6 +19,14 @@
|
||||
|
||||
const saveHandler = async (data) => {
|
||||
console.log(data);
|
||||
|
||||
const manifest = extractFrontmatter(data.content);
|
||||
if (compareVersion(manifest?.required_open_webui_version ?? '0.0.0', WEBUI_VERSION)) {
|
||||
console.log('Version is lower than required');
|
||||
toast.error($i18n.t('Open WebUI version is lower than required version'));
|
||||
return;
|
||||
}
|
||||
|
||||
const res = await updateFunctionById(localStorage.token, func.id, {
|
||||
id: data.id,
|
||||
name: data.name,
|
||||
|
@ -2,7 +2,9 @@
|
||||
import { goto } from '$app/navigation';
|
||||
import { createNewTool, getTools } from '$lib/apis/tools';
|
||||
import ToolkitEditor from '$lib/components/workspace/Tools/ToolkitEditor.svelte';
|
||||
import { WEBUI_VERSION } from '$lib/constants';
|
||||
import { tools } from '$lib/stores';
|
||||
import { compareVersion, extractFrontmatter } from '$lib/utils';
|
||||
import { onMount, getContext } from 'svelte';
|
||||
import { toast } from 'svelte-sonner';
|
||||
|
||||
@ -14,6 +16,14 @@
|
||||
|
||||
const saveHandler = async (data) => {
|
||||
console.log(data);
|
||||
|
||||
const manifest = extractFrontmatter(data.content);
|
||||
if (compareVersion(manifest?.required_open_webui_version ?? '0.0.0', WEBUI_VERSION)) {
|
||||
console.log('Version is lower than required');
|
||||
toast.error($i18n.t('Open WebUI version is lower than required version'));
|
||||
return;
|
||||
}
|
||||
|
||||
const res = await createNewTool(localStorage.token, {
|
||||
id: data.id,
|
||||
name: data.name,
|
||||
|
@ -4,7 +4,9 @@
|
||||
import { getToolById, getTools, updateToolById } from '$lib/apis/tools';
|
||||
import Spinner from '$lib/components/common/Spinner.svelte';
|
||||
import ToolkitEditor from '$lib/components/workspace/Tools/ToolkitEditor.svelte';
|
||||
import { WEBUI_VERSION } from '$lib/constants';
|
||||
import { tools } from '$lib/stores';
|
||||
import { compareVersion, extractFrontmatter } from '$lib/utils';
|
||||
import { onMount, getContext } from 'svelte';
|
||||
import { toast } from 'svelte-sonner';
|
||||
|
||||
@ -14,6 +16,14 @@
|
||||
|
||||
const saveHandler = async (data) => {
|
||||
console.log(data);
|
||||
|
||||
const manifest = extractFrontmatter(data.content);
|
||||
if (compareVersion(manifest?.required_open_webui_version ?? '0.0.0', WEBUI_VERSION)) {
|
||||
console.log('Version is lower than required');
|
||||
toast.error($i18n.t('Open WebUI version is lower than required version'));
|
||||
return;
|
||||
}
|
||||
|
||||
const res = await updateToolById(localStorage.token, tool.id, {
|
||||
id: data.id,
|
||||
name: data.name,
|
||||
|
Loading…
Reference in New Issue
Block a user