Skip to content

support wan 2.7#195

Merged
xiong-binbin merged 2 commits intodashscope:mainfrom
mose-x:support_wan27
Mar 12, 2026
Merged

support wan 2.7#195
xiong-binbin merged 2 commits intodashscope:mainfrom
mose-x:support_wan27

Conversation

@mose-zm
Copy link
Contributor

@mose-zm mose-zm commented Mar 11, 2026

support wan 2.7

@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the video synthesis capabilities by integrating the latest wan2.7 model. It introduces a more flexible and robust system for handling diverse media inputs through new parameters and a refactored, concurrent file upload process. Additionally, a new parameter has been added to the image generation service, collectively improving the overall functionality and performance of the AI generation services.

Highlights

  • Video Synthesis Model Support: Added support for the wan2.7 model in video synthesis, including new examples for wan2.7-i2v and wan2.7-r2v models.
  • Flexible Media Input: Introduced new parameters like referenceUrls, referenceUrl, and a structured Media object to allow for more diverse and flexible input types for video synthesis.
  • Concurrent File Uploads: Refactored the file upload mechanism in VideoSynthesisParam to utilize CompletableFuture for concurrent processing of multiple media files, improving efficiency and robustness.
  • Image Generation Parameter: Added an enableSequential boolean parameter to ImageGenerationParam for controlling sequential image generation.
  • New Media Type Definitions: Defined a new MediaType inner class within VideoSynthesis to categorize various media inputs such as FIRST_CLIP and DRIVING_AUDIO.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • samples/VideoSynthesisUsage.java
    • Renamed referenceVideoUrls to referenceUrls in the basicCall method.
    • Added a new basicCallI2V27 method to demonstrate usage of the wan2.7-i2v model.
    • Added a new basicCallR2V27 method to demonstrate usage of the wan2.7-r2v model.
    • Modified the main method to invoke the basicCallR2V27 example by default.
  • src/main/java/com/alibaba/dashscope/aigc/imagegeneration/ImageGenerationParam.java
    • Reordered Lombok import statements for consistency.
    • Added a new enableSequential boolean field to the parameter class.
    • Included the enableSequential parameter in the HTTP request body if it is not null.
  • src/main/java/com/alibaba/dashscope/aigc/videosynthesis/VideoSynthesis.java
    • Added a new AUTO constant to the ShotType inner class.
    • Introduced a new MediaType inner class containing constants for various media types like FIRST_FRAME, REFERENCE_IMAGE, DRIVING_AUDIO, etc.
  • src/main/java/com/alibaba/dashscope/aigc/videosynthesis/VideoSynthesisParam.java
    • Removed an unnecessary static import for ApiKeywords.
    • Introduced a new static nested class Media to represent structured media input with URL, type, reference voice, and description.
    • Added new fields referenceUrls, referenceUrl, media, and ratio to the parameter class.
    • Updated the getInput method to include the new referenceUrls, referenceUrl, and media fields in the JSON payload.
    • Updated the getParameters method to include the new ratio field.
    • Refactored the checkAndUpload method to use CompletableFuture for asynchronous and concurrent uploading of multiple media files, improving the upload logic and supporting new media types.
  • src/main/java/com/alibaba/dashscope/utils/ApiKeywords.java
    • Added new string constants: REFERENCE_URLS, MEDIA_URLS, REFERENCE_URL, and RATIO to support the new video synthesis parameters.
Activity
  • No specific activity (comments, reviews, progress) was provided in the context for this pull request.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for "wan 2.7" by introducing new parameters for video synthesis and refactoring the file upload logic to be concurrent. The changes are generally good, but there are a few areas for improvement. The new concurrent upload logic in VideoSynthesisParam.java uses hardcoded values for thread pool size and timeout, which could be problematic. Also, it uses magic strings for key construction, which is not ideal for maintainability. Additionally, the sample usage file VideoSynthesisUsage.java demonstrates a discouraged Java pattern for list initialization. My feedback focuses on addressing these points to improve the code's robustness and maintainability.

Note: Security Review is unavailable for this PR.

Comment on lines +49 to +58
List<VideoSynthesisParam.Media> media = new ArrayList<VideoSynthesisParam.Media>(){{
add(VideoSynthesisParam.Media.builder()
.url("https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/wpimhv/rap.png")
.type(VideoSynthesis.MediaType.FIRST_CLIP)
.build());
add(VideoSynthesisParam.Media.builder()
.url("https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/ozwpvi/rap.mp3")
.type(VideoSynthesis.MediaType.DRIVING_AUDIO)
.build());
}};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Double-brace initialization should be avoided. It creates an anonymous inner class for each use, which can lead to performance and memory issues. It's better to initialize the list and then add elements to it.

        List<VideoSynthesisParam.Media> media = new ArrayList<>();
        media.add(VideoSynthesisParam.Media.builder()
                .url("https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/wpimhv/rap.png")
                .type(VideoSynthesis.MediaType.FIRST_CLIP)
                .build());
        media.add(VideoSynthesisParam.Media.builder()
                .url("https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250925/ozwpvi/rap.mp3")
                .type(VideoSynthesis.MediaType.DRIVING_AUDIO)
                .build());

Comment on lines +79 to +105
List<VideoSynthesisParam.Media> media = new ArrayList<VideoSynthesisParam.Media>(){{
add(VideoSynthesisParam.Media.builder()
.url("https://test-data-center.oss-accelerate.aliyuncs.com/wanx/image/res240_269.jpg")
.type(VideoSynthesis.MediaType.REFERENCE_IMAGE)
.build());
add(VideoSynthesisParam.Media.builder()
.url("https://test-data-center.oss-accelerate.aliyuncs.com/wanx/image/man_5K_7_7K_18_4M.JPG")
.referenceVoice("https://test-data-center.oss-accelerate.aliyuncs.com/wanx/audio/2s.wav")
.type(VideoSynthesis.MediaType.REFERENCE_IMAGE)
.build());
add(VideoSynthesisParam.Media.builder()
.url("https://test-data-center.oss-accelerate.aliyuncs.com/wanx/video/resources/cast/100M.mov")
.referenceVoice("https://test-data-center.oss-accelerate.aliyuncs.com/wanx/audio/mp3_1s.mp3")
.type(VideoSynthesis.MediaType.REFERENCE_VIDEO)
.build());
add(VideoSynthesisParam.Media.builder()
.url("https://test-data-center.oss-accelerate.aliyuncs.com/wanx/video/resources/cast/29_99s.mp4")
.referenceDescription("这是一个身穿蓝衣的男子<cast>,他有着浓密的络腮胡")
.type(VideoSynthesis.MediaType.REFERENCE_VIDEO)
.build());
add(VideoSynthesisParam.Media.builder()
.url("https://test-data-center.oss-accelerate.aliyuncs.com/wanx/video/resources/cast/cat_127.mp4")
.referenceVoice("https://test-data-center.oss-accelerate.aliyuncs.com/wanx/audio/wav_10s.wav")
.referenceDescription("这是一只毛绒小猫<cast>,它正在对着镜头微笑")
.type(VideoSynthesis.MediaType.REFERENCE_VIDEO)
.build());
}};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Double-brace initialization should be avoided. It creates an anonymous inner class for each use, which can lead to performance and memory issues. A better approach is to use java.util.Arrays.asList or List.of (for Java 9+) to create the list.

        List<VideoSynthesisParam.Media> media = new ArrayList<>(java.util.Arrays.asList(
            VideoSynthesisParam.Media.builder()
                    .url("https://test-data-center.oss-accelerate.aliyuncs.com/wanx/image/res240_269.jpg")
                    .type(VideoSynthesis.MediaType.REFERENCE_IMAGE)
                    .build(),
            VideoSynthesisParam.Media.builder()
                    .url("https://test-data-center.oss-accelerate.aliyuncs.com/wanx/image/man_5K_7_7K_18_4M.JPG")
                    .referenceVoice("https://test-data-center.oss-accelerate.aliyuncs.com/wanx/audio/2s.wav")
                    .type(VideoSynthesis.MediaType.REFERENCE_IMAGE)
                    .build(),
            VideoSynthesisParam.Media.builder()
                    .url("https://test-data-center.oss-accelerate.aliyuncs.com/wanx/video/resources/cast/100M.mov")
                    .referenceVoice("https://test-data-center.oss-accelerate.aliyuncs.com/wanx/audio/mp3_1s.mp3")
                    .type(VideoSynthesis.MediaType.REFERENCE_VIDEO)
                    .build(),
            VideoSynthesisParam.Media.builder()
                    .url("https://test-data-center.oss-accelerate.aliyuncs.com/wanx/video/resources/cast/29_99s.mp4")
                    .referenceDescription("这是一个身穿蓝衣的男子<cast>,他有着浓密的络腮胡")
                    .type(VideoSynthesis.MediaType.REFERENCE_VIDEO)
                    .build(),
            VideoSynthesisParam.Media.builder()
                    .url("https://test-data-center.oss-accelerate.aliyuncs.com/wanx/video/resources/cast/cat_127.mp4")
                    .referenceVoice("https://test-data-center.oss-accelerate.aliyuncs.com/wanx/audio/wav_10s.wav")
                    .referenceDescription("这是一只毛绒小猫<cast>,它正在对着镜头微笑")
                    .type(VideoSynthesis.MediaType.REFERENCE_VIDEO)
                    .build()
        ));

Comment on lines +341 to +354
if (this.media != null) {
for (int i = 0; i < this.media.size(); i++) {
Media media = this.media.get(i);
if (media != null) {
if (media.getUrl() != null) {
itemsToProcess.add(new TaskItem(MEDIA_URLS, "_URL", media.getUrl(), i));
}
if (media.getReferenceVoice() != null) {
itemsToProcess.add(
new TaskItem(MEDIA_URLS, "_REFERENCE_VOICE", media.getReferenceVoice(), i));
}
}
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The strings "_URL" and "_REFERENCE_VOICE" are used as magic strings to construct keys for the media items. This is fragile and error-prone, as the same strings are manually constructed again when retrieving values from the map (lines 458-459). It's better to define them as private static final constants to avoid typos and improve maintainability.

}

if (isUpload) {
ExecutorService executor = Executors.newFixedThreadPool(5);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The thread pool size is hardcoded to 5. This might not be optimal for all environments. Consider defining it as a named constant at the class level (e.g., private static final int UPLOAD_THREAD_POOL_SIZE = 5;) to improve maintainability and clarity. It would be even better to allow users to provide their own ExecutorService.

} finally {
executor.shutdown();
try {
if (!executor.awaitTermination(60, TimeUnit.SECONDS)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The awaitTermination timeout is hardcoded to 60 seconds. This might be too short for uploading large files or on slow networks, which could lead to premature task cancellation. It's recommended to use a larger timeout and define it as a named constant for clarity and ease of modification (e.g., private static final long UPLOAD_TIMEOUT_SECONDS = 180;).

@xiong-binbin xiong-binbin merged commit a04ac72 into dashscope:main Mar 12, 2026
3 checks passed
@mose-zm mose-zm deleted the support_wan27 branch March 12, 2026 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants