From 4715160b53cb29297ce257b8576a3b496b8bc7b4 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Wed, 29 May 2024 22:41:51 -0700 Subject: [PATCH] fix: pipelines --- backend/apps/openai/main.py | 5 +- backend/main.py | 10 +- src/lib/apis/index.ts | 8 +- .../admin/Settings/Pipelines.svelte | 343 +++++++++--------- 4 files changed, 185 insertions(+), 181 deletions(-) diff --git a/backend/apps/openai/main.py b/backend/apps/openai/main.py index 29c157308..9bf76818f 100644 --- a/backend/apps/openai/main.py +++ b/backend/apps/openai/main.py @@ -219,7 +219,7 @@ def merge_models_lists(model_lists): return merged_list -async def get_all_models(): +async def get_all_models(raw: bool = False): log.info("get_all_models()") if ( @@ -236,6 +236,9 @@ async def get_all_models(): responses = await asyncio.gather(*tasks) log.debug(f"get_all_models:responses() {responses}") + if raw: + return responses + models = { "data": merge_models_lists( list( diff --git a/backend/main.py b/backend/main.py index f85ea789d..9f358b90c 100644 --- a/backend/main.py +++ b/backend/main.py @@ -466,8 +466,10 @@ async def get_models(user=Depends(get_verified_user)): @app.get("/api/pipelines/list") async def get_pipelines_list(user=Depends(get_admin_user)): - models = await get_all_models() - urlIdxs = list(set([model["urlIdx"] for model in models if "pipeline" in model])) + responses = await get_openai_models(raw=True) + + print(responses) + urlIdxs = [idx for idx, response in enumerate(responses) if "pipelines" in response] return { "data": [ @@ -716,9 +718,7 @@ async def update_pipeline_valves( pass raise HTTPException( - status_code=( - r.status_code if r is not None else status.HTTP_404_NOT_FOUND - ), + status_code=(r.status_code if r is not None else status.HTTP_404_NOT_FOUND), detail=detail, ) diff --git a/src/lib/apis/index.ts b/src/lib/apis/index.ts index 016a708f5..6cc3d5405 100644 --- a/src/lib/apis/index.ts +++ b/src/lib/apis/index.ts @@ -154,7 +154,7 @@ export const getPipelines = async (token: string, urlIdx?: string) => { let error = null; const searchParams = new URLSearchParams(); - if (urlIdx) { + if (urlIdx !== undefined) { searchParams.append('urlIdx', urlIdx); } @@ -188,7 +188,7 @@ export const getPipelineValves = async (token: string, pipeline_id: string, urlI let error = null; const searchParams = new URLSearchParams(); - if (urlIdx) { + if (urlIdx !== undefined) { searchParams.append('urlIdx', urlIdx); } @@ -224,7 +224,7 @@ export const getPipelineValvesSpec = async (token: string, pipeline_id: string, let error = null; const searchParams = new URLSearchParams(); - if (urlIdx) { + if (urlIdx !== undefined) { searchParams.append('urlIdx', urlIdx); } @@ -265,7 +265,7 @@ export const updatePipelineValves = async ( let error = null; const searchParams = new URLSearchParams(); - if (urlIdx) { + if (urlIdx !== undefined) { searchParams.append('urlIdx', urlIdx); } diff --git a/src/lib/components/admin/Settings/Pipelines.svelte b/src/lib/components/admin/Settings/Pipelines.svelte index c620bd799..7be08e69c 100644 --- a/src/lib/components/admin/Settings/Pipelines.svelte +++ b/src/lib/components/admin/Settings/Pipelines.svelte @@ -90,6 +90,7 @@ valves_spec = null; if (PIPELINES_LIST.length > 0) { + console.log(selectedPipelinesUrlIdx); pipelines = await getPipelines(localStorage.token, selectedPipelinesUrlIdx); if (pipelines.length > 0) { @@ -143,10 +144,10 @@ console.log(PIPELINES_LIST); if (PIPELINES_LIST.length > 0) { - selectedPipelinesUrlIdx = PIPELINES_LIST[0]['idx']; + selectedPipelinesUrlIdx = PIPELINES_LIST[0]['idx'].toString(); } - setPipelines(); + await setPipelines(); }); @@ -182,7 +183,7 @@ > {#each PIPELINES_LIST as pipelines, idx} - {/each} @@ -190,187 +191,187 @@ - {/if} -
-
- {$i18n.t('Install from Github URL')} -
-
-
- +
+
+ {$i18n.t('Install from Github URL')}
- -
-
- -
- - {#if pipelines !== null} - {#if pipelines.length > 0} -
-
- {$i18n.t('Pipelines Valves')} +
+
+
-
-
- {#if pipelines.length > 0} -
-
- -
- - -
- {/if} - -
- {#if pipelines[selectedPipelineIdx].valves} - {#if valves} - {#each Object.keys(valves_spec.properties) as property, idx} -
-
-
- {valves_spec.properties[property].title} -
- - -
- - {#if (valves[property] ?? null) !== null} -
-
- -
-
- {/if} -
- {/each} - {:else} - - {/if} +
{:else} -
No valves
+ + + + {/if} -
-
- {:else if pipelines.length === 0} -
Pipelines Not Detected
- {/if} - {:else} -
-
- +
+ +
+ + {#if pipelines !== null} + {#if pipelines.length > 0} +
+
+ {$i18n.t('Pipelines Valves')} +
+
+
+ {#if pipelines.length > 0} +
+
+ +
+ + +
+ {/if} + +
+ {#if pipelines[selectedPipelineIdx].valves} + {#if valves} + {#each Object.keys(valves_spec.properties) as property, idx} +
+
+
+ {valves_spec.properties[property].title} +
+ + +
+ + {#if (valves[property] ?? null) !== null} +
+
+ +
+
+ {/if} +
+ {/each} + {:else} + + {/if} + {:else} +
No valves
+ {/if} +
+
+ {:else if pipelines.length === 0} +
Pipelines Not Detected
+ {/if} + {:else} +
+
+ +
+
+ {/if} {/if} {:else}