Working version with increased timeout and slight messaging improvements
This commit is contained in:
parent
1634dfcdc5
commit
6eadf28c66
|
@ -155,9 +155,9 @@ public class IoASystem {
|
|||
|
||||
// Create all tasks
|
||||
List<Task> 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();
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ public class ConversationManager {
|
|||
if (!conversation.isFinished()) {
|
||||
conversation.finish("Time limit reached");
|
||||
}
|
||||
}, 10, TimeUnit.MINUTES);
|
||||
}, 40, TimeUnit.MINUTES);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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<String, Object> 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) {
|
||||
|
|
|
@ -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<String, Object> result = new HashMap<>();
|
||||
result.put("reasoning", reasoning);
|
||||
result.put("treeData", treeData);
|
||||
return result;
|
||||
}
|
||||
|
||||
private Map<String, Object> 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<String, Object> childNode = exploreThought(task, depth - 1, branches, thought);
|
||||
children.add(childNode);
|
||||
if (!thought.equals("No response generated") && !thought.startsWith("Error:")) {
|
||||
Map<String, Object> 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);
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user