diff --git a/backend/apps/openai/main.py b/backend/apps/openai/main.py index 29c1573088..9bf76818fd 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 f85ea789d0..9f358b90c5 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 016a708f57..6cc3d54051 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 c620bd7992..7be08e69c5 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} -