diff --git a/backend/main.py b/backend/main.py index 2de27111d..f3d8371b0 100644 --- a/backend/main.py +++ b/backend/main.py @@ -477,6 +477,7 @@ async def get_pipeline_valves(pipeline_id: str, user=Depends(get_admin_user)): if pipeline_id in app.state.MODELS and "pipeline" in app.state.MODELS[pipeline_id]: pipeline = app.state.MODELS[pipeline_id] + r = None try: urlIdx = pipeline["urlIdx"] @@ -495,12 +496,23 @@ async def get_pipeline_valves(pipeline_id: str, user=Depends(get_admin_user)): # Handle connection error here print(f"Connection error: {e}") + detail = "Pipeline not found" + + if r is not None: + try: + res = r.json() + if "detail" in res: + detail = res["detail"] + except: + pass + raise HTTPException( - status_code=status.HTTP_404_NOT_FOUND, - detail="Pipeline not found", + status_code=( + r.status_code if r is not None else status.HTTP_404_NOT_FOUND + ), + detail=detail, ) - return {"data": pipeline["pipeline"]["valves"]} else: raise HTTPException( status_code=status.HTTP_404_NOT_FOUND, @@ -514,6 +526,7 @@ async def get_pipeline_valves_spec(pipeline_id: str, user=Depends(get_admin_user if pipeline_id in app.state.MODELS and "pipeline" in app.state.MODELS[pipeline_id]: pipeline = app.state.MODELS[pipeline_id] + r = None try: urlIdx = pipeline["urlIdx"] @@ -532,12 +545,21 @@ async def get_pipeline_valves_spec(pipeline_id: str, user=Depends(get_admin_user # Handle connection error here print(f"Connection error: {e}") - raise HTTPException( - status_code=status.HTTP_404_NOT_FOUND, - detail="Pipeline not found", - ) + detail = "Pipeline not found" + if r is not None: + try: + res = r.json() + if "detail" in res: + detail = res["detail"] + except: + pass - return {"data": pipeline["pipeline"]["valves"]} + raise HTTPException( + status_code=( + r.status_code if r is not None else status.HTTP_404_NOT_FOUND + ), + detail=detail, + ) else: raise HTTPException( status_code=status.HTTP_404_NOT_FOUND, @@ -554,6 +576,7 @@ async def update_pipeline_valves( if pipeline_id in app.state.MODELS and "pipeline" in app.state.MODELS[pipeline_id]: pipeline = app.state.MODELS[pipeline_id] + r = None try: urlIdx = pipeline["urlIdx"] @@ -576,9 +599,21 @@ async def update_pipeline_valves( # Handle connection error here print(f"Connection error: {e}") + detail = "Pipeline not found" + + if r is not None: + try: + res = r.json() + if "detail" in res: + detail = res["detail"] + except: + pass + raise HTTPException( - status_code=status.HTTP_404_NOT_FOUND, - detail="Pipeline not found", + status_code=( + r.status_code if r is not None else status.HTTP_404_NOT_FOUND + ), + detail=detail, ) else: raise HTTPException( diff --git a/src/lib/apis/index.ts b/src/lib/apis/index.ts index 9850581f9..ffa5c6bbb 100644 --- a/src/lib/apis/index.ts +++ b/src/lib/apis/index.ts @@ -156,7 +156,12 @@ export const updatePipelineValves = async ( }) .catch((err) => { console.log(err); - error = err; + + if ('detail' in err) { + error = err.detail; + } else { + error = err; + } return null; }); diff --git a/src/lib/components/admin/Settings/Pipelines.svelte b/src/lib/components/admin/Settings/Pipelines.svelte index 3680e3621..dda33d055 100644 --- a/src/lib/components/admin/Settings/Pipelines.svelte +++ b/src/lib/components/admin/Settings/Pipelines.svelte @@ -1,43 +1,63 @@
{ - saveHandler(); + updateHandler(); }} >
@@ -47,17 +67,30 @@ {$i18n.t('Pipelines')}
-
+
{#if pipelines.length > 0}
@@ -66,11 +99,45 @@
{$i18n.t('Valves')}
-
+
{#if pipelines[selectedPipelineIdx].pipeline.valves} {#if valves} - {#each Object.keys(valves) as valve, idx} -
{valve}
+ {#each Object.keys(valves_spec.properties) as property, idx} +
+
+
+ {valves_spec.properties[property].title} +
+ + +
+ + {#if (valves[property] ?? null) !== null} +
+
+ +
+
+ {/if} +
{/each} {:else} diff --git a/src/lib/components/admin/SettingsModal.svelte b/src/lib/components/admin/SettingsModal.svelte index 6da1bda6f..78f48cdfc 100644 --- a/src/lib/components/admin/SettingsModal.svelte +++ b/src/lib/components/admin/SettingsModal.svelte @@ -185,35 +185,30 @@ {#if selectedTab === 'general'} { - show = false; toast.success($i18n.t('Settings saved successfully!')); }} /> {:else if selectedTab === 'users'} { - show = false; toast.success($i18n.t('Settings saved successfully!')); }} /> {:else if selectedTab === 'db'} { - show = false; toast.success($i18n.t('Settings saved successfully!')); }} /> {:else if selectedTab === 'banners'} { - show = false; toast.success($i18n.t('Settings saved successfully!')); }} /> {:else if selectedTab === 'pipelines'} { - show = false; toast.success($i18n.t('Settings saved successfully!')); }} />