Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
be3976a
feat: add new parameters for image generation and multimodal conversa…
Jul 7, 2026
7d11fae
Add NOTICE file declaring third-party licenses
Jul 7, 2026
650672a
fix: remove hardcoded URL in TingWu to support DASHSCOPE_HTTP_BASE_UR…
Jul 7, 2026
3f460b3
fix: remove hardcoded URL in TingWuUsage sample
Jul 7, 2026
d2449e9
feat: validate mutual exclusivity of stopStrings and stopTokens
Jul 7, 2026
2d9c743
Merge remote-tracking branch 'origin/dev/param' into dev/param
Jul 7, 2026
000f3db
feat: validate mutual exclusivity of stopStrings and stopTokens
Jul 7, 2026
cc1a487
Delete .pre-commit-config.yaml
luk384090-cloud Jul 7, 2026
a2e4565
chore: bump version to 2.22.25
Jul 9, 2026
7f4a930
fix: remove trailing whitespace and apply reasoningContent/content mu…
Jul 10, 2026
2c640e1
feat: support quark_search and code_interpreter tool calls in MultiMo…
Jul 10, 2026
f9f5fec
fix: allow reasoning_content and content to coexist in streaming resp…
Jul 10, 2026
2112b1d
fix: allow reasoning_content and content to coexist in streaming resp…
Jul 10, 2026
45b4000
fix: prevent automatic incremental_output injection to avoid response…
Jul 10, 2026
6f4c840
fix ConversationParam.java
Jul 10, 2026
1714e88
fix GenerationStreamCall.java
Jul 10, 2026
b84fb58
fix: prevent NPE when parameters map is null and improve stream error…
Jul 10, 2026
4e8b6bf
fix: initialize parameters and headers maps in HalfDuplexParamBase to…
Jul 13, 2026
541ad3b
fix: initialize parameters and headers maps in HalfDuplexParamBase to…
Jul 13, 2026
d667ac8
fix: initialize parameters and headers maps in HalfDuplexParamBase to…
Jul 13, 2026
6e83e47
Revert "fix: initialize parameters and headers maps in HalfDuplexPara…
Jul 13, 2026
380f226
Revert "fix: initialize parameters and headers maps in HalfDuplexPara…
Jul 13, 2026
d170341
Revert "fix: initialize parameters and headers maps in HalfDuplexPara…
Jul 13, 2026
e1d7b1e
Revert "fix: prevent NPE when parameters map is null and improve stre…
Jul 13, 2026
d74d76f
Revert "fix GenerationStreamCall.java"
Jul 13, 2026
07c84a4
Revert "fix: prevent automatic incremental_output injection to avoid …
Jul 13, 2026
0b383f6
Revert "fix: allow reasoning_content and content to coexist in stream…
Jul 13, 2026
c5bb4e0
fix: propagate streamData error to responseEmitter and avoid duplicat…
Jul 13, 2026
7250666
fix: allow reasoning_content and content to coexist in MultiModalConv…
Jul 13, 2026
3878c1a
feat: support real incremental output in MultiModalConversation strea…
Jul 13, 2026
c07a264
feat: support explicit incremental/full mode selection in MultiModalC…
Jul 13, 2026
3faa65d
feat: support explicit incremental/full mode selection in MultiModalC…
Jul 13, 2026
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
4 changes: 2 additions & 2 deletions .dev_tools/run_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ mvn package

if [ $? -ne 0 ]; then
echo "mvn package failed, please check if any unittest is failed!"
exit -1
exit 1
fi

echo "CI passed."
echo "CI passed."
39 changes: 39 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
DashScope SDK for Java
Copyright 2023-2026 Alibaba Cloud Computing Ltd.

This product includes software developed at
The Apache Software Foundation (https://www.apache.org/).

Third-Party Software
--------------------

This project uses the following third-party components in test scope only
(not included in the distributed artifact):

JUnit Jupiter (https://junit.org/junit5/)
License: Eclipse Public License 2.0 (EPL-2.0)
Copyright: JUnit team

JUnit Pioneer (https://junit-pioneer.org/)
License: Eclipse Public License 2.0 (EPL-2.0)
Copyright: JUnit Pioneer team

OkHttp (https://square.github.io/okhttp/)
License: Apache License 2.0
Copyright: Square, Inc.

Gson (https://github.com/google/gson)
License: Apache License 2.0
Copyright: Google Inc.

Jackson (https://github.com/FasterXML/jackson)
License: Apache License 2.0
Copyright: FasterXML, LLC

SLF4J (https://www.slf4j.org/)
License: MIT License
Copyright: QOS.ch

Lombok (https://projectlombok.org/)
License: MIT License
Copyright: Reinier Zwitserloot, Roel Spilker
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,3 @@ public class Main {
```

The `call` method accepts a `GenerationParam`, and returns a `GenerationResult`, you can also catch the exception with a try-catch block.

2 changes: 1 addition & 1 deletion lint.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
java -jar .dev_tools/google-java-format-1.7-all-deps.jar -i $(find . -type f -name "*.java" | grep "./*/src/.*java")
java -jar .dev_tools/google-java-format-1.7-all-deps.jar -i $(find . -type f -name "*.java" | grep "./*/src/.*java")
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<name>DashScope Java SDK</name>
<groupId>com.alibaba</groupId>
<artifactId>dashscope-sdk-java</artifactId>
<version>2.22.24</version>
<version>2.22.25</version>

<properties>
<maven.compiler.source>8</maven.compiler.source>
Expand Down
3 changes: 1 addition & 2 deletions samples/TingWuUsage.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ public static Map<String, Object> buildCreateTask(String appId) {

public static void main(String[] args) {
try {
String baseWebsocketApiUrl = "https://dashscope.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation";
// 创建任务
TingWu tingwu = new TingWu(Protocol.HTTP.getValue(),baseWebsocketApiUrl);
TingWu tingwu = new TingWu();
TingWuParam param = TingWuParam.builder().
model("tingwu-automotive-service-inspection")
.input(buildCreateTask("123456"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,45 @@ public class ChatCompletionParam extends FlattenHalfDuplexParamBase {
@SerializedName("parallel_tool_calls")
private Boolean parallelToolCalls;

/**
* Whether to preserve thinking/reasoning content in the response. When enabled, the model will
* include reasoning process in the output.
*/
@SerializedName("preserve_thinking")
private Boolean preserveThinking;

/**
* Controls the reasoning effort level for models that support it. Possible values: "low",
* "medium", "high"
*/
@SerializedName("reasoning_effort")
private String reasoningEffort;

/**
* The maximum number of tokens to generate for completion. This is an alternative to max_tokens
* following OpenAI's newer API convention.
*/
@SerializedName("max_completion_tokens")
private Integer maxCompletionTokens;

/**
* Whether to stream tool calls as they are generated. When true, tool calls will be sent
* incrementally rather than all at once.
*/
@SerializedName("tool_stream")
private Boolean toolStream;

/**
* Enable high resolution image processing for vision-language models. Improves image
* understanding quality at the cost of more tokens.
*/
@SerializedName("vl_high_resolution_images")
private Boolean vlHighResolutionImages;

/** Enable hardware-accelerated image output for vision-language models. */
@SerializedName("vl_enable_image_hw_output")
private Boolean vlEnableImageHwOutput;

private String user;

@Override
Expand Down Expand Up @@ -142,6 +181,24 @@ public JsonObject getHttpBody() {
if (parallelToolCalls != null) {
requestObject.addProperty("parallel_tool_calls", parallelToolCalls);
}
if (preserveThinking != null) {
requestObject.addProperty("preserve_thinking", preserveThinking);
}
if (reasoningEffort != null) {
requestObject.addProperty("reasoning_effort", reasoningEffort);
}
if (maxCompletionTokens != null) {
requestObject.addProperty("max_completion_tokens", maxCompletionTokens);
}
if (toolStream != null) {
requestObject.addProperty("tool_stream", toolStream);
}
if (vlHighResolutionImages != null) {
requestObject.addProperty("vl_high_resolution_images", vlHighResolutionImages);
}
if (vlEnableImageHwOutput != null) {
requestObject.addProperty("vl_enable_image_hw_output", vlEnableImageHwOutput);
}
if (user != null) {
requestObject.addProperty("user", user);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,25 @@ public Map<String, Object> getParameters() {
if (maxTokens != null) {
params.put(MAX_TOKENS, maxTokens);
}
if (stopStrings != null
&& !stopStrings.isEmpty()
&& stopTokens != null
&& !stopTokens.isEmpty()) {
throw new IllegalArgumentException("Only one of stopStrings or stopTokens can be specified.");
}
if (stopStrings != null && !stopStrings.isEmpty()) {
params.put(STOP, stopStrings);
} else if (stopTokens != null && !stopTokens.isEmpty()) {
params.put(STOP, stopTokens);
}
params.putAll(parameters);
if (parameters != null) {
parameters.forEach(
(k, v) -> {
if (v != null) {
params.put(k, v);
}
});
}
return params;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,20 +351,20 @@ private GenerationResult mergeSingleResponse(
if (currentContent != null && !currentContent.isEmpty()) {
accumulated.content.append(currentContent);
}
// Always set the accumulated content if we have any
if (accumulated.content.length() > 0) {
choice.getMessage().setContent(accumulated.content.toString());
}

// Handle reasoning_content accumulation
String currentReasoningContent = choice.getMessage().getReasoningContent();
if (currentReasoningContent != null && !currentReasoningContent.isEmpty()) {
accumulated.reasoningContent.append(currentReasoningContent);
}
// Always set the accumulated reasoning_content if we have any

// Accumulate both reasoning_content and content independently
if (accumulated.reasoningContent.length() > 0) {
choice.getMessage().setReasoningContent(accumulated.reasoningContent.toString());
}
if (accumulated.content.length() > 0) {
choice.getMessage().setContent(accumulated.content.toString());
}

// Handle tool_calls accumulation
List<ToolCallBase> currentToolCalls = choice.getMessage().getToolCalls();
Expand Down Expand Up @@ -474,12 +474,13 @@ private GenerationResult mergeSingleResponse(
com.alibaba.dashscope.common.Message message =
new com.alibaba.dashscope.common.Message();
message.setRole("assistant");
if (data.content.length() > 0) {
message.setContent(data.content.toString());
}
// Set both reasoning_content and content independently
if (data.reasoningContent.length() > 0) {
message.setReasoningContent(data.reasoningContent.toString());
}
if (data.content.length() > 0) {
message.setContent(data.content.toString());
}
if (!data.toolCalls.isEmpty()) {
message.setToolCalls(data.toolCalls);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,12 @@ public Map<String, Object> getParameters() {
if (maxTokens != null) {
params.put(MAX_TOKENS, maxTokens);
}
if (stopStrings != null
&& !stopStrings.isEmpty()
&& stopTokens != null
&& !stopTokens.isEmpty()) {
throw new IllegalArgumentException("Only one of stopStrings or stopTokens can be specified.");
}
if (stopStrings != null && !stopStrings.isEmpty()) {
params.put(STOP, stopStrings);
} else if (stopTokens != null && !stopTokens.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.alibaba.dashscope.aigc.imagegeneration;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/** Color palette configuration for image generation. */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ColorPalette {

/** Hex color code, e.g., "#FF5733" */
private String hex;

/** Ratio of the color in the palette, value range: [0.0, 1.0] */
private Double ratio;
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ public class ImageGenerationParam extends HalfDuplexServiceParam {
*/
@Builder.Default private List<List<List<Integer>>> bboxList = null;

/**
* Thinking mode for image generation. Controls the level of reasoning and planning in the
* generation process.
*/
private String thinkingMode;

/** Color palette configuration for controlling color distribution in generated images. */
private List<ColorPalette> colorPalette;

@Override
public JsonObject getHttpBody() {
JsonObject requestObject = new JsonObject();
Expand Down Expand Up @@ -167,6 +176,14 @@ public Map<String, Object> getParameters() {
params.put("bbox_list", bboxList);
}

if (thinkingMode != null) {
params.put("thinking_mode", thinkingMode);
}

if (colorPalette != null) {
params.put("color_palette", colorPalette);
}

params.putAll(parameters);
return params;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.alibaba.dashscope.utils.JsonUtils;
import com.alibaba.dashscope.utils.PreprocessInputImage;
import com.google.gson.JsonObject;
import com.google.gson.annotations.SerializedName;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.HashMap;
Expand Down Expand Up @@ -58,6 +59,27 @@ public class ImageSynthesisParam extends HalfDuplexServiceParam {

@Builder.Default private Boolean watermark = null;

/**
* Controls the similarity between the output image and the reference image (垫图). Value range:
* [0.0, 1.0]. Higher values mean the generated image is more similar to the reference image.
*/
@Builder.Default private Float refStrength = null;

/**
* The mode for generating images based on the reference image (垫图). Supported modes: - "repaint"
* (default): Generate image based on the content of the reference image. - "refonly": Generate
* image based on the style of the reference image.
*/
@Builder.Default private String refMode = null;

/**
* The color used to fill the masked area before inpainting. Format: hex color code, e.g.,
* "#FFFFFF" or "white", "black", etc.
*/
@SerializedName("mask_color")
@Builder.Default
private String maskColor = null;

@Override
public JsonObject getInput() {
JsonObject jsonObject = new JsonObject();
Expand Down Expand Up @@ -124,6 +146,18 @@ public Map<String, Object> getParameters() {
params.put(WATERMARK, watermark);
}

if (refStrength != null) {
params.put("ref_strength", refStrength);
}

if (refMode != null) {
params.put("ref_mode", refMode);
}

if (maskColor != null) {
params.put("mask_color", maskColor);
}

params.putAll(super.getParameters());
return params;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ public class SketchImageSynthesisParam extends HalfDuplexServiceParam {
@lombok.NonNull
private String sketchImageUrl;

@SerializedName("style")
@Builder.Default
private String style = null;

@SerializedName("sketch_extraction")
@Builder.Default
private Boolean sketchExtraction = null;

@SerializedName("sketch_color")
@Builder.Default
private String sketchColor = null;

@lombok.NonNull private String prompt;

@Override
Expand All @@ -61,6 +73,15 @@ public Map<String, Object> getParameters() {
if (realisticness != null) {
params.put(REALISTICNESS, realisticness);
}
if (style != null) {
params.put("style", style);
}
if (sketchExtraction != null) {
params.put("sketch_extraction", sketchExtraction);
}
if (sketchColor != null) {
params.put("sketch_color", sketchColor);
}
params.putAll(super.getParameters());
return params;
}
Expand Down
Loading
Loading