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
4715160b
"...git@developer.sourcefind.cn:chenpangpang/open-webui.git" did not exist on "1091ee5a9b75dd2b796d30bf4c3070b6ca0fb9c1"
Commit
4715160b
authored
May 29, 2024
by
Timothy J. Baek
Browse files
fix: pipelines
parent
7cec88c7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
171 additions
and
167 deletions
+171
-167
backend/apps/openai/main.py
backend/apps/openai/main.py
+4
-1
backend/main.py
backend/main.py
+5
-5
src/lib/apis/index.ts
src/lib/apis/index.ts
+4
-4
src/lib/components/admin/Settings/Pipelines.svelte
src/lib/components/admin/Settings/Pipelines.svelte
+158
-157
No files found.
backend/apps/openai/main.py
View file @
4715160b
...
@@ -219,7 +219,7 @@ def merge_models_lists(model_lists):
...
@@ -219,7 +219,7 @@ def merge_models_lists(model_lists):
return
merged_list
return
merged_list
async
def
get_all_models
():
async
def
get_all_models
(
raw
:
bool
=
False
):
log
.
info
(
"get_all_models()"
)
log
.
info
(
"get_all_models()"
)
if
(
if
(
...
@@ -236,6 +236,9 @@ async def get_all_models():
...
@@ -236,6 +236,9 @@ async def get_all_models():
responses
=
await
asyncio
.
gather
(
*
tasks
)
responses
=
await
asyncio
.
gather
(
*
tasks
)
log
.
debug
(
f
"get_all_models:responses()
{
responses
}
"
)
log
.
debug
(
f
"get_all_models:responses()
{
responses
}
"
)
if
raw
:
return
responses
models
=
{
models
=
{
"data"
:
merge_models_lists
(
"data"
:
merge_models_lists
(
list
(
list
(
...
...
backend/main.py
View file @
4715160b
...
@@ -466,8 +466,10 @@ async def get_models(user=Depends(get_verified_user)):
...
@@ -466,8 +466,10 @@ async def get_models(user=Depends(get_verified_user)):
@
app
.
get
(
"/api/pipelines/list"
)
@
app
.
get
(
"/api/pipelines/list"
)
async
def
get_pipelines_list
(
user
=
Depends
(
get_admin_user
)):
async
def
get_pipelines_list
(
user
=
Depends
(
get_admin_user
)):
models
=
await
get_all_models
()
responses
=
await
get_openai_models
(
raw
=
True
)
urlIdxs
=
list
(
set
([
model
[
"urlIdx"
]
for
model
in
models
if
"pipeline"
in
model
]))
print
(
responses
)
urlIdxs
=
[
idx
for
idx
,
response
in
enumerate
(
responses
)
if
"pipelines"
in
response
]
return
{
return
{
"data"
:
[
"data"
:
[
...
@@ -716,9 +718,7 @@ async def update_pipeline_valves(
...
@@ -716,9 +718,7 @@ async def update_pipeline_valves(
pass
pass
raise
HTTPException
(
raise
HTTPException
(
status_code
=
(
status_code
=
(
r
.
status_code
if
r
is
not
None
else
status
.
HTTP_404_NOT_FOUND
),
r
.
status_code
if
r
is
not
None
else
status
.
HTTP_404_NOT_FOUND
),
detail
=
detail
,
detail
=
detail
,
)
)
...
...
src/lib/apis/index.ts
View file @
4715160b
...
@@ -154,7 +154,7 @@ export const getPipelines = async (token: string, urlIdx?: string) => {
...
@@ -154,7 +154,7 @@ export const getPipelines = async (token: string, urlIdx?: string) => {
let
error
=
null
;
let
error
=
null
;
const
searchParams
=
new
URLSearchParams
();
const
searchParams
=
new
URLSearchParams
();
if
(
urlIdx
)
{
if
(
urlIdx
!==
undefined
)
{
searchParams
.
append
(
'
urlIdx
'
,
urlIdx
);
searchParams
.
append
(
'
urlIdx
'
,
urlIdx
);
}
}
...
@@ -188,7 +188,7 @@ export const getPipelineValves = async (token: string, pipeline_id: string, urlI
...
@@ -188,7 +188,7 @@ export const getPipelineValves = async (token: string, pipeline_id: string, urlI
let
error
=
null
;
let
error
=
null
;
const
searchParams
=
new
URLSearchParams
();
const
searchParams
=
new
URLSearchParams
();
if
(
urlIdx
)
{
if
(
urlIdx
!==
undefined
)
{
searchParams
.
append
(
'
urlIdx
'
,
urlIdx
);
searchParams
.
append
(
'
urlIdx
'
,
urlIdx
);
}
}
...
@@ -224,7 +224,7 @@ export const getPipelineValvesSpec = async (token: string, pipeline_id: string,
...
@@ -224,7 +224,7 @@ export const getPipelineValvesSpec = async (token: string, pipeline_id: string,
let
error
=
null
;
let
error
=
null
;
const
searchParams
=
new
URLSearchParams
();
const
searchParams
=
new
URLSearchParams
();
if
(
urlIdx
)
{
if
(
urlIdx
!==
undefined
)
{
searchParams
.
append
(
'
urlIdx
'
,
urlIdx
);
searchParams
.
append
(
'
urlIdx
'
,
urlIdx
);
}
}
...
@@ -265,7 +265,7 @@ export const updatePipelineValves = async (
...
@@ -265,7 +265,7 @@ export const updatePipelineValves = async (
let
error
=
null
;
let
error
=
null
;
const
searchParams
=
new
URLSearchParams
();
const
searchParams
=
new
URLSearchParams
();
if
(
urlIdx
)
{
if
(
urlIdx
!==
undefined
)
{
searchParams
.
append
(
'
urlIdx
'
,
urlIdx
);
searchParams
.
append
(
'
urlIdx
'
,
urlIdx
);
}
}
...
...
src/lib/components/admin/Settings/Pipelines.svelte
View file @
4715160b
...
@@ -90,6 +90,7 @@
...
@@ -90,6 +90,7 @@
valves_spec = null;
valves_spec = null;
if (PIPELINES_LIST.length > 0) {
if (PIPELINES_LIST.length > 0) {
console.log(selectedPipelinesUrlIdx);
pipelines = await getPipelines(localStorage.token, selectedPipelinesUrlIdx);
pipelines = await getPipelines(localStorage.token, selectedPipelinesUrlIdx);
if (pipelines.length > 0) {
if (pipelines.length > 0) {
...
@@ -143,10 +144,10 @@
...
@@ -143,10 +144,10 @@
console.log(PIPELINES_LIST);
console.log(PIPELINES_LIST);
if (PIPELINES_LIST.length > 0) {
if (PIPELINES_LIST.length > 0) {
selectedPipelinesUrlIdx = PIPELINES_LIST[0]['idx'];
selectedPipelinesUrlIdx = PIPELINES_LIST[0]['idx']
.toString()
;
}
}
setPipelines();
await
setPipelines();
});
});
</script>
</script>
...
@@ -182,7 +183,7 @@
...
@@ -182,7 +183,7 @@
>
>
{#each PIPELINES_LIST as pipelines, idx}
{#each PIPELINES_LIST as pipelines, idx}
<option value={pipelines.idx} class="bg-gray-100 dark:bg-gray-700"
<option value={pipelines.idx
.toString()
} class="bg-gray-100 dark:bg-gray-700"
>{pipelines.url}</option
>{pipelines.url}</option
>
>
{/each}
{/each}
...
@@ -190,187 +191,187 @@
...
@@ -190,187 +191,187 @@
</div>
</div>
</div>
</div>
</div>
</div>
{/if}
<div class=" my-2">
<div class=" my-2">
<div class=" mb-2 text-sm font-medium">
<div class=" mb-2 text-sm font-medium">
{$i18n.t('Install from Github URL')}
{$i18n.t('Install from Github URL')}
</div>
<div class="flex w-full">
<div class="flex-1 mr-2">
<input
class="w-full rounded-lg py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-850 outline-none"
placeholder={$i18n.t('Enter Github Raw URL')}
bind:value={pipelineDownloadUrl}
/>
</div>
</div>
<button
<div class="flex w-full">
class="px-2.5 bg-gray-100 hover:bg-gray-200 text-gray-800 dark:bg-gray-850 dark:hover:bg-gray-800 dark:text-gray-100 rounded-lg transition"
<div class="flex-1 mr-2">
on:click={() => {
<input
addPipelineHandler();
class="w-full rounded-lg py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-850 outline-none"
}}
placeholder={$i18n.t('Enter Github Raw URL')}
disabled={downloading}
bind:value={pipelineDownloadUrl}
type="button"
/>
>
</div>
{#if downloading}
<button
<div class="self-center">
class="px-2.5 bg-gray-100 hover:bg-gray-200 text-gray-800 dark:bg-gray-850 dark:hover:bg-gray-800 dark:text-gray-100 rounded-lg transition"
on:click={() => {
addPipelineHandler();
}}
disabled={downloading}
type="button"
>
{#if downloading}
<div class="self-center">
<svg
class=" w-4 h-4"
viewBox="0 0 24 24"
fill="currentColor"
xmlns="http://www.w3.org/2000/svg"
>
<style>
.spinner_ajPY {
transform-origin: center;
animation: spinner_AtaB 0.75s infinite linear;
}
@keyframes spinner_AtaB {
100% {
transform: rotate(360deg);
}
}
</style>
<path
d="M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"
opacity=".25"
/>
<path
d="M10.14,1.16a11,11,0,0,0-9,8.92A1.59,1.59,0,0,0,2.46,12,1.52,1.52,0,0,0,4.11,10.7a8,8,0,0,1,6.66-6.61A1.42,1.42,0,0,0,12,2.69h0A1.57,1.57,0,0,0,10.14,1.16Z"
class="spinner_ajPY"
/>
</svg>
</div>
{:else}
<svg
<svg
class=" w-4 h-4"
viewBox="0 0 24 24"
fill="currentColor"
xmlns="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 16 16"
fill="currentColor"
class="w-4 h-4"
>
>
<style>
.spinner_ajPY {
transform-origin: center;
animation: spinner_AtaB 0.75s infinite linear;
}
@keyframes spinner_AtaB {
100% {
transform: rotate(360deg);
}
}
</style>
<path
<path
d="M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"
d="M8.75 2.75a.75.75 0 0 0-1.5 0v5.69L5.03 6.22a.75.75 0 0 0-1.06 1.06l3.5 3.5a.75.75 0 0 0 1.06 0l3.5-3.5a.75.75 0 0 0-1.06-1.06L8.75 8.44V2.75Z"
opacity=".25"
/>
/>
<path
<path
d="M10.14,1.16a11,11,0,0,0-9,8.92A1.59,1.59,0,0,0,2.46,12,1.52,1.52,0,0,0,4.11,10.7a8,8,0,0,1,6.66-6.61A1.42,1.42,0,0,0,12,2.69h0A1.57,1.57,0,0,0,10.14,1.16Z"
d="M3.5 9.75a.75.75 0 0 0-1.5 0v1.5A2.75 2.75 0 0 0 4.75 14h6.5A2.75 2.75 0 0 0 14 11.25v-1.5a.75.75 0 0 0-1.5 0v1.5c0 .69-.56 1.25-1.25 1.25h-6.5c-.69 0-1.25-.56-1.25-1.25v-1.5Z"
class="spinner_ajPY"
/>
/>
</svg>
</svg>
</div>
{/if}
{:else}
</button>
<svg
</div>
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 16 16"
fill="currentColor"
class="w-4 h-4"
>
<path
d="M8.75 2.75a.75.75 0 0 0-1.5 0v5.69L5.03 6.22a.75.75 0 0 0-1.06 1.06l3.5 3.5a.75.75 0 0 0 1.06 0l3.5-3.5a.75.75 0 0 0-1.06-1.06L8.75 8.44V2.75Z"
/>
<path
d="M3.5 9.75a.75.75 0 0 0-1.5 0v1.5A2.75 2.75 0 0 0 4.75 14h6.5A2.75 2.75 0 0 0 14 11.25v-1.5a.75.75 0 0 0-1.5 0v1.5c0 .69-.56 1.25-1.25 1.25h-6.5c-.69 0-1.25-.56-1.25-1.25v-1.5Z"
/>
</svg>
{/if}
</button>
</div>
</div>
</div>
<hr class=" dark:border-gray-800 my-3 w-full" />
<hr class=" dark:border-gray-800 my-3 w-full" />
{#if pipelines !== null}
{#if pipelines !== null}
{#if pipelines.length > 0}
{#if pipelines.length > 0}
<div class="flex w-full justify-between mb-2">
<div class="flex w-full justify-between mb-2">
<div class=" self-center text-sm font-semibold">
<div class=" self-center text-sm font-semibold">
{$i18n.t('Pipelines Valves')}
{$i18n.t('Pipelines Valves')}
</div>
</div>
</div>
</div>
<div class="space-y-1">
<div class="space-y-1">
{#if pipelines.length > 0}
{#if pipelines.length > 0}
<div class="flex gap-2">
<div class="flex gap-2">
<div class="flex-1">
<div class="flex-1">
<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={selectedPipelineIdx}
bind:value={selectedPipelineIdx}
placeholder={$i18n.t('Select a pipeline')}
placeholder={$i18n.t('Select a pipeline')}
on:change={async () => {
on:change={async () => {
await tick();
await tick();
await getValves(selectedPipelineIdx);
await getValves(selectedPipelineIdx);
}}
>
{#each pipelines as pipeline, idx}
<option value={idx} class="bg-gray-100 dark:bg-gray-700"
>{pipeline.name} ({pipeline.type ?? 'pipe'})</option
>
{/each}
</select>
</div>
<button
class="px-2.5 bg-gray-100 hover:bg-gray-200 text-gray-800 dark:bg-gray-850 dark:hover:bg-gray-800 dark:text-gray-100 rounded-lg transition"
on:click={() => {
deletePipelineHandler();
}}
}}
type="button"
>
>
{#each pipelines as pipeline, idx}
<svg
<option value={idx} class="bg-gray-100 dark:bg-gray-700"
xmlns="http://www.w3.org/2000/svg"
>{pipeline.name} ({pipeline.type ?? 'pipe'})</option
viewBox="0 0 16 16"
>
fill="currentColor"
{/each}
class="w-4 h-4"
</select>
>
<path
fill-rule="evenodd"
d="M5 3.25V4H2.75a.75.75 0 0 0 0 1.5h.3l.815 8.15A1.5 1.5 0 0 0 5.357 15h5.285a1.5 1.5 0 0 0 1.493-1.35l.815-8.15h.3a.75.75 0 0 0 0-1.5H11v-.75A2.25 2.25 0 0 0 8.75 1h-1.5A2.25 2.25 0 0 0 5 3.25Zm2.25-.75a.75.75 0 0 0-.75.75V4h3v-.75a.75.75 0 0 0-.75-.75h-1.5ZM6.05 6a.75.75 0 0 1 .787.713l.275 5.5a.75.75 0 0 1-1.498.075l-.275-5.5A.75.75 0 0 1 6.05 6Zm3.9 0a.75.75 0 0 1 .712.787l-.275 5.5a.75.75 0 0 1-1.498-.075l.275-5.5a.75.75 0 0 1 .786-.711Z"
clip-rule="evenodd"
/>
</svg>
</button>
</div>
</div>
{/if}
<button
<div class="space-y-1">
class="px-2.5 bg-gray-100 hover:bg-gray-200 text-gray-800 dark:bg-gray-850 dark:hover:bg-gray-800 dark:text-gray-100 rounded-lg transition"
{#if pipelines[selectedPipelineIdx].valves}
on:click={() => {
{#if valves}
deletePipelineHandler();
{#each Object.keys(valves_spec.properties) as property, idx}
}}
<div class=" py-0.5 w-full justify-between">
type="button"
<div class="flex w-full justify-between">
>
<div class=" self-center text-xs font-medium">
<svg
{valves_spec.properties[property].title}
xmlns="http://www.w3.org/2000/svg"
</div>
viewBox="0 0 16 16"
fill="currentColor"
class="w-4 h-4"
>
<path
fill-rule="evenodd"
d="M5 3.25V4H2.75a.75.75 0 0 0 0 1.5h.3l.815 8.15A1.5 1.5 0 0 0 5.357 15h5.285a1.5 1.5 0 0 0 1.493-1.35l.815-8.15h.3a.75.75 0 0 0 0-1.5H11v-.75A2.25 2.25 0 0 0 8.75 1h-1.5A2.25 2.25 0 0 0 5 3.25Zm2.25-.75a.75.75 0 0 0-.75.75V4h3v-.75a.75.75 0 0 0-.75-.75h-1.5ZM6.05 6a.75.75 0 0 1 .787.713l.275 5.5a.75.75 0 0 1-1.498.075l-.275-5.5A.75.75 0 0 1 6.05 6Zm3.9 0a.75.75 0 0 1 .712.787l-.275 5.5a.75.75 0 0 1-1.498-.075l.275-5.5a.75.75 0 0 1 .786-.711Z"
clip-rule="evenodd"
/>
</svg>
</button>
</div>
{/if}
<div class="space-y-1">
<button
{#if pipelines[selectedPipelineIdx].valves}
class="p-1 px-3 text-xs flex rounded transition"
{#if valves}
type="button"
{#each Object.keys(valves_spec.properties) as property, idx}
on:click={() => {
<div class=" py-0.5 w-full justify-between">
valves[property] = (valves[property] ?? null) === null ? '' : null;
<div class="flex w-full justify-between">
}}
<div class=" self-center text-xs font-medium">
>
{valves_spec.properties[property].title}
{#if (valves[property] ?? null) === null}
<span class="ml-2 self-center"> {$i18n.t('None')} </span>
{:else}
<span class="ml-2 self-center"> {$i18n.t('Custom')} </span>
{/if}
</button>
</div>
</div>
<button
{#if (valves[property] ?? null) !== null}
class="p-1 px-3 text-xs flex rounded transition"
<div class="flex mt-0.5 space-x-2">
type="button"
<div class=" flex-1">
on:click={() => {
<input
valves[property] = (valves[property] ?? null) === null ? '' : null;
class="w-full rounded-lg py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-850 outline-none"
}}
type="text"
>
placeholder={valves_spec.properties[property].title}
{#if (valves[property] ?? null) === null}
bind:value={valves[property]}
<span class="ml-2 self-center"> {$i18n.t('None')} </span>
autocomplete="off"
{:else}
/>
<span class="ml-2 self-center"> {$i18n.t('Custom')} </span>
</div>
{/if}
</button>
</div>
{#if (valves[property] ?? null) !== null}
<div class="flex mt-0.5 space-x-2">
<div class=" flex-1">
<input
class="w-full rounded-lg py-2 px-4 text-sm dark:text-gray-300 dark:bg-gray-850 outline-none"
type="text"
placeholder={valves_spec.properties[property].title}
bind:value={valves[property]}
autocomplete="off"
/>
</div>
</div>
</div>
{/if}
{/if}
</div>
</div>
{/each}
{/each}
{:else}
<Spinner className="size-5" />
{/if}
{:else}
{:else}
<
Spinner className="size-5" /
>
<
div>No valves</div
>
{/if}
{/if}
{:else}
</div>
<div>No valves</div>
</div>
{/if}
{:else if pipelines.length === 0}
<div>Pipelines Not Detected</div>
{/if}
{:else}
<div class="flex justify-center">
<div class="my-auto">
<Spinner className="size-4" />
</div>
</div>
</div>
</div>
{:else if pipelines.length === 0}
<div>Pipelines Not Detected</div>
{/if}
{/if}
{:else}
<div class="flex justify-center">
<div class="my-auto">
<Spinner className="size-4" />
</div>
</div>
{/if}
{/if}
{:else}
{:else}
<div class="flex justify-center h-full">
<div class="flex justify-center h-full">
...
...
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