diff --git a/src/main/java/com/ioa/IoASystem.java b/src/main/java/com/ioa/IoASystem.java index 5d7bee4..febcebe 100644 --- a/src/main/java/com/ioa/IoASystem.java +++ b/src/main/java/com/ioa/IoASystem.java @@ -155,9 +155,9 @@ public class IoASystem { // Create all tasks List tasks = Arrays.asList( - // new Task("task1", "Plan a weekend trip to Paris", - // Arrays.asList("travel", "booking"), - // Arrays.asList("bookTravel", "findRestaurants", "getWeather")), + new Task("task1", "Plan a weekend trip to Paris", + Arrays.asList("travel", "booking"), + Arrays.asList("bookTravel", "findRestaurants", "getWeather"))//, // new Task("task2", "Organize a corporate team-building event in New York", // Arrays.asList("event planning", "team management"), // Arrays.asList("findRestaurants", "bookTravel", "scheduleAppointment")), @@ -174,9 +174,9 @@ public class IoASystem { // Arrays.asList("travel", "family planning"), // Arrays.asList("bookTravel", "calculateDistance", "getWeather", "findRestaurants")), - new Task("task7", "Organize an international tech conference with virtual and in-person components", - Arrays.asList("event planning", "tech expertise", "marketing", "travel coordination", "content creation"), - Arrays.asList("scheduleAppointment", "webSearch", "bookTravel", "getWeather", "findRestaurants", "getNewsUpdates"))//, + // new Task("task7", "Organize an international tech conference with virtual and in-person components", + // Arrays.asList("event planning", "tech expertise", "marketing", "travel coordination", "content creation"), + // Arrays.asList("scheduleAppointment", "webSearch", "bookTravel", "getWeather", "findRestaurants", "getNewsUpdates"))//, // new Task("task8", "Develop and launch a multi-lingual mobile app for sustainable tourism", // Arrays.asList("software development", "travel", "language expertise", "environmental science", "user experience design"), @@ -235,7 +235,7 @@ public class IoASystem { // Wait for all agents to complete their tasks try { - latch.await(5, TimeUnit.MINUTES); // Wait for up to 5 minutes + latch.await(40, TimeUnit.MINUTES); // Wait for up to 5 minutes } catch (InterruptedException e) { e.printStackTrace(); } diff --git a/src/main/java/com/ioa/conversation/ConversationManager.java b/src/main/java/com/ioa/conversation/ConversationManager.java index 7228efe..e2782ff 100644 --- a/src/main/java/com/ioa/conversation/ConversationManager.java +++ b/src/main/java/com/ioa/conversation/ConversationManager.java @@ -67,7 +67,7 @@ public class ConversationManager { if (!conversation.isFinished()) { conversation.finish("Time limit reached"); } - }, 10, TimeUnit.MINUTES); + }, 40, TimeUnit.MINUTES); } } diff --git a/src/main/java/com/ioa/task/TaskManager.java b/src/main/java/com/ioa/task/TaskManager.java index 705ccd4..8f8fd64 100644 --- a/src/main/java/com/ioa/task/TaskManager.java +++ b/src/main/java/com/ioa/task/TaskManager.java @@ -53,7 +53,7 @@ public class TaskManager { if (reasoning == null || reasoning.isEmpty()) { System.out.println("WARNING: Empty execution plan generated for task: " + taskId); - reasoning = "No execution plan generated."; + reasoning = "No execution plan generated. Proceeding with a general approach to organize execution plan."; } conversationManager.postMessage(conversationId, agent.getId(), "Task execution plan:\n" + reasoning); @@ -61,22 +61,22 @@ public class TaskManager { String executionPrompt = "Based on this execution plan:\n" + reasoning + "\nExecute the task using the available tools and provide the result."; Map executionResult = treeOfThought.reason(executionPrompt, 1, 1); - String response = (String) executionResult.get("response"); + String response = (String) executionResult.get("reasoning"); if (response == null || response.isEmpty()) { System.out.println("WARNING: Empty response generated for task execution: " + taskId); - response = "No response generated."; + response = "Unable to execute the task due to technical difficulties. Please try again or seek assistance."; } String result = executeToolsFromResponse(response, agent); + if (result == null || result.isEmpty()) { + result = "No specific actions were taken based on the execution plan. Please review the plan and provide more detailed instructions if necessary."; + } + task.setResult(result); - if (result != null && !result.isEmpty()) { - conversationManager.postMessage(conversationId, agent.getId(), "Task result: " + result); - } else { - conversationManager.postMessage(conversationId, agent.getId(), "Task completed, but no result was generated."); - } + conversationManager.postMessage(conversationId, agent.getId(), "Task result: " + result); } private String executeToolsFromResponse(String response, AgentInfo agent) { diff --git a/src/main/java/com/ioa/util/TreeOfThought.java b/src/main/java/com/ioa/util/TreeOfThought.java index b9be837..164a86a 100644 --- a/src/main/java/com/ioa/util/TreeOfThought.java +++ b/src/main/java/com/ioa/util/TreeOfThought.java @@ -22,7 +22,11 @@ public class TreeOfThought { webSocketService.sendUpdate("tree_of_thought", treeData); String reasoning = formatReasoning(treeData); System.out.println("DEBUG: Reasoning result: " + reasoning); - return treeData; + + Map result = new HashMap<>(); + result.put("reasoning", reasoning); + result.put("treeData", treeData); + return result; } private Map exploreThought(String task, int depth, int branches, String nodeName) { @@ -41,8 +45,12 @@ public class TreeOfThought { "\nExplore a new branch of thought (branch " + (i+1) + "/" + branches + "):"; String thought = model.generate(branchPrompt, null); - Map childNode = exploreThought(task, depth - 1, branches, thought); - children.add(childNode); + if (!thought.equals("No response generated") && !thought.startsWith("Error:")) { + Map childNode = exploreThought(task, depth - 1, branches, thought); + children.add(childNode); + } else { + System.out.println("WARNING: Failed to generate thought. Result: " + thought); + } } node.put("children", children); diff --git a/target/classes/com/ioa/IoASystem.class b/target/classes/com/ioa/IoASystem.class index 6a0836c..93d8cbc 100644 Binary files a/target/classes/com/ioa/IoASystem.class and b/target/classes/com/ioa/IoASystem.class differ diff --git a/target/classes/com/ioa/conversation/ConversationManager.class b/target/classes/com/ioa/conversation/ConversationManager.class index 4de5c4e..07f856f 100644 Binary files a/target/classes/com/ioa/conversation/ConversationManager.class and b/target/classes/com/ioa/conversation/ConversationManager.class differ diff --git a/target/classes/com/ioa/task/TaskManager.class b/target/classes/com/ioa/task/TaskManager.class index 88cbcb1..0ec154f 100644 Binary files a/target/classes/com/ioa/task/TaskManager.class and b/target/classes/com/ioa/task/TaskManager.class differ diff --git a/target/classes/com/ioa/util/TreeOfThought.class b/target/classes/com/ioa/util/TreeOfThought.class index cdbfc3d..72c0c5f 100644 Binary files a/target/classes/com/ioa/util/TreeOfThought.class and b/target/classes/com/ioa/util/TreeOfThought.class differ