feat: valves full integration

This commit is contained in:
Timothy J. Baek
2024-05-28 13:05:31 -07:00
parent 7c271734a1
commit 2d596d7307
4 changed files with 138 additions and 36 deletions

View File

@@ -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(