Skip to content

Commit 4219934

Browse files
rainerWJYansweropensourcezizhu8huoci.yy@cainiao.comyuluo-yx
authored
fix(jmanus): merge and fix cn pr (alibaba#2081)
* fix(entity): update PlanExecutionRecord column definition to longtext for larger data storage * bug(jmanus): fix polardb concurrent trasaction bug * bug(jmanus): fix polardb concurrent trasaction bug * feat(jmanus): add namespace host column * feat(jmanus): 扩展序列化方式,支持agent是否初始化,修复polardb事务并发问题 * bug(jmanus): fix compile error * bug(jmanus): fix compile error * feat(jmanus): enhance index page (alibaba#1842) * fix(entity): update PlanExecutionRecord column definition to longtext for larger data storage * feat(i18n): update direct button text and add AI novel example * build front end --------- Co-authored-by: rainerWJY <answeropensource@alibabacloud.com> * feat(nl2sql): update nl2sql common db connector (alibaba#1824) * feat(nl2sql): update nl2sql common db connector Signed-off-by: shown.Ji <yuluo08290126@gmail.com> * style(nl2sql): update code styl Signed-off-by: shown.Ji <yuluo08290126@gmail.com> * fix Signed-off-by: shown.Ji <yuluo08290126@gmail.com> * feat(nl2sql): fix some issue Signed-off-by: shown.Ji <yuluo08290126@gmail.com> * style(nl2sql): update code style Signed-off-by: shown.Ji <yuluo08290126@gmail.com> * fix(ut): fix ut Signed-off-by: shown.Ji <yuluo08290126@gmail.com> --------- Signed-off-by: shown.Ji <yuluo08290126@gmail.com> * feat(graph): StreamingOutput增强,增加 ChatResponse 属性以获取完整响应 (alibaba#1836) * (streamfeating): StreamingOutput增强,增加 ChatResponse 属性以获取完整响应 - 在 StreamingOutput 类中添加 chatResponse 属性,用于存储 ChatResponse 对象 * feat(streaming): 增加对全量 ChatResponse 的处理支持 * feat(streaming): 增加对全量 ChatResponse 的处理支持 * fix(deepresearch): enable researchTeam error handling mechanism (alibaba#1843) * fix(deepresearch): enable researchTeam error handling mechanism * format * remove unused imports * bug(jmanus): fix end file character * bug(jmanus): fix polardb concurrent trasaction bug * bug(jmanus): fix polardb concurrent trasaction bug * feat(jmanus): add namespace host column * feat(jmanus): 扩展序列化方式,支持agent是否初始化,修复polardb事务并发问题 * bug(jmanus): fix compile error * bug(jmanus): fix compile error * bug(jmanus): fix end file character * fix(jmanus): merge main branch * feat(jmanus): add namespace host column * bug(jmanus): fix compile error * bug(jmanus): fix end file character * feat(jmanus): add namespace host column * bug(jmanus): fix compile error * fix(jmanus): merge origin main * fix(jmanus): merge main branch * feat(jmanus): merge ui/support ignore load buildin tools * feat(jmanus): add namespace host column * bug(jmanus): fix compile error * bug(jmanus): fix end file character * feat(jmanus): add namespace host column * feat(jmanus): 扩展序列化方式,支持agent是否初始化,修复polardb事务并发问题 * bug(jmanus): fix compile error * bug(jmanus): fix end file character * feat(jmanus): add namespace host column * bug(jmanus): fix compile error * feat(jmanus): merge upstream main * feat(nl2sql): update nl2sql common db connector (alibaba#1824) * feat(nl2sql): update nl2sql common db connector Signed-off-by: shown.Ji <yuluo08290126@gmail.com> * style(nl2sql): update code styl Signed-off-by: shown.Ji <yuluo08290126@gmail.com> * fix Signed-off-by: shown.Ji <yuluo08290126@gmail.com> * feat(nl2sql): fix some issue Signed-off-by: shown.Ji <yuluo08290126@gmail.com> * style(nl2sql): update code style Signed-off-by: shown.Ji <yuluo08290126@gmail.com> * fix(ut): fix ut Signed-off-by: shown.Ji <yuluo08290126@gmail.com> --------- Signed-off-by: shown.Ji <yuluo08290126@gmail.com> * fix(jmanus): merge main branch * feat(jmanus): merge ui/support ignore load buildin tools * feat(jmanus): 支持不加载内置工具 * feat(jmanus): 支持不加载内置工具 * feat(jmanus): 支持不加载内置工具 * feat(jmanus):Extended acquisition agent implementation * merge upstream main * refactor(ui): clean up CSS and remove unused i18n entries * remove dir * build * java style --------- Signed-off-by: shown.Ji <yuluo08290126@gmail.com> Co-authored-by: rainerWJY <answeropensource@alibabacloud.com> Co-authored-by: zizhu8 <ziyunyangyong@126.com> Co-authored-by: huoci.yy@cainiao.com <huoci.yy@cainiao.com> Co-authored-by: shown <yuluo08290126@gmail.com> Co-authored-by: xiaohai-78 <xiaoyuntao789@163.com> Co-authored-by: sixiyida <102841234+sixiyida@users.noreply.github.com> Co-authored-by: CaptainGreenskin <liulihan5211@gmail.com>
1 parent efc106b commit 4219934

File tree

7 files changed

+69
-26
lines changed

7 files changed

+69
-26
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,6 @@ spring-ai-alibaba-jmanus/ui-vue3/pnpm-lock.yaml
6262
# MCP configuration files
6363
modified_mcp_config.json
6464
.cursorindexingignore
65+
66+
# ignore code copilot local index
67+
.idea/LocalCodeIndex/

spring-ai-alibaba-jmanus/src/main/java/com/alibaba/cloud/ai/example/manus/dynamic/agent/service/DynamicAgentLoader.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import com.alibaba.cloud.ai.example.manus.llm.StreamingResponseHandler;
3434
import com.alibaba.cloud.ai.example.manus.planning.service.UserInputService;
3535
import com.alibaba.cloud.ai.example.manus.recorder.PlanExecutionRecorder;
36+
import com.alibaba.cloud.ai.example.manus.planning.model.vo.ExecutionContext;
3637

3738
@Service
3839
public class DynamicAgentLoader implements IDynamicAgentLoader {
@@ -88,4 +89,9 @@ public List<DynamicAgentEntity> getAllAgents() {
8889
.toList();
8990
}
9091

92+
@Override
93+
public List<DynamicAgentEntity> getAgents(ExecutionContext context) {
94+
return IDynamicAgentLoader.super.getAgents(context);
95+
}
96+
9197
}

spring-ai-alibaba-jmanus/src/main/java/com/alibaba/cloud/ai/example/manus/dynamic/agent/service/IDynamicAgentLoader.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import com.alibaba.cloud.ai.example.manus.dynamic.agent.DynamicAgent;
2222
import com.alibaba.cloud.ai.example.manus.dynamic.agent.entity.DynamicAgentEntity;
23+
import com.alibaba.cloud.ai.example.manus.planning.model.vo.ExecutionContext;
2324

2425
/**
2526
* Dynamic Agent loader interface, providing Agent loading function
@@ -40,4 +41,8 @@ public interface IDynamicAgentLoader {
4041
*/
4142
List<DynamicAgentEntity> getAllAgents();
4243

44+
default List<DynamicAgentEntity> getAgents(ExecutionContext context) {
45+
return getAllAgents();
46+
}
47+
4348
}

spring-ai-alibaba-jmanus/src/main/java/com/alibaba/cloud/ai/example/manus/planning/IPlanningFactory.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import java.util.Map;
1919

20+
import com.alibaba.cloud.ai.example.manus.planning.model.vo.ExecutionContext;
2021
import org.springframework.web.client.RestClient;
2122

2223
import com.alibaba.cloud.ai.example.manus.dynamic.agent.ToolCallbackProvider;
@@ -29,10 +30,10 @@ public interface IPlanningFactory {
2930

3031
/**
3132
* Create planning coordinator
32-
* @param planId Plan ID
33+
* @param context
3334
* @return Planning coordinator
3435
*/
35-
PlanningCoordinator createPlanningCoordinator(String planId);
36+
PlanningCoordinator createPlanningCoordinator(ExecutionContext context);
3637

3738
/**
3839
* Create tool callback mapping

spring-ai-alibaba-jmanus/src/main/java/com/alibaba/cloud/ai/example/manus/planning/PlanningFactory.java

Lines changed: 51 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.util.Map;
2323
import java.util.concurrent.TimeUnit;
2424

25+
import com.alibaba.cloud.ai.example.manus.planning.model.vo.ExecutionContext;
2526
import org.apache.hc.client5.http.classic.HttpClient;
2627
import org.apache.hc.client5.http.config.RequestConfig;
2728
import org.apache.hc.client5.http.impl.classic.HttpClients;
@@ -33,6 +34,7 @@
3334
import org.springframework.ai.tool.function.FunctionToolCallback;
3435
import org.springframework.ai.tool.metadata.ToolMetadata;
3536
import org.springframework.beans.factory.annotation.Autowired;
37+
import org.springframework.beans.factory.annotation.Value;
3638
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
3739
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
3840
import org.springframework.context.annotation.Bean;
@@ -154,6 +156,9 @@ public class PlanningFactory implements IPlanningFactory {
154156
@Autowired
155157
private PptGeneratorOperator pptGeneratorOperator;
156158

159+
@Value("${agent.init}")
160+
private Boolean agentInit = true;
161+
157162
@Autowired
158163
private JsxGeneratorOperator jsxGeneratorOperator;
159164

@@ -172,6 +177,24 @@ public PlanningFactory(ChromeDriverService chromeDriverService, PlanExecutionRec
172177
this.tableProcessingService = tableProcessingService;
173178
}
174179

180+
public PlanningCoordinator createPlanningCoordinator(ExecutionContext context) {
181+
// Add all dynamic agents from the database
182+
List<DynamicAgentEntity> agentEntities = dynamicAgentLoader.getAgents(context);
183+
184+
PlanningToolInterface planningTool = new PlanningTool();
185+
186+
PlanCreator planCreator = new PlanCreator(agentEntities, llmService, planningTool, recorder, promptService,
187+
manusProperties, streamingResponseHandler);
188+
189+
PlanFinalizer planFinalizer = new PlanFinalizer(llmService, recorder, promptService, manusProperties,
190+
streamingResponseHandler);
191+
192+
PlanningCoordinator planningCoordinator = new PlanningCoordinator(planCreator, planExecutorFactory,
193+
planFinalizer);
194+
195+
return planningCoordinator;
196+
}
197+
175198
// Use the enhanced PlanningCoordinator with dynamic executor selection
176199
public PlanningCoordinator createPlanningCoordinator(String planId) {
177200

@@ -225,29 +248,34 @@ public Map<String, ToolCallBackContext> toolCallbackMap(String planId, String ro
225248
log.error("SmartContentSavingService is null, skipping BrowserUseTool registration");
226249
return toolCallbackMap;
227250
}
228-
// Add all tool definitions
229-
toolDefinitions.add(BrowserUseTool.getInstance(chromeDriverService, innerStorageService, objectMapper));
230-
toolDefinitions.add(DatabaseUseTool.getInstance(dataSourceService, objectMapper));
231-
toolDefinitions.add(new TerminateTool(planId, expectedReturnInfo));
232-
toolDefinitions.add(new Bash(unifiedDirectoryManager, objectMapper));
233-
toolDefinitions.add(new DocLoaderTool());
234-
toolDefinitions.add(new TextFileOperator(textFileService, innerStorageService, objectMapper));
235-
// toolDefinitions.add(new InnerStorageTool(unifiedDirectoryManager));
236-
// toolDefinitions.add(pptGeneratorOperator);
237-
// toolDefinitions.add(jsxGeneratorOperator);
238-
toolDefinitions.add(new InnerStorageContentTool(unifiedDirectoryManager, summaryWorkflow, recorder));
239-
toolDefinitions.add(new FileMergeTool(unifiedDirectoryManager));
240-
// toolDefinitions.add(new GoogleSearch());
241-
// toolDefinitions.add(new PythonExecute());
242-
toolDefinitions.add(new FormInputTool(objectMapper));
243-
toolDefinitions.add(new DataSplitTool(planId, manusProperties, sharedStateManager, unifiedDirectoryManager,
244-
objectMapper, tableProcessingService));
245-
toolDefinitions
246-
.add(new MapOutputTool(planId, manusProperties, sharedStateManager, unifiedDirectoryManager, objectMapper));
247-
toolDefinitions
248-
.add(new ReduceOperationTool(planId, manusProperties, sharedStateManager, unifiedDirectoryManager));
249-
toolDefinitions.add(new FinalizeTool(planId, manusProperties, sharedStateManager, unifiedDirectoryManager));
250-
toolDefinitions.add(new CronTool(cronService, objectMapper));
251+
if (agentInit) {
252+
// Add all tool definitions
253+
toolDefinitions.add(BrowserUseTool.getInstance(chromeDriverService, innerStorageService, objectMapper));
254+
toolDefinitions.add(DatabaseUseTool.getInstance(dataSourceService, objectMapper));
255+
toolDefinitions.add(new TerminateTool(planId, expectedReturnInfo));
256+
toolDefinitions.add(new Bash(unifiedDirectoryManager, objectMapper));
257+
toolDefinitions.add(new DocLoaderTool());
258+
toolDefinitions.add(new TextFileOperator(textFileService, innerStorageService, objectMapper));
259+
// toolDefinitions.add(new InnerStorageTool(unifiedDirectoryManager));
260+
// toolDefinitions.add(pptGeneratorOperator);
261+
// toolDefinitions.add(jsxGeneratorOperator);
262+
toolDefinitions.add(new InnerStorageContentTool(unifiedDirectoryManager, summaryWorkflow, recorder));
263+
toolDefinitions.add(new FileMergeTool(unifiedDirectoryManager));
264+
// toolDefinitions.add(new GoogleSearch());
265+
// toolDefinitions.add(new PythonExecute());
266+
toolDefinitions.add(new FormInputTool(objectMapper));
267+
toolDefinitions.add(new DataSplitTool(planId, manusProperties, sharedStateManager, unifiedDirectoryManager,
268+
objectMapper, tableProcessingService));
269+
toolDefinitions.add(new MapOutputTool(planId, manusProperties, sharedStateManager, unifiedDirectoryManager,
270+
objectMapper));
271+
toolDefinitions
272+
.add(new ReduceOperationTool(planId, manusProperties, sharedStateManager, unifiedDirectoryManager));
273+
toolDefinitions.add(new FinalizeTool(planId, manusProperties, sharedStateManager, unifiedDirectoryManager));
274+
toolDefinitions.add(new CronTool(cronService, objectMapper));
275+
}
276+
else {
277+
toolDefinitions.add(new TerminateTool(planId, expectedReturnInfo));
278+
}
251279

252280
List<McpServiceEntity> functionCallbacks = mcpService.getFunctionCallbacks(planId);
253281
for (McpServiceEntity toolCallback : functionCallbacks) {

spring-ai-alibaba-jmanus/src/main/java/com/alibaba/cloud/ai/example/manus/planning/controller/ManusController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public ResponseEntity<Map<String, Object>> executeQuery(@RequestBody Map<String,
9898
context.setNeedSummary(true);
9999

100100
// Get or create planning flow
101-
PlanningCoordinator planningFlow = planningFactory.createPlanningCoordinator(planId);
101+
PlanningCoordinator planningFlow = planningFactory.createPlanningCoordinator(context);
102102

103103
// Asynchronous execution of task
104104
CompletableFuture.supplyAsync(() -> {
File renamed without changes.

0 commit comments

Comments
 (0)