mirror of
https://github.com/open-webui/open-webui
synced 2024-11-16 21:42:58 +00:00
feat: model knowledge ui
This commit is contained in:
parent
a8d709102f
commit
e1edf9227d
38
src/lib/components/workspace/Models/Knowledge.svelte
Normal file
38
src/lib/components/workspace/Models/Knowledge.svelte
Normal file
@ -0,0 +1,38 @@
|
||||
<script lang="ts">
|
||||
import { getContext } from 'svelte';
|
||||
|
||||
export let knowledge = [];
|
||||
|
||||
const i18n = getContext('i18n');
|
||||
</script>
|
||||
|
||||
<div>
|
||||
<div class="flex w-full justify-between mb-1">
|
||||
<div class=" self-center text-sm font-semibold">{$i18n.t('Knowledge')}</div>
|
||||
</div>
|
||||
|
||||
<div class=" text-xs dark:text-gray-500">
|
||||
To add documents here, upload them to the "Documents" workspace first.
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col">
|
||||
{#if knowledge.length > 0}
|
||||
{#each knowledge as doc}
|
||||
<div class=" flex items-center gap-2">
|
||||
<div class=" py-0.5 text-sm w-full">{doc.name}</div>
|
||||
</div>
|
||||
{/each}
|
||||
{/if}
|
||||
|
||||
<div class="flex flex-wrap text-sm font-medium gap-1.5 mt-2">
|
||||
<button
|
||||
class=" px-3.5 py-1.5 font-medium hover:bg-black/5 dark:hover:bg-white/5 outline outline-1 outline-gray-300 dark:outline-gray-800 rounded-3xl"
|
||||
type="button"
|
||||
on:click={() => {
|
||||
console.log('hi');
|
||||
}}>Select Documents</button
|
||||
>
|
||||
</div>
|
||||
<!-- {knowledge} -->
|
||||
</div>
|
||||
</div>
|
@ -11,6 +11,7 @@
|
||||
import AdvancedParams from '$lib/components/chat/Settings/Advanced/AdvancedParams.svelte';
|
||||
import Checkbox from '$lib/components/common/Checkbox.svelte';
|
||||
import Tags from '$lib/components/common/Tags.svelte';
|
||||
import Knowledge from '$lib/components/workspace/Models/Knowledge.svelte';
|
||||
|
||||
const i18n = getContext('i18n');
|
||||
|
||||
@ -30,11 +31,6 @@
|
||||
let id = '';
|
||||
let name = '';
|
||||
|
||||
let params = {};
|
||||
let capabilities = {
|
||||
vision: true
|
||||
};
|
||||
|
||||
let info = {
|
||||
id: '',
|
||||
base_model_id: null,
|
||||
@ -53,6 +49,13 @@
|
||||
}
|
||||
};
|
||||
|
||||
let params = {};
|
||||
let capabilities = {
|
||||
vision: true
|
||||
};
|
||||
|
||||
let knowledge = [];
|
||||
|
||||
$: if (name) {
|
||||
id = name.replace(/\s+/g, '-').toLowerCase();
|
||||
}
|
||||
@ -77,8 +80,16 @@
|
||||
info.id = id;
|
||||
info.name = name;
|
||||
info.meta.capabilities = capabilities;
|
||||
info.params.stop = params.stop ? params.stop.split(',').filter((s) => s.trim()) : null;
|
||||
|
||||
if (knowledge.length > 0) {
|
||||
info.meta.knowledge = knowledge;
|
||||
} else {
|
||||
if (info.meta.knowledge) {
|
||||
delete info.meta.knowledge;
|
||||
}
|
||||
}
|
||||
|
||||
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];
|
||||
@ -536,6 +547,10 @@
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class="my-2">
|
||||
<Knowledge bind:knowledge />
|
||||
</div>
|
||||
|
||||
<div class="my-1">
|
||||
<div class="flex w-full justify-between mb-1">
|
||||
<div class=" self-center text-sm font-semibold">{$i18n.t('Capabilities')}</div>
|
||||
|
@ -14,6 +14,7 @@
|
||||
import { getModels } from '$lib/apis';
|
||||
import Checkbox from '$lib/components/common/Checkbox.svelte';
|
||||
import Tags from '$lib/components/common/Tags.svelte';
|
||||
import Knowledge from '$lib/components/workspace/Models/Knowledge.svelte';
|
||||
|
||||
const i18n = getContext('i18n');
|
||||
|
||||
@ -54,19 +55,28 @@
|
||||
};
|
||||
|
||||
let params = {};
|
||||
|
||||
let capabilities = {
|
||||
vision: true
|
||||
};
|
||||
|
||||
let knowledge = [];
|
||||
|
||||
const updateHandler = async () => {
|
||||
loading = true;
|
||||
|
||||
info.id = id;
|
||||
info.name = name;
|
||||
info.meta.capabilities = capabilities;
|
||||
info.params.stop = params.stop ? params.stop.split(',').filter((s) => s.trim()) : null;
|
||||
|
||||
if (knowledge.length > 0) {
|
||||
info.meta.knowledge = knowledge;
|
||||
} else {
|
||||
if (info.meta.knowledge) {
|
||||
delete info.meta.knowledge;
|
||||
}
|
||||
}
|
||||
|
||||
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];
|
||||
@ -119,6 +129,10 @@
|
||||
)
|
||||
: null;
|
||||
|
||||
if (model?.info?.meta?.knowledge) {
|
||||
knowledge = [...model?.info?.meta?.knowledge];
|
||||
}
|
||||
|
||||
if (model?.owned_by === 'openai') {
|
||||
capabilities.usage = false;
|
||||
}
|
||||
@ -126,6 +140,7 @@
|
||||
if (model?.info?.meta?.capabilities) {
|
||||
capabilities = { ...capabilities, ...model?.info?.meta?.capabilities };
|
||||
}
|
||||
|
||||
console.log(model);
|
||||
} else {
|
||||
goto('/workspace/models');
|
||||
@ -405,7 +420,7 @@
|
||||
|
||||
<hr class=" dark:border-gray-850 my-1" />
|
||||
|
||||
<div class="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>
|
||||
@ -495,7 +510,11 @@
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class="my-1">
|
||||
<div class="my-2">
|
||||
<Knowledge bind:knowledge />
|
||||
</div>
|
||||
|
||||
<div class="my-2">
|
||||
<div class="flex w-full justify-between mb-1">
|
||||
<div class=" self-center text-sm font-semibold">{$i18n.t('Capabilities')}</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user