mirror of
https://github.com/open-webui/open-webui
synced 2025-06-26 18:26:48 +00:00
refac: remove modelfiles completely
This commit is contained in:
parent
c8393db97c
commit
83097cd8be
@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { toast } from 'svelte-sonner';
|
import { toast } from 'svelte-sonner';
|
||||||
import { onMount, tick, getContext } from 'svelte';
|
import { onMount, tick, getContext } from 'svelte';
|
||||||
import { type Model, mobile, modelfiles, settings, showSidebar, models } from '$lib/stores';
|
import { type Model, mobile, settings, showSidebar, models } from '$lib/stores';
|
||||||
import { blobToFile, calculateSHA256, findWordIndices } from '$lib/utils';
|
import { blobToFile, calculateSHA256, findWordIndices } from '$lib/utils';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
@ -13,8 +13,6 @@
|
|||||||
|
|
||||||
export let parentMessage;
|
export let parentMessage;
|
||||||
|
|
||||||
export let selectedModelfiles;
|
|
||||||
|
|
||||||
export let updateChatMessages: Function;
|
export let updateChatMessages: Function;
|
||||||
export let confirmEditResponseMessage: Function;
|
export let confirmEditResponseMessage: Function;
|
||||||
export let rateMessage: Function;
|
export let rateMessage: Function;
|
||||||
@ -130,7 +128,6 @@
|
|||||||
>
|
>
|
||||||
<ResponseMessage
|
<ResponseMessage
|
||||||
message={groupedMessages[model].messages[groupedMessagesIdx[model]]}
|
message={groupedMessages[model].messages[groupedMessagesIdx[model]]}
|
||||||
modelfiles={selectedModelfiles}
|
|
||||||
siblings={groupedMessages[model].messages.map((m) => m.id)}
|
siblings={groupedMessages[model].messages.map((m) => m.id)}
|
||||||
isLastMessage={true}
|
isLastMessage={true}
|
||||||
{updateChatMessages}
|
{updateChatMessages}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
import { tick, createEventDispatcher, getContext } from 'svelte';
|
import { tick, createEventDispatcher, getContext } from 'svelte';
|
||||||
import Name from './Name.svelte';
|
import Name from './Name.svelte';
|
||||||
import ProfileImage from './ProfileImage.svelte';
|
import ProfileImage from './ProfileImage.svelte';
|
||||||
import { modelfiles, settings } from '$lib/stores';
|
import { models, settings } from '$lib/stores';
|
||||||
import Tooltip from '$lib/components/common/Tooltip.svelte';
|
import Tooltip from '$lib/components/common/Tooltip.svelte';
|
||||||
|
|
||||||
import { user as _user } from '$lib/stores';
|
import { user as _user } from '$lib/stores';
|
||||||
@ -60,8 +60,7 @@
|
|||||||
{#if !($settings?.chatBubble ?? true)}
|
{#if !($settings?.chatBubble ?? true)}
|
||||||
<ProfileImage
|
<ProfileImage
|
||||||
src={message.user
|
src={message.user
|
||||||
? $modelfiles.find((modelfile) => modelfile.tagName === message.user)?.imageUrl ??
|
? $models.find((m) => m.id === message.user)?.info?.meta?.profile_image_url ?? '/user.png'
|
||||||
'/user.png'
|
|
||||||
: user?.profile_image_url ?? '/user.png'}
|
: user?.profile_image_url ?? '/user.png'}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
@ -70,12 +69,8 @@
|
|||||||
<div>
|
<div>
|
||||||
<Name>
|
<Name>
|
||||||
{#if message.user}
|
{#if message.user}
|
||||||
{#if $modelfiles.map((modelfile) => modelfile.tagName).includes(message.user)}
|
|
||||||
{$modelfiles.find((modelfile) => modelfile.tagName === message.user)?.title}
|
|
||||||
{:else}
|
|
||||||
{$i18n.t('You')}
|
{$i18n.t('You')}
|
||||||
<span class=" text-gray-500 text-sm font-medium">{message?.user ?? ''}</span>
|
<span class=" text-gray-500 text-sm font-medium">{message?.user ?? ''}</span>
|
||||||
{/if}
|
|
||||||
{:else if $settings.showUsername || $_user.name !== user.name}
|
{:else if $settings.showUsername || $_user.name !== user.name}
|
||||||
{user.name}
|
{user.name}
|
||||||
{:else}
|
{:else}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { getContext, onMount } from 'svelte';
|
import { getContext, onMount } from 'svelte';
|
||||||
|
import { models } from '$lib/stores';
|
||||||
|
|
||||||
import { toast } from 'svelte-sonner';
|
import { toast } from 'svelte-sonner';
|
||||||
import { deleteSharedChatById, getChatById, shareChatById } from '$lib/apis/chats';
|
import { deleteSharedChatById, getChatById, shareChatById } from '$lib/apis/chats';
|
||||||
import { modelfiles } from '$lib/stores';
|
|
||||||
import { copyToClipboard } from '$lib/utils';
|
import { copyToClipboard } from '$lib/utils';
|
||||||
|
|
||||||
import Modal from '../common/Modal.svelte';
|
import Modal from '../common/Modal.svelte';
|
||||||
@ -43,9 +43,7 @@
|
|||||||
tab.postMessage(
|
tab.postMessage(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
chat: _chat,
|
chat: _chat,
|
||||||
modelfiles: $modelfiles.filter((modelfile) =>
|
models: $models.filter((m) => _chat.models.includes(m.id))
|
||||||
_chat.models.includes(modelfile.tagName)
|
|
||||||
)
|
|
||||||
}),
|
}),
|
||||||
'*'
|
'*'
|
||||||
);
|
);
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
WEBUI_NAME,
|
WEBUI_NAME,
|
||||||
chatId,
|
chatId,
|
||||||
mobile,
|
mobile,
|
||||||
modelfiles,
|
|
||||||
settings,
|
settings,
|
||||||
showArchivedChats,
|
showArchivedChats,
|
||||||
showSettings,
|
showSettings,
|
||||||
|
@ -16,8 +16,9 @@
|
|||||||
const i18n = getContext('i18n');
|
const i18n = getContext('i18n');
|
||||||
|
|
||||||
let localModelfiles = [];
|
let localModelfiles = [];
|
||||||
|
|
||||||
let importFiles;
|
let importFiles;
|
||||||
let modelfilesImportInputElement: HTMLInputElement;
|
let modelsImportInputElement: HTMLInputElement;
|
||||||
|
|
||||||
const deleteModelHandler = async (model) => {
|
const deleteModelHandler = async (model) => {
|
||||||
console.log(model.info);
|
console.log(model.info);
|
||||||
@ -243,8 +244,8 @@
|
|||||||
<div class=" flex justify-end w-full mb-3">
|
<div class=" flex justify-end w-full mb-3">
|
||||||
<div class="flex space-x-1">
|
<div class="flex space-x-1">
|
||||||
<input
|
<input
|
||||||
id="modelfiles-import-input"
|
id="models-import-input"
|
||||||
bind:this={modelfilesImportInputElement}
|
bind:this={modelsImportInputElement}
|
||||||
bind:files={importFiles}
|
bind:files={importFiles}
|
||||||
type="file"
|
type="file"
|
||||||
accept=".json"
|
accept=".json"
|
||||||
@ -254,16 +255,16 @@
|
|||||||
|
|
||||||
let reader = new FileReader();
|
let reader = new FileReader();
|
||||||
reader.onload = async (event) => {
|
reader.onload = async (event) => {
|
||||||
let savedModelfiles = JSON.parse(event.target.result);
|
let savedModels = JSON.parse(event.target.result);
|
||||||
console.log(savedModelfiles);
|
console.log(savedModels);
|
||||||
|
|
||||||
for (const modelfile of savedModelfiles) {
|
for (const model of savedModels) {
|
||||||
await addNewModel(localStorage.token, modelfile).catch((error) => {
|
await addNewModel(localStorage.token, model).catch((error) => {
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
await modelfiles.set(await getModelInfos(localStorage.token));
|
await models.set(await getModels(localStorage.token));
|
||||||
};
|
};
|
||||||
|
|
||||||
reader.readAsText(importFiles[0]);
|
reader.readAsText(importFiles[0]);
|
||||||
@ -273,7 +274,7 @@
|
|||||||
<button
|
<button
|
||||||
class="flex text-xs items-center space-x-1 px-3 py-1.5 rounded-xl bg-gray-50 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-700 dark:text-gray-200 transition"
|
class="flex text-xs items-center space-x-1 px-3 py-1.5 rounded-xl bg-gray-50 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-700 dark:text-gray-200 transition"
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
modelfilesImportInputElement.click();
|
modelsImportInputElement.click();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div class=" self-center mr-2 font-medium">{$i18n.t('Import Models')}</div>
|
<div class=" self-center mr-2 font-medium">{$i18n.t('Import Models')}</div>
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
showSettings,
|
showSettings,
|
||||||
settings,
|
settings,
|
||||||
models,
|
models,
|
||||||
modelfiles,
|
|
||||||
prompts,
|
prompts,
|
||||||
documents,
|
documents,
|
||||||
tags,
|
tags,
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
import { toast } from 'svelte-sonner';
|
import { toast } from 'svelte-sonner';
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
import { settings, user, config, modelfiles, models } from '$lib/stores';
|
import { settings, user, config, models } from '$lib/stores';
|
||||||
|
|
||||||
import { onMount, tick, getContext } from 'svelte';
|
import { onMount, tick, getContext } from 'svelte';
|
||||||
import { addNewModel, getModelById, getModelInfos } from '$lib/apis/models';
|
import { addNewModel, getModelById, getModelInfos } from '$lib/apis/models';
|
||||||
|
@ -14,10 +14,10 @@
|
|||||||
].includes(event.origin)
|
].includes(event.origin)
|
||||||
)
|
)
|
||||||
return;
|
return;
|
||||||
const modelfile = JSON.parse(event.data);
|
const model = JSON.parse(event.data);
|
||||||
sessionStorage.modelfile = JSON.stringify(modelfile);
|
sessionStorage.model = JSON.stringify(model);
|
||||||
|
|
||||||
goto('/workspace/modelfiles/create');
|
goto('/workspace/models/create');
|
||||||
});
|
});
|
||||||
|
|
||||||
if (window.opener ?? false) {
|
if (window.opener ?? false) {
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
import { modelfiles, settings, chatId, WEBUI_NAME } from '$lib/stores';
|
import { settings, chatId, WEBUI_NAME, models } from '$lib/stores';
|
||||||
import { convertMessagesToHistory } from '$lib/utils';
|
import { convertMessagesToHistory } from '$lib/utils';
|
||||||
|
|
||||||
import { getChatByShareId } from '$lib/apis/chats';
|
import { getChatByShareId } from '$lib/apis/chats';
|
||||||
@ -14,6 +14,7 @@
|
|||||||
import Navbar from '$lib/components/layout/Navbar.svelte';
|
import Navbar from '$lib/components/layout/Navbar.svelte';
|
||||||
import { getUserById } from '$lib/apis/users';
|
import { getUserById } from '$lib/apis/users';
|
||||||
import { error } from '@sveltejs/kit';
|
import { error } from '@sveltejs/kit';
|
||||||
|
import { getModels } from '$lib/apis';
|
||||||
|
|
||||||
const i18n = getContext('i18n');
|
const i18n = getContext('i18n');
|
||||||
|
|
||||||
@ -27,17 +28,6 @@
|
|||||||
let showModelSelector = false;
|
let showModelSelector = false;
|
||||||
let selectedModels = [''];
|
let selectedModels = [''];
|
||||||
|
|
||||||
let selectedModelfiles = {};
|
|
||||||
$: selectedModelfiles = selectedModels.reduce((a, tagName, i, arr) => {
|
|
||||||
const modelfile =
|
|
||||||
$modelfiles.filter((modelfile) => modelfile.tagName === tagName)?.at(0) ?? undefined;
|
|
||||||
|
|
||||||
return {
|
|
||||||
...a,
|
|
||||||
...(modelfile && { [tagName]: modelfile })
|
|
||||||
};
|
|
||||||
}, {});
|
|
||||||
|
|
||||||
let chat = null;
|
let chat = null;
|
||||||
let user = null;
|
let user = null;
|
||||||
|
|
||||||
@ -69,10 +59,6 @@
|
|||||||
if (await loadSharedChat()) {
|
if (await loadSharedChat()) {
|
||||||
await tick();
|
await tick();
|
||||||
loaded = true;
|
loaded = true;
|
||||||
|
|
||||||
window.setTimeout(() => scrollToBottom(), 0);
|
|
||||||
const chatInput = document.getElementById('chat-textarea');
|
|
||||||
chatInput?.focus();
|
|
||||||
} else {
|
} else {
|
||||||
await goto('/');
|
await goto('/');
|
||||||
}
|
}
|
||||||
@ -84,6 +70,7 @@
|
|||||||
//////////////////////////
|
//////////////////////////
|
||||||
|
|
||||||
const loadSharedChat = async () => {
|
const loadSharedChat = async () => {
|
||||||
|
await models.set(await getModels(localStorage.token));
|
||||||
await chatId.set($page.params.id);
|
await chatId.set($page.params.id);
|
||||||
chat = await getChatByShareId(localStorage.token, $chatId).catch(async (error) => {
|
chat = await getChatByShareId(localStorage.token, $chatId).catch(async (error) => {
|
||||||
await goto('/');
|
await goto('/');
|
||||||
@ -168,7 +155,6 @@
|
|||||||
chatId={$chatId}
|
chatId={$chatId}
|
||||||
readOnly={true}
|
readOnly={true}
|
||||||
{selectedModels}
|
{selectedModels}
|
||||||
{selectedModelfiles}
|
|
||||||
{processing}
|
{processing}
|
||||||
bind:history
|
bind:history
|
||||||
bind:messages
|
bind:messages
|
||||||
|
Loading…
Reference in New Issue
Block a user