Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions spring-ai-alibaba-jmanus/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,23 @@
<artifactId>mockito-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>

<!-- Apache POI -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.2.3</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>5.2.3</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.15.1</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public enum AgentEnum {
MAPREDUCE_DATA_PREPARE_AGENT("MAPREDUCE_DATA_PREPARE_AGENT", "mapreduce_data_prepare_agent"),
MAPREDUCE_FIN_AGENT("MAPREDUCE_FIN_AGENT", "mapreduce_fin_agent"),
MAPREDUCE_MAP_TASK_AGENT("MAPREDUCE_MAP_TASK_AGENT", "mapreduce_map_task_agent"),
MAPREDUCE_REDUCE_TASK_AGENT("MAPREDUCE_REDUCE_TASK_AGENT", "mapreduce_reduce_task_agent");
MAPREDUCE_REDUCE_TASK_AGENT("MAPREDUCE_REDUCE_TASK_AGENT", "mapreduce_reduce_task_agent"),
PPT_GENERATOR_AGENT("PPT_GENERATOR_AGENT", "ppt_generator_agent");

private String agentName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ public enum PromptEnum {
"tool/doc-loader-tool-parameters.txt"),

// File Merge Tool
FILE_MERGE_TOOL_DESCRIPTION("FILE_MERGE_TOOL_DESCRIPTION", MessageType.SYSTEM, PromptType.TOOL_DESCRIPTION, true,
"tool/file-merge-tool-description.txt"),
FILE_MERGE_TOOL_PARAMETERS("FILE_MERGE_TOOL_PARAMETERS", MessageType.SYSTEM, PromptType.TOOL_PARAMETER, true,
"tool/file-merge-tool-parameters.txt"),
FILE_MERGE_TOOL_TOOL_DESCRIPTION("FILE_MERGE_TOOL_TOOL_DESCRIPTION", MessageType.SYSTEM,
PromptType.TOOL_DESCRIPTION, true, "tool/file-merge-tool-description.txt"),
FILE_MERGE_TOOL_TOOL_PARAMETERS("FILE_MERGE_TOOL_TOOL_PARAMETERS", MessageType.SYSTEM, PromptType.TOOL_PARAMETER,
true, "tool/file-merge-tool-parameters.txt"),

// Data Split Tool
DATA_SPLIT_TOOL_DESCRIPTION("DATA_SPLIT_TOOL_DESCRIPTION", MessageType.SYSTEM, PromptType.TOOL_DESCRIPTION, true,
Expand Down Expand Up @@ -127,7 +127,13 @@ public enum PromptEnum {
TERMINATE_TOOL_DESCRIPTION("TERMINATE_TOOL_DESCRIPTION", MessageType.SYSTEM, PromptType.TOOL_DESCRIPTION, true,
"tool/terminate-tool-description.txt"),
TERMINATE_TOOL_PARAMETERS("TERMINATE_TOOL_PARAMETERS", MessageType.SYSTEM, PromptType.TOOL_PARAMETER, true,
"tool/terminate-tool-parameters.txt");
"tool/terminate-tool-parameters.txt"),

// PPT Generator Tool
PPTGENERATOROPERATOR_TOOL_DESCRIPTION("PPTGENERATOROPERATOR_TOOL_DESCRIPTION", MessageType.SYSTEM,
PromptType.TOOL_DESCRIPTION, true, "tool/ppt-generator-operator-tool-description.txt"),
PPTGENERATOROPERATOR_TOOL_PARAMETERS("PPTGENERATOROPERATOR_TOOL_PARAMETERS", MessageType.SYSTEM,
PromptType.TOOL_PARAMETER, true, "tool/ppt-generator-operator-tool-parameters.txt");

private String promptName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
import com.alibaba.cloud.ai.example.manus.tool.mapreduce.ReduceOperationTool;
import com.alibaba.cloud.ai.example.manus.tool.textOperator.TextFileOperator;
import com.alibaba.cloud.ai.example.manus.tool.textOperator.TextFileService;
import com.alibaba.cloud.ai.example.manus.tool.pptGenerator.PptGeneratorOperator;
import com.alibaba.cloud.ai.example.manus.workflow.SummaryWorkflow;
import com.fasterxml.jackson.databind.ObjectMapper;

Expand Down Expand Up @@ -150,6 +151,9 @@ public class PlanningFactory implements IPlanningFactory {
@Lazy
private CronService cronService;

@Autowired
private PptGeneratorOperator pptGeneratorOperator;

public PlanningFactory(ChromeDriverService chromeDriverService, PlanExecutionRecorder recorder,
ManusProperties manusProperties, TextFileService textFileService, McpService mcpService,
SmartContentSavingService innerStorageService, UnifiedDirectoryManager unifiedDirectoryManager,
Expand Down Expand Up @@ -241,6 +245,7 @@ public Map<String, ToolCallBackContext> toolCallbackMap(String planId, String ro
unifiedDirectoryManager, terminateColumns));
toolDefinitions.add(new FinalizeTool(planId, manusProperties, sharedStateManager, unifiedDirectoryManager));
toolDefinitions.add(new CronTool(cronService, objectMapper, toolPromptManager));
toolDefinitions.add(pptGeneratorOperator);

List<McpServiceEntity> functionCallbacks = mcpService.getFunctionCallbacks(planId);
for (McpServiceEntity toolCallback : functionCallbacks) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* Copyright 2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.cloud.ai.example.manus.tool.pptGenerator;

import java.io.IOException;

import com.alibaba.cloud.ai.example.manus.config.ManusProperties;
import com.alibaba.cloud.ai.example.manus.tool.textOperator.FileState;

/**
* PPT generator service interface, providing PPT file operation management functions
*/
public interface IPptGeneratorService {

/**
* Get the file state
* @param planId Plan ID
* @return File state
*/
FileState getFileState(String planId);

/**
* Update the file state
* @param planId Plan ID
* @param filePath File path
* @param operationResult Operation result
*/
void updateFileState(String planId, String filePath, String operationResult);

/**
* Get the current file path
* @param planId Plan ID
* @return Current file path
*/
String getCurrentFilePath(String planId);

/**
* Get the last operation result
* @param planId Plan ID
* @return Last operation result
*/
String getLastOperationResult(String planId);

/**
* Validate PPT file path
* @param planId Plan ID
* @param filePath File path
* @return Validated absolute path
* @throws IOException IO exception
*/
String validatePptFilePath(String planId, String filePath) throws IOException;

/**
* Check if the file type is supported
* @param filePath File path
* @return True if supported, false otherwise
*/
boolean isSupportedPptFileType(String filePath);

/**
* Get the file extension
* @param filePath File path
* @return File extension
*/
String getFileExtension(String filePath);

/**
* Clean up plan resources
* @param planId Plan ID
*/
void cleanupForPlan(String planId);

/**
* Get the Manus configuration properties
* @return Manus configuration properties
*/
ManusProperties getManusProperties();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
/*
* Copyright 2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.cloud.ai.example.manus.tool.pptGenerator;

import com.alibaba.cloud.ai.example.manus.tool.AbstractBaseTool;
import com.alibaba.cloud.ai.example.manus.tool.ToolPromptManager;
import com.alibaba.cloud.ai.example.manus.tool.code.ToolExecuteResult;
import com.alibaba.cloud.ai.example.manus.tool.filesystem.UnifiedDirectoryManager;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.io.IOException;

@Component
public class PptGeneratorOperator extends AbstractBaseTool<PptInput> {

private static final Logger log = LoggerFactory.getLogger(PptGeneratorOperator.class);

private final PptGeneratorService pptGeneratorService;

private final ObjectMapper objectMapper;

private final ToolPromptManager toolPromptManager;

private final UnifiedDirectoryManager unifiedDirectoryManager;

private static final String TOOL_NAME = "ppt_generator_operator";

public PptGeneratorOperator(PptGeneratorService pptGeneratorService, ObjectMapper objectMapper,
ToolPromptManager toolPromptManager, UnifiedDirectoryManager unifiedDirectoryManager) {
this.pptGeneratorService = pptGeneratorService;
this.objectMapper = objectMapper;
this.toolPromptManager = toolPromptManager;
this.unifiedDirectoryManager = unifiedDirectoryManager;
}

/**
* Run the tool (accepts JSON string input)
*/
@Override
public ToolExecuteResult run(PptInput input) {
log.info("PptGeneratorOperator input: action={}, outputPath={}, title={}", input.getAction(),
input.getOutputPath(), input.getTitle());
try {
String planId = this.currentPlanId;

if (!"create".equals(input.getAction())) {
pptGeneratorService.updateFileState(planId, input.getOutputPath(),
"Error: Unsupported operations: " + input.getAction());
return new ToolExecuteResult(
"Unsupported operations: " + input.getAction() + ",Only supports the 'create' operation");
}

// Validate the path. This will throw an exception if the path is invalid.
String resultPath = validateAndProcessPath(planId, input.getOutputPath());
input.setOutputPath(resultPath);

// Update the file state to processing.
pptGeneratorService.updateFileState(planId, resultPath, "Processing: 正在生成PPT文件");

Check failure on line 74 in spring-ai-alibaba-jmanus/src/main/java/com/alibaba/cloud/ai/example/manus/tool/pptGenerator/PptGeneratorOperator.java

View workflow job for this annotation

GitHub Actions / Check for Chinese content in Jmanus

Found Chinese content in string literal: pptGeneratorService.updateFileState(planId, resultPath, "Processing: 正在生成PPT文件");

Check failure on line 74 in spring-ai-alibaba-jmanus/src/main/java/com/alibaba/cloud/ai/example/manus/tool/pptGenerator/PptGeneratorOperator.java

View workflow job for this annotation

GitHub Actions / Check for Chinese content in Jmanus

Found Chinese content in string literal: pptGeneratorService.updateFileState(planId, resultPath, "Processing: 正在生成PPT文件");

String path = pptGeneratorService.createPpt(input);

// Update the file state to success.
pptGeneratorService.updateFileState(planId, path, "Success: PPT file generated successfully");

return new ToolExecuteResult("PPT file generated successfully, save path: " + path);
}
catch (IllegalArgumentException e) {
String planId = this.currentPlanId;
pptGeneratorService.updateFileState(planId, input.getOutputPath(),
"Error: Parameter validation failed: " + e.getMessage());
return new ToolExecuteResult("Parameter validation failed: " + e.getMessage());
}
catch (Exception e) {
log.error("PPT generation failed", e);
String planId = this.currentPlanId;
pptGeneratorService.updateFileState(planId, input.getOutputPath(),
"Error: PPT generation failed: " + e.getMessage());
return new ToolExecuteResult("PPT generation failed: " + e.getMessage());
}
}

/**
* Validate and process the output path.
* @param planId Plan ID
* @param outputPath Output path
* @return Processed absolute path
* @throws IOException IO exception
*/
private String validateAndProcessPath(String planId, String outputPath) throws IOException {
// Even if the path is empty, call the validation method, which will throw an
// IllegalArgumentException.
return pptGeneratorService.validatePptFilePath(planId, outputPath);
}

@Override
public String getName() {
return TOOL_NAME;
}

@Override
public String getDescription() {
return toolPromptManager.getToolDescription("pptGeneratorOperator");
}

@Override
public String getParameters() {
return toolPromptManager.getToolParameters("pptGeneratorOperator");
}

@Override
public Class<PptInput> getInputType() {
return PptInput.class;
}

@Override
public String getServiceGroup() {
return "default-service-group";
}

@Override
public void cleanup(String planId) {
// Clean up file state.
pptGeneratorService.cleanupForPlan(planId);
log.info("Cleaning up PPT generator resources for plan: {}", planId);
}

@Override
public String getCurrentToolStateString() {
String planId = this.currentPlanId;
if (planId != null) {
return String.format("PPT Generator - Current File: %s, Last Operation: %s",
pptGeneratorService.getCurrentFilePath(planId), pptGeneratorService.getLastOperationResult(planId));
}
return "PPT Generator is ready";
}

}
Loading
Loading