mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-11 20:05:19 +00:00
* feat: improve ollama model management experience
This commit introduces several improvements to the Ollama model management modal:
- Adds a cancel button to the model pulling operation, using the existing 'x' button pattern.
- Adds a cancel button to the "Update All" models operation, allowing the user to cancel the update for the currently processing model.
- Cleans up toast notifications when updating all models. A single toast is now shown at the beginning and a summary toast at the end, preventing notification spam.
- Refactors the `ManageOllama.svelte` component to support these new cancellation features.
- Adds tooltips to all buttons in the modal to improve clarity.
- Disables buttons when their corresponding input fields are empty to prevent accidental clicks.
* fix
* i18n: improve Chinese translation
* fix: handle non‑UTF8 chars in third‑party responses without error
* German translation of new strings in i18n
* log web search queries only with level 'debug' instead of 'info'
* Tool calls now only include text and dont inlcude other content like image b64
* fix onedrive
* fix: discovery url
* fix: default permissions not being loaded
* fix: ai hallucination
* fix: non rich text input copy
* refac: rm print statements
* refac: disable direct models from model editors
* refac/fix: do not process xlsx files with azure doc intelligence
* Update pull_request_template.md
* Update generated image translation in DE-de
* added missing danish translations
* feat(onedrive): Enable search and "My Organization" pivot
* style(onedrive): Formatting fix
* feat: Implement toggling for vertical and horizontal flow layouts
This commit introduces the necessary logic and UI controls to allow users to switch the Flow component layout between vertical and horizontal orientations.
* **`Flow.svelte` Refactoring:**
* Updates logic for calculating level offsets and node positions to consistently respect the current flow orientation.
* Adds a control panel using `<Controls>` and `<SwitchButton>` components.
* Provides user interface elements to easily switch the flow layout between horizontal and vertical orientations.
* build(deps): bump pydantic from 2.11.7 to 2.11.9 in /backend
Bumps [pydantic](https://github.com/pydantic/pydantic) from 2.11.7 to 2.11.9.
- [Release notes](https://github.com/pydantic/pydantic/releases)
- [Changelog](https://github.com/pydantic/pydantic/blob/v2.11.9/HISTORY.md)
- [Commits](https://github.com/pydantic/pydantic/compare/v2.11.7...v2.11.9)
---
updated-dependencies:
- dependency-name: pydantic
dependency-version: 2.11.9
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot] <support@github.com>
* build(deps): bump black from 25.1.0 to 25.9.0 in /backend
Bumps [black](https://github.com/psf/black) from 25.1.0 to 25.9.0.
- [Release notes](https://github.com/psf/black/releases)
- [Changelog](https://github.com/psf/black/blob/main/CHANGES.md)
- [Commits](https://github.com/psf/black/compare/25.1.0...25.9.0)
---
updated-dependencies:
- dependency-name: black
dependency-version: 25.9.0
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com>
* build(deps): bump markdown from 3.8.2 to 3.9 in /backend
Bumps [markdown](https://github.com/Python-Markdown/markdown) from 3.8.2 to 3.9.
- [Release notes](https://github.com/Python-Markdown/markdown/releases)
- [Changelog](https://github.com/Python-Markdown/markdown/blob/master/docs/changelog.md)
- [Commits](https://github.com/Python-Markdown/markdown/compare/3.8.2...3.9.0)
---
updated-dependencies:
- dependency-name: markdown
dependency-version: '3.9'
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com>
* build(deps): bump chromadb from 1.0.20 to 1.1.0 in /backend
Bumps [chromadb](https://github.com/chroma-core/chroma) from 1.0.20 to 1.1.0.
- [Release notes](https://github.com/chroma-core/chroma/releases)
- [Changelog](https://github.com/chroma-core/chroma/blob/main/RELEASE_PROCESS.md)
- [Commits](https://github.com/chroma-core/chroma/compare/1.0.20...1.1.0)
---
updated-dependencies:
- dependency-name: chromadb
dependency-version: 1.1.0
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com>
* build(deps): bump opentelemetry-api from 1.36.0 to 1.37.0
Bumps [opentelemetry-api](https://github.com/open-telemetry/opentelemetry-python) from 1.36.0 to 1.37.0.
- [Release notes](https://github.com/open-telemetry/opentelemetry-python/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-python/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-python/compare/v1.36.0...v1.37.0)
---
updated-dependencies:
- dependency-name: opentelemetry-api
dependency-version: 1.37.0
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com>
* refac: ollama embed form data
* fix: non rich text handling
* fix: oauth client registration
* refac
* chore: dep bump
* chore: fastapi bump
* chore/refac: bump bcrypt and remove passlib
* Improving Korean Translation
* refac
* Improving Korean Translation
* feat: PWA share_target implementation
Co-Authored-By: gjveld <19951982+gjveld@users.noreply.github.com>
* refac: message input mobile detection behaviour
* feat: model_ids per folder
* Update translation.json (pt-BR)
inclusion of new translations of items that have been added
* refac
* refac
* refac
* refac
* refac/fix: temp chat
* refac
* refac: stop task
* refac/fix: azure audio escape
* refac: external tool validation
* refac/enh: start.sh additional args support
* refac
* refac: styling
* refac/fix: direct connection floating action buttons
* refac/fix: system prompt duplication
* refac/enh: openai tts additional params support
* refac
* feat: load data in parallel to accelerate page loading speed
* i18n: improve Chinese translation
* refac
* refac: model selector
* UPD: i18n es-ES Translation v0.6.33
UPD: i18n es-ES Translation v0.6.33
Updated new strings.
* refac
* improved query pref by querying only relevant columns
* refac/enh: docling params
* refac
* refac: openai additional headers support
* refac
* FEAT: Add Vega Char Visualizer Renderer
### FEAT: Add Vega Char Visualizer Renderer
Feature required in https://github.com/open-webui/open-webui/discussions/18022
Added npm vega lib to package.json
Added function for visualization renderer to src/libs/utils/index.ts
Added logic to src/lib/components/chat/Messages/CodeBlock.svelte
The treatment is similar as for mermaid diagrams.
Reference: https://vega.github.io/vega/
* refac
* chore
* refac
* FEAT: Add Vega-Lite Char Visualizer Renderer
### FEAT: Add Vega Char Visualizer Renderer
Add suport for Vega-Lite Specifications.
Vega-Lite is a "compiled" version of Vega Char Visualizer.
For be rendered with Vega it have to be compiled.
This PR add the check and compile if necessary, is a complement of recent Vega Renderer Feature added.
* refac
* refac/fix: switch
* enh/refac: url input handling
* refac
* refac: styling
* UPD: Add Validators & Error Toast for Mermaid & Vega diagrams
### UPD: Feat: Add Validators & Error Toast for Mermaid & Vega diagrams
Description:
As many time the diagrams generated or entered have syntax errors the diagrams are not rendered due to that errors, but as there isn't any notification is difficult to know what happend.
This PR add validator and toast notification when error on Mermaid and Vega/Vega-Lite diagrams, helping the user to fix its.
* removed redundant knowledge API call
* Fix Code Format
* refac: model workspace view
* refac
* refac: knowledge
* refac: prompts
* refac: tools
* refac
* feat: attach folder
* refac: make tencentcloud-sdk-python optional
* refac/fix: oauth
* enh: ENABLE_OAUTH_EMAIL_FALLBACK
* refac/fix: folders
* Update requirements.txt
* Update pyproject.toml
* UPD: Add Validators & Error Toast for Mermaid & Vega diagrams
### UPD: Feat: Add Validators & Error Toast for Mermaid & Vega diagrams
Description:
As many time the diagrams generated or entered have syntax errors the diagrams are not rendered due to that errors, but as there isn't any notification is difficult to know what happend.
This PR add validator and toast notification when error on Mermaid and Vega/Vega-Lite diagrams, helping the user to fix its.
Note:
Another possibility of integrating this Graph Visualizer is through its svelte component: https://github.com/vega/svelte-vega/tree/main/packages/svelte-vega
* Removed unused toast import & Code Format
* refac
* refac: external tool server view
* refac
* refac: overview
* refac: styling
* refac
* Update bug_report.yaml
* refac
* refac
* refac
* refac
* refac: oauth client fallback
* Fixed: Cannot handle batch sizes > 1 if no padding token is defined
Fixes Cannot handle batch sizes > 1 if no padding token is defined
For reranker models that do not have this defined in their config by using the eos_token_id if present as pad_token_id.
* refac: fallback to reasoning content
* fix(i18n): corrected typo in Spanish translation for "Reasoning Tags"
Typo fixed in Spanish translation file at line 1240 of `open-webui/src/lib/i18n/locales/es-ES/translation.json`:
- Incorrect: "Eriquetas de Razonamiento"
- Correct: "Etiquetas de Razonamiento"
This improves clarity and consistency in the UI.
* refac/fix: ENABLE_STAR_SESSIONS_MIDDLEWARE
* refac/fix: redirect
* refac
* refac
* refac
* refac: web search error handling
* refac: source parsing
* refac: functions
* refac
* refac/enh: note pdf export
* refac/fix: mcp oauth2.1
* chore: format
* chore: Changelog (#17995)
* Update CHANGELOG.md
* Update CHANGELOG.md
* Update CHANGELOG.md
* Update CHANGELOG.md
* Update CHANGELOG.md
* Update CHANGELOG.md
* Update CHANGELOG.md
* Update CHANGELOG.md
* Update CHANGELOG.md
* Update CHANGELOG.md
* Update CHANGELOG.md
* Update CHANGELOG.md
* Update CHANGELOG.md
* Update CHANGELOG.md
* Update CHANGELOG.md
* Update CHANGELOG.md
* Update CHANGELOG.md
* Update CHANGELOG.md
* Update CHANGELOG.md
* Update CHANGELOG.md
* Update CHANGELOG.md
* Update CHANGELOG.md
* Update CHANGELOG.md
* Update CHANGELOG.md
* Update CHANGELOG.md
* Update CHANGELOG.md
* Update CHANGELOG.md
* refac
* chore: dep bump
---------
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: silentoplayz <jacwoo21@outlook.com>
Co-authored-by: Shirasawa <764798966@qq.com>
Co-authored-by: Jan Kessler <jakessle@uni-mainz.de>
Co-authored-by: Jacob Leksan <jacob.leksan@expedient.com>
Co-authored-by: Classic298 <27028174+Classic298@users.noreply.github.com>
Co-authored-by: sinejespersen <sinejespersen@protonmail.com>
Co-authored-by: Selene Blok <selene.blok@rws.nl>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Cyp <cypher9715@naver.com>
Co-authored-by: gjveld <19951982+gjveld@users.noreply.github.com>
Co-authored-by: joaoback <156559121+joaoback@users.noreply.github.com>
Co-authored-by: _00_ <131402327+rgaricano@users.noreply.github.com>
Co-authored-by: expruc <eygabi01@gmail.com>
Co-authored-by: YetheSamartaka <55753928+YetheSamartaka@users.noreply.github.com>
Co-authored-by: Akutangulo <akutangulo@gmail.com>
857 lines
23 KiB
Svelte
857 lines
23 KiB
Svelte
<script lang="ts">
|
|
import { toast } from 'svelte-sonner';
|
|
|
|
import { onMount, getContext, tick } from 'svelte';
|
|
import { models, tools, functions, knowledge as knowledgeCollections, user } from '$lib/stores';
|
|
import { WEBUI_BASE_URL } from '$lib/constants';
|
|
|
|
import { getTools } from '$lib/apis/tools';
|
|
import { getFunctions } from '$lib/apis/functions';
|
|
import { getKnowledgeBases } from '$lib/apis/knowledge';
|
|
|
|
import AdvancedParams from '$lib/components/chat/Settings/Advanced/AdvancedParams.svelte';
|
|
import Tags from '$lib/components/common/Tags.svelte';
|
|
import Knowledge from '$lib/components/workspace/Models/Knowledge.svelte';
|
|
import ToolsSelector from '$lib/components/workspace/Models/ToolsSelector.svelte';
|
|
import FiltersSelector from '$lib/components/workspace/Models/FiltersSelector.svelte';
|
|
import ActionsSelector from '$lib/components/workspace/Models/ActionsSelector.svelte';
|
|
import Capabilities from '$lib/components/workspace/Models/Capabilities.svelte';
|
|
import Textarea from '$lib/components/common/Textarea.svelte';
|
|
import AccessControl from '../common/AccessControl.svelte';
|
|
import Spinner from '$lib/components/common/Spinner.svelte';
|
|
import XMark from '$lib/components/icons/XMark.svelte';
|
|
import DefaultFiltersSelector from './DefaultFiltersSelector.svelte';
|
|
import DefaultFeatures from './DefaultFeatures.svelte';
|
|
|
|
const i18n = getContext('i18n');
|
|
|
|
export let onSubmit: Function;
|
|
export let onBack: null | Function = null;
|
|
|
|
export let model = null;
|
|
export let edit = false;
|
|
|
|
export let preset = true;
|
|
|
|
let loading = false;
|
|
let success = false;
|
|
|
|
let filesInputElement;
|
|
let inputFiles;
|
|
|
|
let showAdvanced = false;
|
|
let showPreview = false;
|
|
|
|
let loaded = false;
|
|
|
|
// ///////////
|
|
// model
|
|
// ///////////
|
|
|
|
let id = '';
|
|
let name = '';
|
|
|
|
let enableDescription = true;
|
|
|
|
$: if (!edit) {
|
|
if (name) {
|
|
id = name
|
|
.replace(/\s+/g, '-')
|
|
.replace(/[^a-zA-Z0-9-]/g, '')
|
|
.toLowerCase();
|
|
}
|
|
}
|
|
|
|
let system = '';
|
|
let info = {
|
|
id: '',
|
|
base_model_id: null,
|
|
name: '',
|
|
meta: {
|
|
profile_image_url: `${WEBUI_BASE_URL}/static/favicon.png`,
|
|
description: '',
|
|
suggestion_prompts: null,
|
|
tags: []
|
|
},
|
|
params: {
|
|
system: ''
|
|
}
|
|
};
|
|
|
|
let params = {
|
|
system: ''
|
|
};
|
|
|
|
let knowledge = [];
|
|
let toolIds = [];
|
|
|
|
let filterIds = [];
|
|
let defaultFilterIds = [];
|
|
|
|
let capabilities = {
|
|
vision: true,
|
|
file_upload: true,
|
|
web_search: true,
|
|
image_generation: true,
|
|
code_interpreter: true,
|
|
citations: true,
|
|
status_updates: true,
|
|
usage: undefined
|
|
};
|
|
let defaultFeatureIds = [];
|
|
|
|
let actionIds = [];
|
|
let accessControl = {};
|
|
|
|
const addUsage = (base_model_id) => {
|
|
const baseModel = $models.find((m) => m.id === base_model_id);
|
|
|
|
if (baseModel) {
|
|
if (baseModel.owned_by === 'openai') {
|
|
capabilities.usage = baseModel?.meta?.capabilities?.usage ?? false;
|
|
} else {
|
|
delete capabilities.usage;
|
|
}
|
|
capabilities = capabilities;
|
|
}
|
|
};
|
|
|
|
const submitHandler = async () => {
|
|
loading = true;
|
|
|
|
info.id = id;
|
|
info.name = name;
|
|
|
|
if (id === '') {
|
|
toast.error($i18n.t('Model ID is required.'));
|
|
loading = false;
|
|
|
|
return;
|
|
}
|
|
|
|
if (name === '') {
|
|
toast.error($i18n.t('Model Name is required.'));
|
|
loading = false;
|
|
|
|
return;
|
|
}
|
|
|
|
if (knowledge.some((item) => item.status === 'uploading')) {
|
|
toast.error($i18n.t('Please wait until all files are uploaded.'));
|
|
loading = false;
|
|
|
|
return;
|
|
}
|
|
|
|
info.params = { ...info.params, ...params };
|
|
|
|
info.access_control = accessControl;
|
|
info.meta.capabilities = capabilities;
|
|
|
|
if (enableDescription) {
|
|
info.meta.description = info.meta.description.trim() === '' ? null : info.meta.description;
|
|
} else {
|
|
info.meta.description = null;
|
|
}
|
|
|
|
if (knowledge.length > 0) {
|
|
info.meta.knowledge = knowledge;
|
|
} else {
|
|
if (info.meta.knowledge) {
|
|
delete info.meta.knowledge;
|
|
}
|
|
}
|
|
|
|
if (toolIds.length > 0) {
|
|
info.meta.toolIds = toolIds;
|
|
} else {
|
|
if (info.meta.toolIds) {
|
|
delete info.meta.toolIds;
|
|
}
|
|
}
|
|
|
|
if (filterIds.length > 0) {
|
|
info.meta.filterIds = filterIds;
|
|
} else {
|
|
if (info.meta.filterIds) {
|
|
delete info.meta.filterIds;
|
|
}
|
|
}
|
|
|
|
if (defaultFilterIds.length > 0) {
|
|
info.meta.defaultFilterIds = defaultFilterIds;
|
|
} else {
|
|
if (info.meta.defaultFilterIds) {
|
|
delete info.meta.defaultFilterIds;
|
|
}
|
|
}
|
|
|
|
if (actionIds.length > 0) {
|
|
info.meta.actionIds = actionIds;
|
|
} else {
|
|
if (info.meta.actionIds) {
|
|
delete info.meta.actionIds;
|
|
}
|
|
}
|
|
|
|
if (defaultFeatureIds.length > 0) {
|
|
info.meta.defaultFeatureIds = defaultFeatureIds;
|
|
} else {
|
|
if (info.meta.defaultFeatureIds) {
|
|
delete info.meta.defaultFeatureIds;
|
|
}
|
|
}
|
|
|
|
info.params.system = system.trim() === '' ? null : system;
|
|
info.params.stop = params.stop ? params.stop.split(',').filter((s) => s.trim()) : null;
|
|
Object.keys(info.params).forEach((key) => {
|
|
if (info.params[key] === '' || info.params[key] === null) {
|
|
delete info.params[key];
|
|
}
|
|
});
|
|
|
|
await onSubmit(info);
|
|
|
|
loading = false;
|
|
success = false;
|
|
};
|
|
|
|
onMount(async () => {
|
|
await tools.set(await getTools(localStorage.token));
|
|
await functions.set(await getFunctions(localStorage.token));
|
|
await knowledgeCollections.set([...(await getKnowledgeBases(localStorage.token))]);
|
|
|
|
// Scroll to top 'workspace-container' element
|
|
const workspaceContainer = document.getElementById('workspace-container');
|
|
if (workspaceContainer) {
|
|
workspaceContainer.scrollTop = 0;
|
|
}
|
|
|
|
if (model) {
|
|
name = model.name;
|
|
await tick();
|
|
|
|
id = model.id;
|
|
|
|
enableDescription = model?.meta?.description !== null;
|
|
|
|
if (model.base_model_id) {
|
|
const base_model = $models
|
|
.filter((m) => !m?.preset && !(m?.arena ?? false))
|
|
.find((m) => [model.base_model_id, `${model.base_model_id}:latest`].includes(m.id));
|
|
|
|
console.log('base_model', base_model);
|
|
|
|
if (base_model) {
|
|
model.base_model_id = base_model.id;
|
|
} else {
|
|
model.base_model_id = null;
|
|
}
|
|
}
|
|
|
|
system = model?.params?.system ?? '';
|
|
|
|
params = { ...params, ...model?.params };
|
|
params.stop = params?.stop
|
|
? (typeof params.stop === 'string' ? params.stop.split(',') : (params?.stop ?? [])).join(
|
|
','
|
|
)
|
|
: null;
|
|
|
|
knowledge = (model?.meta?.knowledge ?? []).map((item) => {
|
|
if (item?.collection_name && item?.type !== 'file') {
|
|
return {
|
|
id: item.collection_name,
|
|
name: item.name,
|
|
legacy: true
|
|
};
|
|
} else if (item?.collection_names) {
|
|
return {
|
|
name: item.name,
|
|
type: 'collection',
|
|
collection_names: item.collection_names,
|
|
legacy: true
|
|
};
|
|
} else {
|
|
return item;
|
|
}
|
|
});
|
|
|
|
toolIds = model?.meta?.toolIds ?? [];
|
|
filterIds = model?.meta?.filterIds ?? [];
|
|
defaultFilterIds = model?.meta?.defaultFilterIds ?? [];
|
|
actionIds = model?.meta?.actionIds ?? [];
|
|
|
|
capabilities = { ...capabilities, ...(model?.meta?.capabilities ?? {}) };
|
|
defaultFeatureIds = model?.meta?.defaultFeatureIds ?? [];
|
|
|
|
if ('access_control' in model) {
|
|
accessControl = model.access_control;
|
|
} else {
|
|
accessControl = {};
|
|
}
|
|
|
|
console.log(model?.access_control);
|
|
console.log(accessControl);
|
|
|
|
info = {
|
|
...info,
|
|
...JSON.parse(
|
|
JSON.stringify(
|
|
model
|
|
? model
|
|
: {
|
|
id: model.id,
|
|
name: model.name
|
|
}
|
|
)
|
|
)
|
|
};
|
|
|
|
console.log(model);
|
|
}
|
|
|
|
loaded = true;
|
|
});
|
|
</script>
|
|
|
|
{#if loaded}
|
|
{#if onBack}
|
|
<button
|
|
class="flex space-x-1"
|
|
on:click={() => {
|
|
onBack();
|
|
}}
|
|
>
|
|
<div class=" self-center">
|
|
<svg
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
viewBox="0 0 20 20"
|
|
fill="currentColor"
|
|
class="h-4 w-4"
|
|
>
|
|
<path
|
|
fill-rule="evenodd"
|
|
d="M17 10a.75.75 0 01-.75.75H5.612l4.158 3.96a.75.75 0 11-1.04 1.08l-5.5-5.25a.75.75 0 010-1.08l5.5-5.25a.75.75 0 111.04 1.08L5.612 9.25H16.25A.75.75 0 0117 10z"
|
|
clip-rule="evenodd"
|
|
/>
|
|
</svg>
|
|
</div>
|
|
<div class=" self-center text-sm font-medium">{$i18n.t('Back')}</div>
|
|
</button>
|
|
{/if}
|
|
|
|
<div class="w-full max-h-full flex justify-center">
|
|
<input
|
|
bind:this={filesInputElement}
|
|
bind:files={inputFiles}
|
|
type="file"
|
|
hidden
|
|
accept="image/*"
|
|
on:change={() => {
|
|
let reader = new FileReader();
|
|
reader.onload = (event) => {
|
|
let originalImageUrl = `${event.target.result}`;
|
|
|
|
const img = new Image();
|
|
img.src = originalImageUrl;
|
|
|
|
img.onload = function () {
|
|
const canvas = document.createElement('canvas');
|
|
const ctx = canvas.getContext('2d');
|
|
|
|
// Calculate the aspect ratio of the image
|
|
const aspectRatio = img.width / img.height;
|
|
|
|
// Calculate the new width and height to fit within 100x100
|
|
let newWidth, newHeight;
|
|
if (aspectRatio > 1) {
|
|
newWidth = 250 * aspectRatio;
|
|
newHeight = 250;
|
|
} else {
|
|
newWidth = 250;
|
|
newHeight = 250 / aspectRatio;
|
|
}
|
|
|
|
// Set the canvas size
|
|
canvas.width = 250;
|
|
canvas.height = 250;
|
|
|
|
// Calculate the position to center the image
|
|
const offsetX = (250 - newWidth) / 2;
|
|
const offsetY = (250 - newHeight) / 2;
|
|
|
|
// Draw the image on the canvas
|
|
ctx.drawImage(img, offsetX, offsetY, newWidth, newHeight);
|
|
|
|
// Get the base64 representation of the compressed image
|
|
const compressedSrc = canvas.toDataURL();
|
|
|
|
// Display the compressed image
|
|
info.meta.profile_image_url = compressedSrc;
|
|
|
|
inputFiles = null;
|
|
filesInputElement.value = '';
|
|
};
|
|
};
|
|
|
|
if (
|
|
inputFiles &&
|
|
inputFiles.length > 0 &&
|
|
['image/gif', 'image/webp', 'image/jpeg', 'image/png', 'image/svg+xml'].includes(
|
|
inputFiles[0]['type']
|
|
)
|
|
) {
|
|
reader.readAsDataURL(inputFiles[0]);
|
|
} else {
|
|
console.log(`Unsupported File Type '${inputFiles[0]['type']}'.`);
|
|
inputFiles = null;
|
|
}
|
|
}}
|
|
/>
|
|
|
|
{#if !edit || (edit && model)}
|
|
<form
|
|
class="flex flex-col md:flex-row w-full gap-3 md:gap-6"
|
|
on:submit|preventDefault={() => {
|
|
submitHandler();
|
|
}}
|
|
>
|
|
<div class="self-center md:self-start flex justify-center my-2 shrink-0">
|
|
<div class="self-center">
|
|
<button
|
|
class="rounded-xl flex shrink-0 items-center {info.meta.profile_image_url !==
|
|
`${WEBUI_BASE_URL}/static/favicon.png`
|
|
? 'bg-transparent'
|
|
: 'bg-white'} shadow-xl group relative"
|
|
type="button"
|
|
on:click={() => {
|
|
filesInputElement.click();
|
|
}}
|
|
>
|
|
{#if info.meta.profile_image_url}
|
|
<img
|
|
src={info.meta.profile_image_url}
|
|
alt="model profile"
|
|
class="rounded-xl size-72 md:size-60 object-cover shrink-0"
|
|
/>
|
|
{:else}
|
|
<img
|
|
src="{WEBUI_BASE_URL}/static/favicon.png"
|
|
alt="model profile"
|
|
class=" rounded-xl size-72 md:size-60 object-cover shrink-0"
|
|
/>
|
|
{/if}
|
|
|
|
<div class="absolute bottom-0 right-0 z-10">
|
|
<div class="m-1.5">
|
|
<div
|
|
class="shadow-xl p-1 rounded-full border-2 border-white bg-gray-800 text-white group-hover:bg-gray-600 transition dark:border-black dark:bg-white dark:group-hover:bg-gray-200 dark:text-black"
|
|
>
|
|
<svg
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
viewBox="0 0 16 16"
|
|
fill="currentColor"
|
|
class="size-5"
|
|
>
|
|
<path
|
|
fill-rule="evenodd"
|
|
d="M2 4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4Zm10.5 5.707a.5.5 0 0 0-.146-.353l-1-1a.5.5 0 0 0-.708 0L9.354 9.646a.5.5 0 0 1-.708 0L6.354 7.354a.5.5 0 0 0-.708 0l-2 2a.5.5 0 0 0-.146.353V12a.5.5 0 0 0 .5.5h8a.5.5 0 0 0 .5-.5V9.707ZM12 5a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"
|
|
clip-rule="evenodd"
|
|
/>
|
|
</svg>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div
|
|
class="absolute top-0 bottom-0 left-0 right-0 bg-white dark:bg-black rounded-lg opacity-0 group-hover:opacity-20 transition"
|
|
></div>
|
|
</button>
|
|
|
|
<div class="flex w-full mt-1 justify-end">
|
|
<button
|
|
class="px-2 py-1 text-gray-500 rounded-lg text-xs"
|
|
on:click={() => {
|
|
info.meta.profile_image_url = `${WEBUI_BASE_URL}/static/favicon.png`;
|
|
}}
|
|
type="button"
|
|
>
|
|
{$i18n.t('Reset Image')}</button
|
|
>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="w-full">
|
|
<div class="mt-2 my-2 flex flex-col">
|
|
<div class="flex-1">
|
|
<div>
|
|
<input
|
|
class="text-3xl font-semibold w-full bg-transparent outline-hidden"
|
|
placeholder={$i18n.t('Model Name')}
|
|
bind:value={name}
|
|
required
|
|
/>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="flex-1">
|
|
<div>
|
|
<input
|
|
class="text-xs w-full bg-transparent text-gray-500 outline-hidden"
|
|
placeholder={$i18n.t('Model ID')}
|
|
bind:value={id}
|
|
disabled={edit}
|
|
required
|
|
/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{#if preset}
|
|
<div class="my-1">
|
|
<div class=" text-sm font-semibold mb-1">{$i18n.t('Base Model (From)')}</div>
|
|
|
|
<div>
|
|
<select
|
|
class="text-sm w-full bg-transparent outline-hidden"
|
|
placeholder={$i18n.t('Select a base model (e.g. llama3, gpt-4o)')}
|
|
bind:value={info.base_model_id}
|
|
on:change={(e) => {
|
|
addUsage(e.target.value);
|
|
}}
|
|
required
|
|
>
|
|
<option value={null} class=" text-gray-900"
|
|
>{$i18n.t('Select a base model')}</option
|
|
>
|
|
{#each $models.filter((m) => (model ? m.id !== model.id : true) && !m?.preset && m?.owned_by !== 'arena' && !(m?.direct ?? false)) as model}
|
|
<option value={model.id} class=" text-gray-900">{model.name}</option>
|
|
{/each}
|
|
</select>
|
|
</div>
|
|
</div>
|
|
{/if}
|
|
|
|
<div class="my-1">
|
|
<div class="mb-1 flex w-full justify-between items-center">
|
|
<div class=" self-center text-sm font-semibold">{$i18n.t('Description')}</div>
|
|
|
|
<button
|
|
class="p-1 text-xs flex rounded-sm transition"
|
|
type="button"
|
|
aria-pressed={enableDescription ? 'true' : 'false'}
|
|
aria-label={enableDescription
|
|
? $i18n.t('Custom description enabled')
|
|
: $i18n.t('Default description enabled')}
|
|
on:click={() => {
|
|
enableDescription = !enableDescription;
|
|
}}
|
|
>
|
|
{#if !enableDescription}
|
|
<span class="ml-2 self-center">{$i18n.t('Default')}</span>
|
|
{:else}
|
|
<span class="ml-2 self-center">{$i18n.t('Custom')}</span>
|
|
{/if}
|
|
</button>
|
|
</div>
|
|
|
|
{#if enableDescription}
|
|
<Textarea
|
|
className=" text-sm w-full bg-transparent outline-hidden resize-none overflow-y-hidden "
|
|
placeholder={$i18n.t('Add a short description about what this model does')}
|
|
bind:value={info.meta.description}
|
|
/>
|
|
{/if}
|
|
</div>
|
|
|
|
<div class=" mt-2 my-1">
|
|
<div class="">
|
|
<Tags
|
|
tags={info?.meta?.tags ?? []}
|
|
on:delete={(e) => {
|
|
const tagName = e.detail;
|
|
info.meta.tags = info.meta.tags.filter((tag) => tag.name !== tagName);
|
|
}}
|
|
on:add={(e) => {
|
|
const tagName = e.detail;
|
|
if (!(info?.meta?.tags ?? null)) {
|
|
info.meta.tags = [{ name: tagName }];
|
|
} else {
|
|
info.meta.tags = [...info.meta.tags, { name: tagName }];
|
|
}
|
|
}}
|
|
/>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="my-2">
|
|
<div class="px-4 py-3 bg-gray-50 dark:bg-gray-950 rounded-3xl">
|
|
<AccessControl
|
|
bind:accessControl
|
|
accessRoles={['read', 'write']}
|
|
allowPublic={$user?.permissions?.sharing?.public_models || $user?.role === 'admin'}
|
|
/>
|
|
</div>
|
|
</div>
|
|
|
|
<hr class=" border-gray-100 dark:border-gray-850 my-1.5" />
|
|
|
|
<div class="my-2">
|
|
<div class="flex w-full justify-between">
|
|
<div class=" self-center text-sm font-semibold">{$i18n.t('Model Params')}</div>
|
|
</div>
|
|
|
|
<div class="mt-2">
|
|
<div class="my-1">
|
|
<div class=" text-xs font-semibold mb-2">{$i18n.t('System Prompt')}</div>
|
|
<div>
|
|
<Textarea
|
|
className=" text-sm w-full bg-transparent outline-hidden resize-none overflow-y-hidden "
|
|
placeholder={$i18n.t(
|
|
'Write your model system prompt content here\ne.g.) You are Mario from Super Mario Bros, acting as an assistant.'
|
|
)}
|
|
rows={4}
|
|
bind:value={system}
|
|
/>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="flex w-full justify-between">
|
|
<div class=" self-center text-xs font-semibold">
|
|
{$i18n.t('Advanced Params')}
|
|
</div>
|
|
|
|
<button
|
|
class="p-1 px-3 text-xs flex rounded-sm transition"
|
|
type="button"
|
|
on:click={() => {
|
|
showAdvanced = !showAdvanced;
|
|
}}
|
|
>
|
|
{#if showAdvanced}
|
|
<span class="ml-2 self-center">{$i18n.t('Hide')}</span>
|
|
{:else}
|
|
<span class="ml-2 self-center">{$i18n.t('Show')}</span>
|
|
{/if}
|
|
</button>
|
|
</div>
|
|
|
|
{#if showAdvanced}
|
|
<div class="my-2">
|
|
<AdvancedParams admin={true} custom={true} bind:params />
|
|
</div>
|
|
{/if}
|
|
</div>
|
|
</div>
|
|
|
|
<hr class=" border-gray-100 dark:border-gray-850 my-1" />
|
|
|
|
<div class="my-2">
|
|
<div class="flex w-full justify-between items-center">
|
|
<div class="flex w-full justify-between items-center">
|
|
<div class=" self-center text-sm font-semibold">
|
|
{$i18n.t('Prompt suggestions')}
|
|
</div>
|
|
|
|
<button
|
|
class="p-1 text-xs flex rounded-sm transition"
|
|
type="button"
|
|
on:click={() => {
|
|
if ((info?.meta?.suggestion_prompts ?? null) === null) {
|
|
info.meta.suggestion_prompts = [{ content: '' }];
|
|
} else {
|
|
info.meta.suggestion_prompts = null;
|
|
}
|
|
}}
|
|
>
|
|
{#if (info?.meta?.suggestion_prompts ?? null) === null}
|
|
<span class="ml-2 self-center">{$i18n.t('Default')}</span>
|
|
{:else}
|
|
<span class="ml-2 self-center">{$i18n.t('Custom')}</span>
|
|
{/if}
|
|
</button>
|
|
</div>
|
|
|
|
{#if (info?.meta?.suggestion_prompts ?? null) !== null}
|
|
<button
|
|
class="p-1 px-2 text-xs flex rounded-sm transition"
|
|
type="button"
|
|
on:click={() => {
|
|
if (
|
|
info.meta.suggestion_prompts.length === 0 ||
|
|
info.meta.suggestion_prompts.at(-1).content !== ''
|
|
) {
|
|
info.meta.suggestion_prompts = [
|
|
...info.meta.suggestion_prompts,
|
|
{ content: '' }
|
|
];
|
|
}
|
|
}}
|
|
>
|
|
<svg
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
viewBox="0 0 20 20"
|
|
fill="currentColor"
|
|
class="w-4 h-4"
|
|
>
|
|
<path
|
|
d="M10.75 4.75a.75.75 0 00-1.5 0v4.5h-4.5a.75.75 0 000 1.5h4.5v4.5a.75.75 0 001.5 0v-4.5h4.5a.75.75 0 000-1.5h-4.5v-4.5z"
|
|
/>
|
|
</svg>
|
|
</button>
|
|
{/if}
|
|
</div>
|
|
|
|
{#if info?.meta?.suggestion_prompts}
|
|
<div class="flex flex-col space-y-1 mt-1 mb-3">
|
|
{#if info.meta.suggestion_prompts.length > 0}
|
|
{#each info.meta.suggestion_prompts as prompt, promptIdx}
|
|
<div class=" flex rounded-lg">
|
|
<input
|
|
class=" text-sm w-full bg-transparent outline-hidden border-r border-gray-100 dark:border-gray-850"
|
|
placeholder={$i18n.t('Write a prompt suggestion (e.g. Who are you?)')}
|
|
bind:value={prompt.content}
|
|
/>
|
|
|
|
<button
|
|
class="px-2"
|
|
type="button"
|
|
on:click={() => {
|
|
info.meta.suggestion_prompts.splice(promptIdx, 1);
|
|
info.meta.suggestion_prompts = info.meta.suggestion_prompts;
|
|
}}
|
|
>
|
|
<XMark className={'size-4'} />
|
|
</button>
|
|
</div>
|
|
{/each}
|
|
{:else}
|
|
<div class="text-xs text-center">{$i18n.t('No suggestion prompts')}</div>
|
|
{/if}
|
|
</div>
|
|
{/if}
|
|
</div>
|
|
|
|
<hr class=" border-gray-100 dark:border-gray-850 my-1.5" />
|
|
|
|
<div class="my-2">
|
|
<Knowledge bind:selectedItems={knowledge} />
|
|
</div>
|
|
|
|
<div class="my-2">
|
|
<ToolsSelector bind:selectedToolIds={toolIds} tools={$tools} />
|
|
</div>
|
|
|
|
<div class="my-2">
|
|
<FiltersSelector
|
|
bind:selectedFilterIds={filterIds}
|
|
filters={$functions.filter((func) => func.type === 'filter')}
|
|
/>
|
|
</div>
|
|
|
|
{#if filterIds.length > 0}
|
|
{@const toggleableFilters = $functions.filter(
|
|
(func) =>
|
|
func.type === 'filter' &&
|
|
(filterIds.includes(func.id) || func?.is_global) &&
|
|
func?.meta?.toggle
|
|
)}
|
|
|
|
{#if toggleableFilters.length > 0}
|
|
<div class="my-2">
|
|
<DefaultFiltersSelector
|
|
bind:selectedFilterIds={defaultFilterIds}
|
|
filters={toggleableFilters}
|
|
/>
|
|
</div>
|
|
{/if}
|
|
{/if}
|
|
|
|
<div class="my-2">
|
|
<ActionsSelector
|
|
bind:selectedActionIds={actionIds}
|
|
actions={$functions.filter((func) => func.type === 'action')}
|
|
/>
|
|
</div>
|
|
|
|
<div class="my-2">
|
|
<Capabilities bind:capabilities />
|
|
</div>
|
|
|
|
{#if Object.keys(capabilities).filter((key) => capabilities[key]).length > 0}
|
|
{@const availableFeatures = Object.entries(capabilities)
|
|
.filter(
|
|
([key, value]) =>
|
|
value && ['web_search', 'code_interpreter', 'image_generation'].includes(key)
|
|
)
|
|
.map(([key, value]) => key)}
|
|
|
|
{#if availableFeatures.length > 0}
|
|
<div class="my-2">
|
|
<DefaultFeatures {availableFeatures} bind:featureIds={defaultFeatureIds} />
|
|
</div>
|
|
{/if}
|
|
{/if}
|
|
|
|
<div class="my-2 text-gray-300 dark:text-gray-700">
|
|
<div class="flex w-full justify-between mb-2">
|
|
<div class=" self-center text-sm font-semibold">{$i18n.t('JSON Preview')}</div>
|
|
|
|
<button
|
|
class="p-1 px-3 text-xs flex rounded-sm transition"
|
|
type="button"
|
|
on:click={() => {
|
|
showPreview = !showPreview;
|
|
}}
|
|
>
|
|
{#if showPreview}
|
|
<span class="ml-2 self-center">{$i18n.t('Hide')}</span>
|
|
{:else}
|
|
<span class="ml-2 self-center">{$i18n.t('Show')}</span>
|
|
{/if}
|
|
</button>
|
|
</div>
|
|
|
|
{#if showPreview}
|
|
<div>
|
|
<textarea
|
|
class="text-sm w-full bg-transparent outline-hidden resize-none"
|
|
rows="10"
|
|
value={JSON.stringify(info, null, 2)}
|
|
disabled
|
|
readonly
|
|
/>
|
|
</div>
|
|
{/if}
|
|
</div>
|
|
|
|
<div class="my-2 flex justify-end pb-20">
|
|
<button
|
|
class=" text-sm px-3 py-2 transition rounded-lg {loading
|
|
? ' cursor-not-allowed bg-black hover:bg-gray-900 text-white dark:bg-white dark:hover:bg-gray-100 dark:text-black'
|
|
: 'bg-black hover:bg-gray-900 text-white dark:bg-white dark:hover:bg-gray-100 dark:text-black'} flex w-full justify-center"
|
|
type="submit"
|
|
disabled={loading}
|
|
>
|
|
<div class=" self-center font-medium">
|
|
{#if edit}
|
|
{$i18n.t('Save & Update')}
|
|
{:else}
|
|
{$i18n.t('Save & Create')}
|
|
{/if}
|
|
</div>
|
|
|
|
{#if loading}
|
|
<div class="ml-1.5 self-center">
|
|
<Spinner />
|
|
</div>
|
|
{/if}
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
{/if}
|
|
</div>
|
|
{/if}
|