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
0bef1b44
"src/git@developer.sourcefind.cn:chenpangpang/open-webui.git" did not exist on "62f67bed292ae27fec9e63e1ead1c80355319d4b"
Commit
0bef1b44
authored
May 28, 2024
by
Timothy J. Baek
Browse files
feat: pipeline valves
parent
0383efa2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
129 additions
and
0 deletions
+129
-0
backend/main.py
backend/main.py
+7
-0
src/lib/apis/index.ts
src/lib/apis/index.ts
+29
-0
src/lib/components/admin/Settings/Pipelines.svelte
src/lib/components/admin/Settings/Pipelines.svelte
+55
-0
src/lib/components/admin/SettingsModal.svelte
src/lib/components/admin/SettingsModal.svelte
+38
-0
No files found.
backend/main.py
View file @
0bef1b44
...
@@ -464,6 +464,13 @@ async def get_models(user=Depends(get_verified_user)):
...
@@ -464,6 +464,13 @@ async def get_models(user=Depends(get_verified_user)):
return
{
"data"
:
models
}
return
{
"data"
:
models
}
@
app
.
get
(
"/api/pipelines"
)
async
def
get_pipelines
(
user
=
Depends
(
get_admin_user
)):
models
=
await
get_all_models
()
pipelines
=
[
model
for
model
in
models
if
"pipeline"
in
model
]
return
{
"data"
:
pipelines
}
@
app
.
get
(
"/api/config"
)
@
app
.
get
(
"/api/config"
)
async
def
get_app_config
():
async
def
get_app_config
():
# Checking and Handling the Absence of 'ui' in CONFIG_DATA
# Checking and Handling the Absence of 'ui' in CONFIG_DATA
...
...
src/lib/apis/index.ts
View file @
0bef1b44
...
@@ -49,6 +49,35 @@ export const getModels = async (token: string = '') => {
...
@@ -49,6 +49,35 @@ export const getModels = async (token: string = '') => {
return
models
;
return
models
;
};
};
export
const
getPipelines
=
async
(
token
:
string
=
''
)
=>
{
let
error
=
null
;
const
res
=
await
fetch
(
`
${
WEBUI_BASE_URL
}
/api/pipelines`
,
{
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
;
}
let
pipelines
=
res
?.
data
??
[];
return
pipelines
;
};
export
const
getBackendConfig
=
async
()
=>
{
export
const
getBackendConfig
=
async
()
=>
{
let
error
=
null
;
let
error
=
null
;
...
...
src/lib/components/admin/Settings/Pipelines.svelte
0 → 100644
View file @
0bef1b44
<script lang="ts">
import { v4 as uuidv4 } from 'uuid';
import { getContext, onMount } from 'svelte';
import { models } from '$lib/stores';
import type { Writable } from 'svelte/store';
import type { i18n as i18nType } from 'i18next';
import Tooltip from '$lib/components/common/Tooltip.svelte';
import Switch from '$lib/components/common/Switch.svelte';
import { stringify } from 'postcss';
import { getPipelines } from '$lib/apis';
const i18n: Writable<i18nType> = getContext('i18n');
export let saveHandler: Function;
let pipelines = [];
let selectedPipelineIdx = 0;
onMount(async () => {
pipelines = await getPipelines(localStorage.token);
});
</script>
<form
class="flex flex-col h-full justify-between space-y-3 text-sm"
on:submit|preventDefault={async () => {
saveHandler();
}}
>
<div class=" space-y-3 pr-1.5 overflow-y-scroll max-h-80 h-full">
<div class=" space-y-3 pr-1.5">
<div class="flex w-full justify-between mb-2">
<div class=" self-center text-sm font-semibold">
{$i18n.t('Pipeline Valves')}
</div>
</div>
<div class="flex flex-col space-y-1">
{#each pipelines as pipeline}
<div class=" flex justify-between">
{JSON.stringify(pipeline)}
</div>
{/each}
</div>
</div>
</div>
<div class="flex justify-end pt-3 text-sm font-medium">
<button
class=" px-4 py-2 bg-emerald-700 hover:bg-emerald-800 text-gray-100 transition rounded-lg"
type="submit"
>
Save
</button>
</div>
</form>
src/lib/components/admin/SettingsModal.svelte
View file @
0bef1b44
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
import Banners from '$lib/components/admin/Settings/Banners.svelte';
import Banners from '$lib/components/admin/Settings/Banners.svelte';
import { toast } from 'svelte-sonner';
import { toast } from 'svelte-sonner';
import Pipelines from './Settings/Pipelines.svelte';
const i18n = getContext('i18n');
const i18n = getContext('i18n');
...
@@ -149,6 +150,36 @@
...
@@ -149,6 +150,36 @@
</div>
</div>
<div class=" self-center">{$i18n.t('Banners')}</div>
<div class=" self-center">{$i18n.t('Banners')}</div>
</button>
</button>
<button
class="px-2.5 py-2.5 min-w-fit rounded-lg flex-1 md:flex-none flex text-right transition {selectedTab ===
'pipelines'
? 'bg-gray-200 dark:bg-gray-700'
: ' hover:bg-gray-300 dark:hover:bg-gray-800'}"
on:click={() => {
selectedTab = 'pipelines';
}}
>
<div class=" self-center mr-2">
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="currentColor"
class="size-4"
>
<path
d="M11.644 1.59a.75.75 0 0 1 .712 0l9.75 5.25a.75.75 0 0 1 0 1.32l-9.75 5.25a.75.75 0 0 1-.712 0l-9.75-5.25a.75.75 0 0 1 0-1.32l9.75-5.25Z"
/>
<path
d="m3.265 10.602 7.668 4.129a2.25 2.25 0 0 0 2.134 0l7.668-4.13 1.37.739a.75.75 0 0 1 0 1.32l-9.75 5.25a.75.75 0 0 1-.71 0l-9.75-5.25a.75.75 0 0 1 0-1.32l1.37-.738Z"
/>
<path
d="m10.933 19.231-7.668-4.13-1.37.739a.75.75 0 0 0 0 1.32l9.75 5.25c.221.12.489.12.71 0l9.75-5.25a.75.75 0 0 0 0-1.32l-1.37-.738-7.668 4.13a2.25 2.25 0 0 1-2.134-.001Z"
/>
</svg>
</div>
<div class=" self-center">{$i18n.t('Pipelines')}</div>
</button>
</div>
</div>
<div class="flex-1 md:min-h-[380px]">
<div class="flex-1 md:min-h-[380px]">
{#if selectedTab === 'general'}
{#if selectedTab === 'general'}
...
@@ -179,6 +210,13 @@
...
@@ -179,6 +210,13 @@
toast.success($i18n.t('Settings saved successfully!'));
toast.success($i18n.t('Settings saved successfully!'));
}}
}}
/>
/>
{:else if selectedTab === 'pipelines'}
<Pipelines
saveHandler={() => {
show = false;
toast.success($i18n.t('Settings saved successfully!'));
}}
/>
{/if}
{/if}
</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