Various beans and context updates to protect from null pointer exceptions

This commit is contained in:
Mahesh Kommareddi 2024-07-16 23:57:27 -04:00
parent 44cced45e3
commit be0ed8f22d
14 changed files with 67 additions and 18 deletions

View File

@ -11,8 +11,8 @@ const TreeOfThoughtVisual = ({ data }) => {
const svg = d3.select(svgRef.current);
svg.selectAll("*").remove();
const width = 800;
const height = 600;
const width = 1920;
const height = 1080;
const margin = { top: 20, right: 90, bottom: 30, left: 90 };
const treeLayout = d3.tree().size([height - margin.top - margin.bottom, width - margin.left - margin.right]);

View File

@ -70,7 +70,11 @@ public class IoASystem {
public static void main(String[] args) {
ConfigurableApplicationContext context = SpringApplication.run(IoASystem.class, args);
IoASystem system = context.getBean(IoASystem.class);
system.processTasksAndAgents(context);
}
public void processTasksAndAgents(ConfigurableApplicationContext context) {
AgentRegistry agentRegistry = context.getBean(AgentRegistry.class);
TeamFormation teamFormation = context.getBean(TeamFormation.class);
TaskManager taskManager = context.getBean(TaskManager.class);

View File

@ -5,7 +5,6 @@ import org.springframework.stereotype.Service;
@Service
public class WebSocketService {
private final SimpMessagingTemplate messagingTemplate;
public WebSocketService(SimpMessagingTemplate messagingTemplate) {
@ -13,6 +12,10 @@ public class WebSocketService {
}
public void sendUpdate(String topic, Object payload) {
if (payload != null) {
messagingTemplate.convertAndSend("/topic/" + topic, payload);
} else {
System.out.println("Warning: Attempted to send null payload to topic: " + topic);
}
}
}

View File

@ -2,12 +2,9 @@ package com.ioa.team;
import com.ioa.agent.AgentInfo;
import com.ioa.agent.AgentRegistry;
import com.ioa.model.BedrockLanguageModel;
import com.ioa.task.Task;
import com.ioa.util.TreeOfThought;
import com.ioa.service.WebSocketService;
import org.springframework.stereotype.Component;
import java.util.*;
@ -40,17 +37,22 @@ public class TeamFormation {
String reasoning = treeOfThought.reason(teamFormationTask, 3, 2);
// Send update about the reasoning process
if (reasoning != null && !reasoning.isEmpty()) {
webSocketService.sendUpdate("team_formation_reasoning", reasoning);
}
List<AgentInfo> team = parseTeamComposition(reasoning, potentialAgents);
// Send update about the formed team
if (team != null && !team.isEmpty()) {
webSocketService.sendUpdate("team_formed", team);
}
return team;
}
private String formatAgentTools(List<AgentInfo> agents) {
return agents.stream()
.map(agent -> agent.getId() + " (capabilities: " + agent.getCapabilities() + ", tools: " + agent.getTools() + ")")

View File

@ -4,10 +4,7 @@ import com.ioa.model.BedrockLanguageModel;
import com.ioa.service.WebSocketService;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
@Component
public class TreeOfThought {
@ -22,7 +19,7 @@ public class TreeOfThought {
public String reason(String task, int depth, int branches) {
Map<String, Object> treeData = exploreThought(task, depth, branches, "Root");
webSocketService.sendUpdate("tree_of_thought", treeData);
return (String) treeData.get("selection");
return (String) treeData.getOrDefault("selection", "No selection made");
}
private Map<String, Object> exploreThought(String task, int depth, int branches, String nodeName) {

View File

@ -1,15 +1,15 @@
{
"files": {
"main.css": "/static/css/main.e6c13ad2.css",
"main.js": "/static/js/main.1af137e7.js",
"main.js": "/static/js/main.03144112.js",
"static/js/453.d855a71b.chunk.js": "/static/js/453.d855a71b.chunk.js",
"index.html": "/index.html",
"main.e6c13ad2.css.map": "/static/css/main.e6c13ad2.css.map",
"main.1af137e7.js.map": "/static/js/main.1af137e7.js.map",
"main.03144112.js.map": "/static/js/main.03144112.js.map",
"453.d855a71b.chunk.js.map": "/static/js/453.d855a71b.chunk.js.map"
},
"entrypoints": [
"static/css/main.e6c13ad2.css",
"static/js/main.1af137e7.js"
"static/js/main.03144112.js"
]
}

View File

@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>React App</title><script defer="defer" src="/static/js/main.1af137e7.js"></script><link href="/static/css/main.e6c13ad2.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>React App</title><script defer="defer" src="/static/js/main.03144112.js"></script><link href="/static/css/main.e6c13ad2.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,39 @@
/**
* @license React
* react-dom.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/**
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/**
* @license React
* react.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/**
* @license React
* scheduler.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

File diff suppressed because one or more lines are too long