Working code!

This commit is contained in:
Mahesh Kommareddi 2024-07-16 20:08:17 -04:00
parent 634b4b2561
commit 09f508f5fa
24 changed files with 48 additions and 75 deletions

21
pom.xml
View File

@ -9,9 +9,10 @@
<version>1.0-SNAPSHOT</version>
<properties>
<java.version>11</java.version>
<spring-boot.version>2.5.5</spring-boot.version>
<java.version>21</java.version>
<spring-boot.version>3.2.4</spring-boot.version>
<aws.sdk.version>2.26.9</aws.sdk.version>
<lombok.version>1.18.30</lombok.version>
</properties>
<dependencyManagement>
@ -54,7 +55,8 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
@ -71,12 +73,6 @@
<version>${spring-boot.version}</version>
<configuration>
<mainClass>com.ioa.IoASystem</mainClass>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
<executions>
<execution>
@ -93,6 +89,13 @@
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>

View File

@ -1,65 +0,0 @@
package com.ioa;
import com.ioa.agent.AgentInfo;
import com.ioa.agent.AgentRegistry;
import com.ioa.task.Task;
import com.ioa.task.TaskManager;
import com.ioa.team.TeamFormation;
import com.ioa.tool.CommonTools;
import com.ioa.tool.ToolRegistry;
import com.ioa.model.BedrockLanguageModel;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.List;
public class Main {
public static void main(String[] args) {
// Initialize the system
ToolRegistry toolRegistry = new ToolRegistry();
CommonTools commonTools = new CommonTools();
// Register all tools from CommonTools
for (Method method : CommonTools.class.getMethods()) {
if (method.isAnnotationPresent(dev.langchain4j.agent.tool.Tool.class)) {
toolRegistry.registerTool(method.getName(), method);
}
}
AgentRegistry agentRegistry = new AgentRegistry(toolRegistry);
BedrockLanguageModel model = new BedrockLanguageModel("anthropic.claude-v2"); // or another model ID
TeamFormation teamFormation = new TeamFormation(agentRegistry, model);
TaskManager taskManager = new TaskManager(agentRegistry, model, toolRegistry);
// Register some example agents
AgentInfo agent1 = new AgentInfo("agent1", "General Assistant",
Arrays.asList("general", "search"),
Arrays.asList("webSearch", "getWeather", "setReminder"));
AgentInfo agent2 = new AgentInfo("agent2", "Travel Expert",
Arrays.asList("travel", "booking"),
Arrays.asList("bookTravel", "calculateDistance", "findRestaurants"));
agentRegistry.registerAgent(agent1.getId(), agent1);
agentRegistry.registerAgent(agent2.getId(), agent2);
// Create a sample task
Task task = new Task("task1", "Plan a weekend trip to Paris",
Arrays.asList("travel", "booking"),
Arrays.asList("bookTravel", "findRestaurants", "getWeather"));
// Form a team for the task
List<AgentInfo> team = teamFormation.formTeam(task);
System.out.println("Formed team: " + team);
// Assign the task to the first agent in the team (simplified)
task.setAssignedAgent(team.get(0));
// Execute the task
taskManager.addTask(task);
taskManager.executeTask(task.getId());
// Print the result
System.out.println("Task result: " + task.getResult());
}
}

View File

@ -1,6 +1,6 @@
package com.ioa.tool;
import dev.langchain4j.agent.tool.Tool;
import com.ioa.tool.Tool;
public class CommonTools {

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

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

View File

@ -0,0 +1,16 @@
/Users/emkay/Projects/totioa/src/main/java/com/ioa/util/TreeOfThought.java
/Users/emkay/Projects/totioa/src/main/java/com/ioa/conversation/ConversationFSM.java
/Users/emkay/Projects/totioa/src/main/java/com/ioa/model/BedrockLanguageModel.java
/Users/emkay/Projects/totioa/src/main/java/com/ioa/conversation/ConversationState.java
/Users/emkay/Projects/totioa/src/main/java/com/ioa/task/Task.java
/Users/emkay/Projects/totioa/src/main/java/com/ioa/conversation/Message.java
/Users/emkay/Projects/totioa/src/main/java/com/ioa/service/WebSocketService.java
/Users/emkay/Projects/totioa/src/main/java/com/ioa/agent/AgentInfo.java
/Users/emkay/Projects/totioa/src/main/java/com/ioa/tool/Tool.java
/Users/emkay/Projects/totioa/src/main/java/com/ioa/team/TeamFormation.java
/Users/emkay/Projects/totioa/src/main/java/com/ioa/tool/ToolRegistry.java
/Users/emkay/Projects/totioa/src/main/java/com/ioa/tool/CommonTools.java
/Users/emkay/Projects/totioa/src/main/java/com/ioa/task/TaskManager.java
/Users/emkay/Projects/totioa/src/main/java/com/ioa/IoASystem.java
/Users/emkay/Projects/totioa/src/main/java/com/ioa/agent/AgentRegistry.java
/Users/emkay/Projects/totioa/src/main/java/com/ioa/config/WebSocketConfig.java