AI UI-Designer & ToolGenerator: Added ErrorHandling

This commit is contained in:
Manas Hejmadi
2025-05-04 04:03:03 +05:30
parent 1057e07241
commit c6c0391b66
3 changed files with 102 additions and 31 deletions

View File

@@ -37,7 +37,7 @@ class _GenerateToolDialogState extends ConsumerState<GenerateToolDialog> {
setState(() {
generatedToolCode = null;
});
final x = await APIDashAgentCaller.instance.call(
final toolfuncRes = await APIDashAgentCaller.instance.call(
APIToolFunctionGenerator(),
ref: ref,
input: AgentInputs(variables: {
@@ -45,19 +45,22 @@ class _GenerateToolDialogState extends ConsumerState<GenerateToolDialog> {
'TARGET_LANGUAGE': selectedLanguage,
}),
);
if (x == null) {
if (toolfuncRes == null) {
setState(() {
generatedToolCode = '';
});
print("ToolGeneration Failed"); //TODO: Make Alert
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(
"API Tool generation failed!",
style: TextStyle(color: Colors.white),
),
backgroundColor: Colors.redAccent,
));
return;
}
String toolCode = x!['FUNC'];
String toolCode = toolfuncRes!['FUNC'];
print(toolCode);
//TODO: Integrate into tool
final toolres = await APIDashAgentCaller.instance.call(
ApiToolBodyGen(),
ref: ref,
@@ -71,7 +74,13 @@ class _GenerateToolDialogState extends ConsumerState<GenerateToolDialog> {
setState(() {
generatedToolCode = '';
});
print("ToolGeneration Failed"); //TODO: Make Alert
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(
"API Tool generation failed!",
style: TextStyle(color: Colors.white),
),
backgroundColor: Colors.redAccent,
));
return;
}
String toolDefinition = toolres!['TOOL'];