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
e1edf922
Commit
e1edf922
authored
Jun 09, 2024
by
Timothy J. Baek
Browse files
feat: model knowledge ui
parent
a8d70910
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
82 additions
and
10 deletions
+82
-10
src/lib/components/workspace/Models/Knowledge.svelte
src/lib/components/workspace/Models/Knowledge.svelte
+38
-0
src/routes/(app)/workspace/models/create/+page.svelte
src/routes/(app)/workspace/models/create/+page.svelte
+21
-6
src/routes/(app)/workspace/models/edit/+page.svelte
src/routes/(app)/workspace/models/edit/+page.svelte
+23
-4
No files found.
src/lib/components/workspace/Models/Knowledge.svelte
0 → 100644
View file @
e1edf922
<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>
src/routes/(app)/workspace/models/create/+page.svelte
View file @
e1edf922
...
@@ -11,6 +11,7 @@
...
@@ -11,6 +11,7 @@
import AdvancedParams from '$lib/components/chat/Settings/Advanced/AdvancedParams.svelte';
import AdvancedParams from '$lib/components/chat/Settings/Advanced/AdvancedParams.svelte';
import Checkbox from '$lib/components/common/Checkbox.svelte';
import Checkbox from '$lib/components/common/Checkbox.svelte';
import Tags from '$lib/components/common/Tags.svelte';
import Tags from '$lib/components/common/Tags.svelte';
import Knowledge from '$lib/components/workspace/Models/Knowledge.svelte';
const i18n = getContext('i18n');
const i18n = getContext('i18n');
...
@@ -30,11 +31,6 @@
...
@@ -30,11 +31,6 @@
let id = '';
let id = '';
let name = '';
let name = '';
let params = {};
let capabilities = {
vision: true
};
let info = {
let info = {
id: '',
id: '',
base_model_id: null,
base_model_id: null,
...
@@ -53,6 +49,13 @@
...
@@ -53,6 +49,13 @@
}
}
};
};
let params = {};
let capabilities = {
vision: true
};
let knowledge = [];
$: if (name) {
$: if (name) {
id = name.replace(/\s+/g, '-').toLowerCase();
id = name.replace(/\s+/g, '-').toLowerCase();
}
}
...
@@ -77,8 +80,16 @@
...
@@ -77,8 +80,16 @@
info.id = id;
info.id = id;
info.name = name;
info.name = name;
info.meta.capabilities = capabilities;
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) => {
Object.keys(info.params).forEach((key) => {
if (info.params[key] === '' || info.params[key] === null) {
if (info.params[key] === '' || info.params[key] === null) {
delete info.params[key];
delete info.params[key];
...
@@ -536,6 +547,10 @@
...
@@ -536,6 +547,10 @@
{/if}
{/if}
</div>
</div>
<div class="my-2">
<Knowledge bind:knowledge />
</div>
<div class="my-1">
<div class="my-1">
<div class="flex w-full justify-between mb-1">
<div class="flex w-full justify-between mb-1">
<div class=" self-center text-sm font-semibold">{$i18n.t('Capabilities')}</div>
<div class=" self-center text-sm font-semibold">{$i18n.t('Capabilities')}</div>
...
...
src/routes/(app)/workspace/models/edit/+page.svelte
View file @
e1edf922
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
import
{
getModels
}
from
'$lib/apis'
;
import
{
getModels
}
from
'$lib/apis'
;
import
Checkbox
from
'$lib/components/common/Checkbox.svelte'
;
import
Checkbox
from
'$lib/components/common/Checkbox.svelte'
;
import
Tags
from
'$lib/components/common/Tags.svelte'
;
import
Tags
from
'$lib/components/common/Tags.svelte'
;
import
Knowledge
from
'$lib/components/workspace/Models/Knowledge.svelte'
;
const
i18n
=
getContext
(
'i18n'
);
const
i18n
=
getContext
(
'i18n'
);
...
@@ -54,19 +55,28 @@
...
@@ -54,19 +55,28 @@
};
};
let
params
=
{};
let
params
=
{};
let
capabilities
=
{
let
capabilities
=
{
vision
:
true
vision
:
true
};
};
let
knowledge
=
[];
const
updateHandler
=
async
()
=>
{
const
updateHandler
=
async
()
=>
{
loading
=
true
;
loading
=
true
;
info
.
id
=
id
;
info
.
id
=
id
;
info
.
name
=
name
;
info
.
name
=
name
;
info
.
meta
.
capabilities
=
capabilities
;
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
)
=>
{
Object
.
keys
(
info
.
params
).
forEach
((
key
)
=>
{
if
(
info
.
params
[
key
]
===
''
||
info
.
params
[
key
]
===
null
)
{
if
(
info
.
params
[
key
]
===
''
||
info
.
params
[
key
]
===
null
)
{
delete
info
.
params
[
key
];
delete
info
.
params
[
key
];
...
@@ -119,6 +129,10 @@
...
@@ -119,6 +129,10 @@
)
)
:
null
;
:
null
;
if
(
model
?.
info
?.
meta
?.
knowledge
)
{
knowledge
=
[...
model
?.
info
?.
meta
?.
knowledge
];
}
if
(
model
?.
owned_by
===
'openai'
)
{
if
(
model
?.
owned_by
===
'openai'
)
{
capabilities
.
usage
=
false
;
capabilities
.
usage
=
false
;
}
}
...
@@ -126,6 +140,7 @@
...
@@ -126,6 +140,7 @@
if
(
model
?.
info
?.
meta
?.
capabilities
)
{
if
(
model
?.
info
?.
meta
?.
capabilities
)
{
capabilities
=
{
...
capabilities
,
...
model
?.
info
?.
meta
?.
capabilities
};
capabilities
=
{
...
capabilities
,
...
model
?.
info
?.
meta
?.
capabilities
};
}
}
console
.
log
(
model
);
console
.
log
(
model
);
}
else
{
}
else
{
goto
(
'/workspace/models'
);
goto
(
'/workspace/models'
);
...
@@ -405,7 +420,7 @@
...
@@ -405,7 +420,7 @@
<
hr
class
=
" dark:border-gray-850 my-1"
/>
<
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
=
"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
>
<
div
class
=
" self-center text-sm font-semibold"
>{$
i18n
.
t
(
'Prompt suggestions'
)}</
div
>
...
@@ -495,7 +510,11 @@
...
@@ -495,7 +510,11 @@
{/
if
}
{/
if
}
</
div
>
</
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
=
"flex w-full justify-between mb-1"
>
<
div
class
=
" self-center text-sm font-semibold"
>{$
i18n
.
t
(
'Capabilities'
)}</
div
>
<
div
class
=
" self-center text-sm font-semibold"
>{$
i18n
.
t
(
'Capabilities'
)}</
div
>
</
div
>
</
div
>
...
...
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