refac/enh: function valves validation

This commit is contained in:
Timothy Jaeryang Baek
2025-09-16 12:00:59 -05:00
parent fed5615c19
commit e66e0526ed
2 changed files with 70 additions and 45 deletions
+10
View File
@@ -148,6 +148,16 @@ async def sync_functions(
content=function.content,
)
if hasattr(function_module, "Valves") and function.valves:
Valves = function_module.Valves
try:
Valves(**{k: v for k, v in function.valves if v is not None})
except Exception as e:
log.exception(
f"Error validating valves for function {function.id}: {e}"
)
raise e
return Functions.sync_functions(user.id, form_data.functions)
except Exception as e:
log.exception(f"Failed to load a function: {e}")