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
da4586f2
"...git@developer.sourcefind.cn:chenpangpang/open-webui.git" did not exist on "14fb5a9b5c91dbbf472e2a1c19c5795ee6acc0b2"
Commit
da4586f2
authored
Jun 09, 2024
by
Timothy J. Baek
Browse files
refac: task models
parent
591cd993
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
86 additions
and
15 deletions
+86
-15
src/lib/apis/index.ts
src/lib/apis/index.ts
+61
-0
src/lib/components/admin/Settings/Interface.svelte
src/lib/components/admin/Settings/Interface.svelte
+25
-15
No files found.
src/lib/apis/index.ts
View file @
da4586f2
...
@@ -104,6 +104,67 @@ export const chatCompleted = async (token: string, body: ChatCompletedForm) => {
...
@@ -104,6 +104,67 @@ export const chatCompleted = async (token: string, body: ChatCompletedForm) => {
return
res
;
return
res
;
};
};
export
const
getTaskConfig
=
async
(
token
:
string
=
''
)
=>
{
let
error
=
null
;
const
res
=
await
fetch
(
`
${
WEBUI_BASE_URL
}
/api/task/config`
,
{
method
:
'
GET
'
,
headers
:
{
Accept
:
'
application/json
'
,
'
Content-Type
'
:
'
application/json
'
,
...(
token
&&
{
authorization
:
`Bearer
${
token
}
`
})
}
})
.
then
(
async
(
res
)
=>
{
if
(
!
res
.
ok
)
throw
await
res
.
json
();
return
res
.
json
();
})
.
catch
((
err
)
=>
{
console
.
log
(
err
);
error
=
err
;
return
null
;
});
if
(
error
)
{
throw
error
;
}
return
res
;
};
export
const
updateTaskConfig
=
async
(
token
:
string
,
config
:
object
)
=>
{
let
error
=
null
;
const
res
=
await
fetch
(
`
${
WEBUI_BASE_URL
}
/api/task/config/update`
,
{
method
:
'
POST
'
,
headers
:
{
Accept
:
'
application/json
'
,
'
Content-Type
'
:
'
application/json
'
,
...(
token
&&
{
authorization
:
`Bearer
${
token
}
`
})
},
body
:
JSON
.
stringify
(
config
)
})
.
then
(
async
(
res
)
=>
{
if
(
!
res
.
ok
)
throw
await
res
.
json
();
return
res
.
json
();
})
.
catch
((
err
)
=>
{
console
.
log
(
err
);
if
(
'
detail
'
in
err
)
{
error
=
err
.
detail
;
}
else
{
error
=
err
;
}
return
null
;
});
if
(
error
)
{
throw
error
;
}
return
res
;
};
export
const
generateTitle
=
async
(
export
const
generateTitle
=
async
(
token
:
string
=
''
,
token
:
string
=
''
,
model
:
string
,
model
:
string
,
...
...
src/lib/components/admin/Settings/Interface.svelte
View file @
da4586f2
...
@@ -2,7 +2,7 @@
...
@@ -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 { getBackendConfig } from '$lib/apis';
import { getBackendConfig
, getTaskConfig, updateTaskConfig
} from '$lib/apis';
import { setDefaultPromptSuggestions } from '$lib/apis/configs';
import { setDefaultPromptSuggestions } from '$lib/apis/configs';
import { config, models, settings, user } from '$lib/stores';
import { config, models, settings, user } from '$lib/stores';
import { createEventDispatcher, onMount, getContext } from 'svelte';
import { createEventDispatcher, onMount, getContext } from 'svelte';
...
@@ -19,26 +19,27 @@
...
@@ -19,26 +19,27 @@
const i18n = getContext('i18n');
const i18n = getContext('i18n');
let taskModel = '';
let taskConfig = {
let taskModelExternal = '';
TASK_MODEL: '',
TASK_MODEL_EXTERNAL: '',
let titleGenerationPrompt = '';
TITLE_GENERATION_PROMPT_TEMPLATE: '',
SEARCH_QUERY_GENERATION_PROMPT_TEMPLATE: ''
};
let promptSuggestions = [];
let promptSuggestions = [];
let banners: Banner[] = [];
let banners: Banner[] = [];
const updateInterfaceHandler = async () => {
const updateInterfaceHandler = async () => {
taskConfig = await updateTaskConfig(localStorage.token, taskConfig);
promptSuggestions = await setDefaultPromptSuggestions(localStorage.token, promptSuggestions);
promptSuggestions = await setDefaultPromptSuggestions(localStorage.token, promptSuggestions);
await updateBanners();
await updateBanners();
await config.set(await getBackendConfig());
await config.set(await getBackendConfig());
};
};
onMount(async () => {
onMount(async () => {
taskModel = $settings?.title?.model ?? '';
taskConfig = await getTaskConfig(localStorage.token);
taskModelExternal = $settings?.title?.modelExternal ?? '';
titleGenerationPrompt =
$settings?.title?.prompt ??
`Create a concise, 3-5 word phrase as a header for the following query, strictly adhering to the 3-5 word limit and avoiding the use of the word 'title': {{prompt}}`;
promptSuggestions = $config?.default_prompt_suggestions;
promptSuggestions = $config?.default_prompt_suggestions;
...
@@ -57,7 +58,7 @@
...
@@ -57,7 +58,7 @@
dispatch('save');
dispatch('save');
}}
}}
>
>
<div class=" overflow-y-scroll scrollbar-hidden h-full">
<div class=" overflow-y-scroll scrollbar-hidden h-full
pr-1.5
">
<div>
<div>
<div class=" mb-2.5 text-sm font-medium flex">
<div class=" mb-2.5 text-sm font-medium flex">
<div class=" mr-1">{$i18n.t('Set Task Model')}</div>
<div class=" mr-1">{$i18n.t('Set Task Model')}</div>
...
@@ -87,7 +88,7 @@
...
@@ -87,7 +88,7 @@
<div class=" text-xs mb-1">{$i18n.t('Local Models')}</div>
<div class=" text-xs mb-1">{$i18n.t('Local Models')}</div>
<select
<select
class="w-full rounded-lg py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-850 outline-none"
class="w-full rounded-lg py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-850 outline-none"
bind:value={task
Model
}
bind:value={task
Config.TASK_MODEL
}
placeholder={$i18n.t('Select a model')}
placeholder={$i18n.t('Select a model')}
>
>
<option value="" selected>{$i18n.t('Current Model')}</option>
<option value="" selected>{$i18n.t('Current Model')}</option>
...
@@ -103,7 +104,7 @@
...
@@ -103,7 +104,7 @@
<div class=" text-xs mb-1">{$i18n.t('External Models')}</div>
<div class=" text-xs mb-1">{$i18n.t('External Models')}</div>
<select
<select
class="w-full rounded-lg py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-850 outline-none"
class="w-full rounded-lg py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-850 outline-none"
bind:value={task
ModelExternal
}
bind:value={task
Config.TASK_MODEL_EXTERNAL
}
placeholder={$i18n.t('Select a model')}
placeholder={$i18n.t('Select a model')}
>
>
<option value="" selected>{$i18n.t('Current Model')}</option>
<option value="" selected>{$i18n.t('Current Model')}</option>
...
@@ -119,9 +120,18 @@
...
@@ -119,9 +120,18 @@
<div class="mt-3">
<div class="mt-3">
<div class=" mb-2.5 text-sm font-medium">{$i18n.t('Title Generation Prompt')}</div>
<div class=" mb-2.5 text-sm font-medium">{$i18n.t('Title Generation Prompt')}</div>
<textarea
<textarea
bind:value={titleGenerationPrompt}
bind:value={taskConfig.TITLE_GENERATION_PROMPT_TEMPLATE}
class="w-full rounded-lg p-4 text-sm dark:text-gray-300 dark:bg-gray-850 outline-none resize-none"
rows="6"
/>
</div>
<div class="mt-3">
<div class=" mb-2.5 text-sm font-medium">{$i18n.t('Search Query Generation Prompt')}</div>
<textarea
bind:value={taskConfig.SEARCH_QUERY_GENERATION_PROMPT_TEMPLATE}
class="w-full rounded-lg p-4 text-sm dark:text-gray-300 dark:bg-gray-850 outline-none resize-none"
class="w-full rounded-lg p-4 text-sm dark:text-gray-300 dark:bg-gray-850 outline-none resize-none"
rows="
3
"
rows="
6
"
/>
/>
</div>
</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