Fancy frontend to work with the websockets

This commit is contained in:
Mahesh Kommareddi 2024-07-16 23:30:16 -04:00
parent 6ca5c28d7a
commit 9983a530a5
51 changed files with 19745 additions and 55 deletions

23
frontend/.gitignore vendored Normal file
View File

@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*

70
frontend/README.md Normal file
View File

@ -0,0 +1,70 @@
# Getting Started with Create React App
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
## Available Scripts
In the project directory, you can run:
### `npm start`
Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
The page will reload when you make changes.\
You may also see any lint errors in the console.
### `npm test`
Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
### `npm run build`
Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
### `npm run eject`
**Note: this is a one-way operation. Once you `eject`, you can't go back!**
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
## Learn More
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
To learn React, check out the [React documentation](https://reactjs.org/).
### Code Splitting
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
### Analyzing the Bundle Size
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
### Making a Progressive Web App
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
### Advanced Configuration
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
### Deployment
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
### `npm run build` fails to minify
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)

18903
frontend/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

42
frontend/package.json Normal file
View File

@ -0,0 +1,42 @@
{
"name": "frontend",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"d3": "^7.9.0",
"net": "^1.0.2",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-scripts": "5.0.1",
"sockjs-client": "^1.6.1",
"stompjs": "^2.3.3",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}

BIN
frontend/public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/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="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>

BIN
frontend/public/logo192.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

BIN
frontend/public/logo512.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

View File

@ -0,0 +1,25 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}

View File

@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:

38
frontend/src/App.css Normal file
View File

@ -0,0 +1,38 @@
.App {
text-align: center;
}
.App-logo {
height: 40vmin;
pointer-events: none;
}
@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}
.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}
.App-link {
color: #61dafb;
}
@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}

54
frontend/src/App.js Normal file
View File

@ -0,0 +1,54 @@
// src/App.js
import React, { useEffect, useState } from 'react';
import { connectWebSocket, subscribeToTopic } from './services/websocket';
import AgentNetworkGraph from './components/AgentNetworkGraph';
import ConversationStateDiagram from './components/ConversationStateDiagram';
import TaskProgressIndicator from './components/TaskProgressIndicator';
import TreeOfThoughtVisual from './components/TreeOfThoughtVisual';
function App() {
const [agentNetwork, setAgentNetwork] = useState(null);
const [conversationState, setConversationState] = useState({ currentState: '', possibleTransitions: [] });
const [taskProgress, setTaskProgress] = useState({ taskId: '', status: '', progressPercentage: 0 });
const [treeOfThought, setTreeOfThought] = useState(null);
useEffect(() => {
connectWebSocket(() => {
subscribeToTopic('agent_network', setAgentNetwork);
subscribeToTopic('conversation_state', setConversationState);
subscribeToTopic('task_progress', setTaskProgress);
subscribeToTopic('tree_of_thought', setTreeOfThought);
});
}, []);
return (
<div className="App">
<h1>IoA Dashboard</h1>
<div>
<h2>Agent Network</h2>
{agentNetwork && <AgentNetworkGraph data={agentNetwork} />}
</div>
<div>
<h2>Conversation State</h2>
<ConversationStateDiagram
currentState={conversationState.currentState}
possibleTransitions={conversationState.possibleTransitions}
/>
</div>
<div>
<h2>Task Progress</h2>
<TaskProgressIndicator
taskId={taskProgress.taskId}
status={taskProgress.status}
progressPercentage={taskProgress.progressPercentage}
/>
</div>
<div>
<h2>Tree of Thought</h2>
{treeOfThought && <TreeOfThoughtVisual data={treeOfThought} />}
</div>
</div>
);
}
export default App;

8
frontend/src/App.test.js Normal file
View File

@ -0,0 +1,8 @@
import { render, screen } from '@testing-library/react';
import App from './App';
test('renders learn react link', () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});

View File

@ -0,0 +1,53 @@
// src/components/AgentNetworkGraph.js
import React, { useEffect, useRef } from 'react';
import * as d3 from 'd3';
const AgentNetworkGraph = ({ data }) => {
const svgRef = useRef();
useEffect(() => {
if (!data) return;
const svg = d3.select(svgRef.current);
const width = 600;
const height = 400;
const simulation = d3.forceSimulation(data.nodes)
.force("link", d3.forceLink(data.links).id(d => d.id))
.force("charge", d3.forceManyBody())
.force("center", d3.forceCenter(width / 2, height / 2));
const link = svg.append("g")
.selectAll("line")
.data(data.links)
.join("line")
.attr("stroke", "#999")
.attr("stroke-opacity", 0.6);
const node = svg.append("g")
.selectAll("circle")
.data(data.nodes)
.join("circle")
.attr("r", 5)
.attr("fill", "#69b3a2");
node.append("title")
.text(d => d.name);
simulation.on("tick", () => {
link
.attr("x1", d => d.source.x)
.attr("y1", d => d.source.y)
.attr("x2", d => d.target.x)
.attr("y2", d => d.target.y);
node
.attr("cx", d => d.x)
.attr("cy", d => d.y);
});
}, [data]);
return <svg ref={svgRef} width="600" height="400" />;
};
export default AgentNetworkGraph;

View File

@ -0,0 +1,60 @@
// src/components/ConversationStateDiagram.js
import React, { useEffect, useRef } from 'react';
import * as d3 from 'd3';
const ConversationStateDiagram = ({ currentState, possibleTransitions }) => {
const svgRef = useRef();
useEffect(() => {
const svg = d3.select(svgRef.current);
svg.selectAll("*").remove();
const width = 400;
const height = 300;
const radius = 50;
const nodes = [currentState, ...possibleTransitions].map((state, index) => ({
id: state,
x: width / 2 + radius * Math.cos(index * 2 * Math.PI / (possibleTransitions.length + 1)),
y: height / 2 + radius * Math.sin(index * 2 * Math.PI / (possibleTransitions.length + 1))
}));
const links = possibleTransitions.map(state => ({
source: currentState,
target: state
}));
svg.selectAll("line")
.data(links)
.enter()
.append("line")
.attr("x1", d => nodes.find(n => n.id === d.source).x)
.attr("y1", d => nodes.find(n => n.id === d.source).y)
.attr("x2", d => nodes.find(n => n.id === d.target).x)
.attr("y2", d => nodes.find(n => n.id === d.target).y)
.attr("stroke", "#999");
svg.selectAll("circle")
.data(nodes)
.enter()
.append("circle")
.attr("cx", d => d.x)
.attr("cy", d => d.y)
.attr("r", 20)
.attr("fill", d => d.id === currentState ? "#69b3a2" : "#ccc");
svg.selectAll("text")
.data(nodes)
.enter()
.append("text")
.attr("x", d => d.x)
.attr("y", d => d.y)
.text(d => d.id)
.attr("text-anchor", "middle")
.attr("dominant-baseline", "central");
}, [currentState, possibleTransitions]);
return <svg ref={svgRef} width="400" height="300" />;
};
export default ConversationStateDiagram;

View File

@ -0,0 +1,25 @@
// src/components/TaskProgressIndicator.js
import React from 'react';
const TaskProgressIndicator = ({ taskId, status, progressPercentage }) => {
return (
<div>
<h3>Task: {taskId}</h3>
<p>Status: {status}</p>
<div style={{ width: '100%', backgroundColor: '#e0e0e0', borderRadius: '5px' }}>
<div
style={{
width: `${progressPercentage}%`,
backgroundColor: '#4CAF50',
height: '20px',
borderRadius: '5px',
transition: 'width 0.5s ease-in-out'
}}
/>
</div>
<p>{progressPercentage}% Complete</p>
</div>
);
};
export default TaskProgressIndicator;

View File

@ -0,0 +1,55 @@
// src/components/TreeOfThoughtVisual.js
import React, { useEffect, useRef } from 'react';
import * as d3 from 'd3';
const TreeOfThoughtVisual = ({ data }) => {
const svgRef = useRef();
useEffect(() => {
if (!data) return;
const svg = d3.select(svgRef.current);
svg.selectAll("*").remove();
const width = 800;
const height = 600;
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]);
const root = d3.hierarchy(data);
const treeData = treeLayout(root);
const g = svg.append("g")
.attr("transform", `translate(${margin.left},${margin.top})`);
const link = g.selectAll(".link")
.data(treeData.links())
.enter().append("path")
.attr("class", "link")
.attr("d", d3.linkHorizontal()
.x(d => d.y)
.y(d => d.x));
const node = g.selectAll(".node")
.data(treeData.descendants())
.enter().append("g")
.attr("class", d => "node" + (d.children ? " node--internal" : " node--leaf"))
.attr("transform", d => `translate(${d.y},${d.x})`);
node.append("circle")
.attr("r", 10)
.style("fill", d => d.data.selected ? "#ff0000" : "#69b3a2");
node.append("text")
.attr("dy", ".35em")
.attr("x", d => d.children ? -13 : 13)
.style("text-anchor", d => d.children ? "end" : "start")
.text(d => d.data.name);
}, [data]);
return <svg ref={svgRef} width="800" height="600" />;
};
export default TreeOfThoughtVisual;

13
frontend/src/index.css Normal file
View File

@ -0,0 +1,13 @@
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}

17
frontend/src/index.js Normal file
View File

@ -0,0 +1,17 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);
// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();

1
frontend/src/logo.svg Normal file
View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3"><g fill="#61DAFB"><path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/><circle cx="420.9" cy="296.5" r="45.7"/><path d="M520.5 78.1z"/></g></svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -0,0 +1,13 @@
const reportWebVitals = onPerfEntry => {
if (onPerfEntry && onPerfEntry instanceof Function) {
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
getCLS(onPerfEntry);
getFID(onPerfEntry);
getFCP(onPerfEntry);
getLCP(onPerfEntry);
getTTFB(onPerfEntry);
});
}
};
export default reportWebVitals;

View File

@ -0,0 +1,17 @@
// src/services/websocket.js
import SockJS from 'sockjs-client';
import Stomp from 'stompjs';
let stompClient = null;
export const connectWebSocket = (onConnect) => {
const socket = new SockJS('/ws');
stompClient = Stomp.over(socket);
stompClient.connect({}, onConnect);
};
export const subscribeToTopic = (topic, callback) => {
stompClient.subscribe(`/topic/${topic}`, (message) => {
callback(JSON.parse(message.body));
});
};

View File

@ -0,0 +1,5 @@
// jest-dom adds custom jest matchers for asserting on DOM nodes.
// allows you to do things like:
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
import '@testing-library/jest-dom';

43
pom.xml
View File

@ -98,6 +98,49 @@
</annotationProcessorPaths> </annotationProcessorPaths>
</configuration> </configuration>
</plugin> </plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>npm-build</id>
<goals>
<goal>exec</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<workingDirectory>${project.basedir}/frontend</workingDirectory>
<executable>npm</executable>
<arguments>
<argument>run</argument>
<argument>build</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<phase>generate-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/classes/static</outputDirectory>
<resources>
<resource>
<directory>${project.basedir}/frontend/build</directory>
<filtering>false</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins> </plugins>
</build> </build>

View File

@ -92,32 +92,32 @@ public class IoASystem {
// Create all tasks // Create all tasks
List<Task> tasks = Arrays.asList( List<Task> tasks = Arrays.asList(
new Task("task1", "Plan a weekend trip to Paris", // new Task("task1", "Plan a weekend trip to Paris",
Arrays.asList("travel", "booking"), // Arrays.asList("travel", "booking"),
Arrays.asList("bookTravel", "findRestaurants", "getWeather")), // Arrays.asList("bookTravel", "findRestaurants", "getWeather")),
new Task("task2", "Organize a corporate team-building event in New York", // new Task("task2", "Organize a corporate team-building event in New York",
Arrays.asList("event planning", "team management"), // Arrays.asList("event planning", "team management"),
Arrays.asList("findRestaurants", "bookTravel", "scheduleAppointment")), // Arrays.asList("findRestaurants", "bookTravel", "scheduleAppointment")),
new Task("task3", "Develop a personalized fitness and nutrition plan", // new Task("task3", "Develop a personalized fitness and nutrition plan",
Arrays.asList("health", "nutrition"), // Arrays.asList("health", "nutrition"),
Arrays.asList("getWeather", "findFitnessClasses", "getRecipe")), // Arrays.asList("getWeather", "findFitnessClasses", "getRecipe")),
new Task("task4", "Research and summarize recent advancements in renewable energy", // new Task("task4", "Research and summarize recent advancements in renewable energy",
Arrays.asList("research", "writing"), // Arrays.asList("research", "writing"),
Arrays.asList("webSearch", "getNewsUpdates", "translate")), // Arrays.asList("webSearch", "getNewsUpdates", "translate")),
new Task("task5", "Plan and execute a social media marketing campaign for a new product launch", // new Task("task5", "Plan and execute a social media marketing campaign for a new product launch",
Arrays.asList("marketing", "social media"), // Arrays.asList("marketing", "social media"),
Arrays.asList("webSearch", "getNewsUpdates", "scheduleAppointment")), // Arrays.asList("webSearch", "getNewsUpdates", "scheduleAppointment")),
new Task("task6", "Assist in planning a multi-city European vacation for a family of four", // new Task("task6", "Assist in planning a multi-city European vacation for a family of four",
Arrays.asList("travel", "family planning"), // Arrays.asList("travel", "family planning"),
Arrays.asList("bookTravel", "calculateDistance", "getWeather", "findRestaurants")), // Arrays.asList("bookTravel", "calculateDistance", "getWeather", "findRestaurants")),
new Task("task7", "Organize an international tech conference with virtual and in-person components", // 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("event planning", "tech expertise", "marketing", "travel coordination", "content creation"),
Arrays.asList("scheduleAppointment", "webSearch", "bookTravel", "getWeather", "findRestaurants", "getNewsUpdates")), // Arrays.asList("scheduleAppointment", "webSearch", "bookTravel", "getWeather", "findRestaurants", "getNewsUpdates")),
new Task("task8", "Develop and launch a multi-lingual mobile app for sustainable tourism", // 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"), // Arrays.asList("software development", "travel", "language expertise", "environmental science", "user experience design"),
Arrays.asList("webSearch", "translate", "getWeather", "findRestaurants", "getNewsUpdates", "compareProductPrices")), // Arrays.asList("webSearch", "translate", "getWeather", "findRestaurants", "getNewsUpdates", "compareProductPrices")),
new Task("task9", "Create a comprehensive health and wellness program for a large corporation, including mental health support", new Task("task9", "Create a comprehensive health and wellness program for a large corporation, including mental health support",
Arrays.asList("health", "nutrition", "psychology", "corporate wellness", "data analysis"), Arrays.asList("health", "nutrition", "psychology", "corporate wellness", "data analysis"),

View File

@ -55,6 +55,14 @@ public class TaskManager {
updateTaskProgress(taskId, "COMPLETED", 100); updateTaskProgress(taskId, "COMPLETED", 100);
} }
private void updateTaskProgress(String taskId, String status, int progressPercentage) {
Map<String, Object> progressUpdate = new HashMap<>();
progressUpdate.put("taskId", taskId);
progressUpdate.put("status", status);
progressUpdate.put("progressPercentage", progressPercentage);
webSocketService.sendUpdate("task_progress", progressUpdate);
}
private String executeToolsFromResponse(String response, AgentInfo agent) { private String executeToolsFromResponse(String response, AgentInfo agent) {
StringBuilder result = new StringBuilder(); StringBuilder result = new StringBuilder();
for (String tool : agent.getTools()) { for (String tool : agent.getTools()) {
@ -67,11 +75,6 @@ public class TaskManager {
return result.toString(); return result.toString();
} }
private void updateTaskProgress(String taskId, String status, int progressPercentage) {
TaskProgress progress = new TaskProgress(taskId, status, progressPercentage);
webSocketService.sendUpdate("task_progress", progress);
}
private class TaskProgress { private class TaskProgress {
public String taskId; public String taskId;
public String status; public String status;

View File

@ -5,16 +5,20 @@ import com.ioa.agent.AgentRegistry;
import com.ioa.model.BedrockLanguageModel; import com.ioa.model.BedrockLanguageModel;
import com.ioa.task.Task; import com.ioa.task.Task;
import com.ioa.util.TreeOfThought; import com.ioa.util.TreeOfThought;
import com.ioa.service.WebSocketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Arrays; import java.util.*;
import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Component @Component
public class TeamFormation { public class TeamFormation {
private AgentRegistry agentRegistry; private AgentRegistry agentRegistry;
private TreeOfThought treeOfThought; private TreeOfThought treeOfThought;
@Autowired
private WebSocketService webSocketService;
public TeamFormation(AgentRegistry agentRegistry, BedrockLanguageModel model) { public TeamFormation(AgentRegistry agentRegistry, BedrockLanguageModel model) {
this.agentRegistry = agentRegistry; this.agentRegistry = agentRegistry;
@ -24,10 +28,8 @@ public class TeamFormation {
public List<AgentInfo> formTeam(Task task) { public List<AgentInfo> formTeam(Task task) {
List<String> requiredCapabilities = task.getRequiredCapabilities(); List<String> requiredCapabilities = task.getRequiredCapabilities();
List<String> requiredTools = task.getRequiredTools(); List<String> requiredTools = task.getRequiredTools();
List<AgentInfo> potentialAgents = agentRegistry.searchAgentsPartial(requiredCapabilities); List<AgentInfo> potentialAgents = agentRegistry.searchAgents(requiredCapabilities);
System.out.println("DEBUG: Potential agents: " + potentialAgents);
String teamFormationTask = "Form the best team for this task: " + task.getDescription() + String teamFormationTask = "Form the best team for this task: " + task.getDescription() +
"\nRequired capabilities: " + requiredCapabilities + "\nRequired capabilities: " + requiredCapabilities +
"\nRequired tools: " + requiredTools + "\nRequired tools: " + requiredTools +
@ -36,11 +38,19 @@ public class TeamFormation {
"Conclude with a final team selection in the format: 'Final Team Selection: agent1, agent2, ...'"; "Conclude with a final team selection in the format: 'Final Team Selection: agent1, agent2, ...'";
String reasoning = treeOfThought.reason(teamFormationTask, 3, 2); String reasoning = treeOfThought.reason(teamFormationTask, 3, 2);
System.out.println("DEBUG: Tree of Thought reasoning:\n" + reasoning);
// Send update about the reasoning process
webSocketService.sendUpdate("team_formation_reasoning", reasoning);
return parseTeamComposition(reasoning, potentialAgents); List<AgentInfo> team = parseTeamComposition(reasoning, potentialAgents);
// Send update about the formed team
webSocketService.sendUpdate("team_formed", team);
return team;
} }
private String formatAgentTools(List<AgentInfo> agents) { private String formatAgentTools(List<AgentInfo> agents) {
return agents.stream() return agents.stream()
.map(agent -> agent.getId() + " (capabilities: " + agent.getCapabilities() + ", tools: " + agent.getTools() + ")") .map(agent -> agent.getId() + " (capabilities: " + agent.getCapabilities() + ", tools: " + agent.getTools() + ")")

View File

@ -1,34 +1,60 @@
package com.ioa.util; package com.ioa.util;
import com.ioa.model.BedrockLanguageModel; import com.ioa.model.BedrockLanguageModel;
import com.ioa.service.WebSocketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Component
public class TreeOfThought { public class TreeOfThought {
private final BedrockLanguageModel model; private final BedrockLanguageModel model;
@Autowired
private WebSocketService webSocketService;
public TreeOfThought(BedrockLanguageModel model) { public TreeOfThought(BedrockLanguageModel model) {
this.model = model; this.model = model;
} }
public String reason(String task, int depth, int branches) { public String reason(String task, int depth, int branches) {
return exploreThought(task, depth, branches, ""); Map<String, Object> treeData = exploreThought(task, depth, branches, "Root");
webSocketService.sendUpdate("tree_of_thought", treeData);
return (String) treeData.get("selection");
} }
private String exploreThought(String task, int depth, int branches, String path) { private Map<String, Object> exploreThought(String task, int depth, int branches, String nodeName) {
Map<String, Object> node = new HashMap<>();
node.put("name", nodeName);
if (depth == 0) { if (depth == 0) {
return evaluateLeaf(task, path); String evaluation = evaluateLeaf(task, nodeName);
node.put("evaluation", evaluation);
return node;
} }
StringBuilder result = new StringBuilder(); List<Map<String, Object>> children = new ArrayList<>();
for (int i = 0; i < branches; i++) { for (int i = 0; i < branches; i++) {
String branchPrompt = "Consider the task: " + task + "\nCurrent path: " + path + String branchPrompt = "Consider the task: " + task + "\nCurrent path: " + nodeName +
"\nExplore a new branch of thought (branch " + (i+1) + "/" + branches + "):"; "\nExplore a new branch of thought (branch " + (i+1) + "/" + branches + "):";
String thought = model.generate(branchPrompt, null); String thought = model.generate(branchPrompt, null);
result.append("Branch ").append(i + 1).append(":\n"); Map<String, Object> childNode = exploreThought(task, depth - 1, branches, thought);
result.append(thought).append("\n"); children.add(childNode);
result.append(exploreThought(task, depth - 1, branches, path + " -> " + thought)).append("\n\n");
} }
return result.toString();
node.put("children", children);
if (depth == 1) {
String selection = selectBestBranch(children);
node.put("selection", selection);
}
return node;
} }
private String evaluateLeaf(String task, String path) { private String evaluateLeaf(String task, String path) {
@ -36,7 +62,11 @@ public class TreeOfThought {
return model.generate(prompt, null); return model.generate(prompt, null);
} }
public BedrockLanguageModel getModel() { private String selectBestBranch(List<Map<String, Object>> children) {
return model; // Logic to select the best branch based on evaluations
// For simplicity, let's just select the first child
Map<String, Object> selectedChild = children.get(0);
selectedChild.put("selected", true);
return (String) selectedChild.get("name");
} }
} }

View File

@ -0,0 +1,15 @@
{
"files": {
"main.css": "/static/css/main.e6c13ad2.css",
"main.js": "/static/js/main.1af137e7.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",
"453.d855a71b.chunk.js.map": "/static/js/453.d855a71b.chunk.js.map"
},
"entrypoints": [
"static/css/main.e6c13ad2.css",
"static/js/main.1af137e7.js"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@ -0,0 +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>

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

View File

@ -0,0 +1,25 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}

View File

@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:

View File

@ -0,0 +1,2 @@
body{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;margin:0}code{font-family:source-code-pro,Menlo,Monaco,Consolas,Courier New,monospace}
/*# sourceMappingURL=main.e6c13ad2.css.map*/

View File

@ -0,0 +1 @@
{"version":3,"file":"static/css/main.e6c13ad2.css","mappings":"AAAA,KAKE,kCAAmC,CACnC,iCAAkC,CAJlC,mIAEY,CAHZ,QAMF,CAEA,KACE,uEAEF","sources":["index.css"],"sourcesContent":["body {\n margin: 0;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',\n 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',\n sans-serif;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\ncode {\n font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',\n monospace;\n}\n"],"names":[],"sourceRoot":""}

View File

@ -0,0 +1,2 @@
"use strict";(self.webpackChunkfrontend=self.webpackChunkfrontend||[]).push([[453],{6453:(e,t,n)=>{n.r(t),n.d(t,{getCLS:()=>y,getFCP:()=>g,getFID:()=>C,getLCP:()=>P,getTTFB:()=>D});var i,r,a,o,u=function(e,t){return{name:e,value:void 0===t?-1:t,delta:0,entries:[],id:"v2-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12)}},c=function(e,t){try{if(PerformanceObserver.supportedEntryTypes.includes(e)){if("first-input"===e&&!("PerformanceEventTiming"in self))return;var n=new PerformanceObserver((function(e){return e.getEntries().map(t)}));return n.observe({type:e,buffered:!0}),n}}catch(e){}},f=function(e,t){var n=function n(i){"pagehide"!==i.type&&"hidden"!==document.visibilityState||(e(i),t&&(removeEventListener("visibilitychange",n,!0),removeEventListener("pagehide",n,!0)))};addEventListener("visibilitychange",n,!0),addEventListener("pagehide",n,!0)},s=function(e){addEventListener("pageshow",(function(t){t.persisted&&e(t)}),!0)},m=function(e,t,n){var i;return function(r){t.value>=0&&(r||n)&&(t.delta=t.value-(i||0),(t.delta||void 0===i)&&(i=t.value,e(t)))}},v=-1,d=function(){return"hidden"===document.visibilityState?0:1/0},p=function(){f((function(e){var t=e.timeStamp;v=t}),!0)},l=function(){return v<0&&(v=d(),p(),s((function(){setTimeout((function(){v=d(),p()}),0)}))),{get firstHiddenTime(){return v}}},g=function(e,t){var n,i=l(),r=u("FCP"),a=function(e){"first-contentful-paint"===e.name&&(f&&f.disconnect(),e.startTime<i.firstHiddenTime&&(r.value=e.startTime,r.entries.push(e),n(!0)))},o=window.performance&&performance.getEntriesByName&&performance.getEntriesByName("first-contentful-paint")[0],f=o?null:c("paint",a);(o||f)&&(n=m(e,r,t),o&&a(o),s((function(i){r=u("FCP"),n=m(e,r,t),requestAnimationFrame((function(){requestAnimationFrame((function(){r.value=performance.now()-i.timeStamp,n(!0)}))}))})))},h=!1,T=-1,y=function(e,t){h||(g((function(e){T=e.value})),h=!0);var n,i=function(t){T>-1&&e(t)},r=u("CLS",0),a=0,o=[],v=function(e){if(!e.hadRecentInput){var t=o[0],i=o[o.length-1];a&&e.startTime-i.startTime<1e3&&e.startTime-t.startTime<5e3?(a+=e.value,o.push(e)):(a=e.value,o=[e]),a>r.value&&(r.value=a,r.entries=o,n())}},d=c("layout-shift",v);d&&(n=m(i,r,t),f((function(){d.takeRecords().map(v),n(!0)})),s((function(){a=0,T=-1,r=u("CLS",0),n=m(i,r,t)})))},E={passive:!0,capture:!0},w=new Date,L=function(e,t){i||(i=t,r=e,a=new Date,F(removeEventListener),S())},S=function(){if(r>=0&&r<a-w){var e={entryType:"first-input",name:i.type,target:i.target,cancelable:i.cancelable,startTime:i.timeStamp,processingStart:i.timeStamp+r};o.forEach((function(t){t(e)})),o=[]}},b=function(e){if(e.cancelable){var t=(e.timeStamp>1e12?new Date:performance.now())-e.timeStamp;"pointerdown"==e.type?function(e,t){var n=function(){L(e,t),r()},i=function(){r()},r=function(){removeEventListener("pointerup",n,E),removeEventListener("pointercancel",i,E)};addEventListener("pointerup",n,E),addEventListener("pointercancel",i,E)}(t,e):L(t,e)}},F=function(e){["mousedown","keydown","touchstart","pointerdown"].forEach((function(t){return e(t,b,E)}))},C=function(e,t){var n,a=l(),v=u("FID"),d=function(e){e.startTime<a.firstHiddenTime&&(v.value=e.processingStart-e.startTime,v.entries.push(e),n(!0))},p=c("first-input",d);n=m(e,v,t),p&&f((function(){p.takeRecords().map(d),p.disconnect()}),!0),p&&s((function(){var a;v=u("FID"),n=m(e,v,t),o=[],r=-1,i=null,F(addEventListener),a=d,o.push(a),S()}))},k={},P=function(e,t){var n,i=l(),r=u("LCP"),a=function(e){var t=e.startTime;t<i.firstHiddenTime&&(r.value=t,r.entries.push(e),n())},o=c("largest-contentful-paint",a);if(o){n=m(e,r,t);var v=function(){k[r.id]||(o.takeRecords().map(a),o.disconnect(),k[r.id]=!0,n(!0))};["keydown","click"].forEach((function(e){addEventListener(e,v,{once:!0,capture:!0})})),f(v,!0),s((function(i){r=u("LCP"),n=m(e,r,t),requestAnimationFrame((function(){requestAnimationFrame((function(){r.value=performance.now()-i.timeStamp,k[r.id]=!0,n(!0)}))}))}))}},D=function(e){var t,n=u("TTFB");t=function(){try{var t=performance.getEntriesByType("navigation")[0]||function(){var e=performance.timing,t={entryType:"navigation",startTime:0};for(var n in e)"navigationStart"!==n&&"toJSON"!==n&&(t[n]=Math.max(e[n]-e.navigationStart,0));return t}();if(n.value=n.delta=t.responseStart,n.value<0||n.value>performance.now())return;n.entries=[t],e(n)}catch(e){}},"complete"===document.readyState?setTimeout(t,0):addEventListener("load",(function(){return setTimeout(t,0)}))}}}]);
//# sourceMappingURL=453.d855a71b.chunk.js.map

File diff suppressed because one or more lines are too long

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

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

View File

@ -1,5 +1,3 @@
com/ioa/tool/CommonTools.class
com/ioa/model/BedrockLanguageModel.class
com/ioa/conversation/ConversationFSM$1.class com/ioa/conversation/ConversationFSM$1.class
com/ioa/service/WebSocketService.class com/ioa/service/WebSocketService.class
com/ioa/conversation/ConversationFSM.class com/ioa/conversation/ConversationFSM.class
@ -8,12 +6,14 @@ com/ioa/util/TreeOfThought.class
com/ioa/conversation/ConversationFSM$ConversationStateUpdate.class com/ioa/conversation/ConversationFSM$ConversationStateUpdate.class
com/ioa/IoASystem.class com/ioa/IoASystem.class
com/ioa/tool/ToolRegistry.class com/ioa/tool/ToolRegistry.class
com/ioa/agent/AgentInfo.class
com/ioa/task/Task.class
com/ioa/conversation/ConversationState.class com/ioa/conversation/ConversationState.class
com/ioa/config/WebSocketConfig.class
com/ioa/task/TaskManager$TaskProgress.class
com/ioa/agent/AgentRegistry.class com/ioa/agent/AgentRegistry.class
com/ioa/team/TeamFormation.class com/ioa/team/TeamFormation.class
com/ioa/tool/Tool.class
com/ioa/task/TaskManager.class com/ioa/task/TaskManager.class
com/ioa/tool/CommonTools.class
com/ioa/model/BedrockLanguageModel.class
com/ioa/agent/AgentInfo.class
com/ioa/task/Task.class
com/ioa/config/WebSocketConfig.class
com/ioa/task/TaskManager$TaskProgress.class
com/ioa/tool/Tool.class