mirror of
https://github.com/open-webui/pipelines
synced 2025-06-26 18:15:58 +00:00
refac: on_valves_update hook added
This commit is contained in:
5
main.py
5
main.py
@@ -268,18 +268,19 @@ async def update_valves(pipeline_id: str, form_data: dict):
|
||||
|
||||
pipeline_module = PIPELINE_MODULES[pipeline_id]
|
||||
|
||||
await pipeline_module.on_shutdown()
|
||||
try:
|
||||
ValvesModel = pipeline_module.valves.__class__
|
||||
valves = ValvesModel(**form_data)
|
||||
pipeline_module.valves = valves
|
||||
|
||||
if hasattr(pipeline_module, "on_valves_update"):
|
||||
await pipeline_module.on_valves_update()
|
||||
except Exception as e:
|
||||
print(e)
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
detail=f"{str(e)}",
|
||||
)
|
||||
await pipeline_module.on_startup()
|
||||
|
||||
return pipeline_module.valves
|
||||
|
||||
|
||||
Reference in New Issue
Block a user