main
黄海 5 months ago
parent 6df7392acb
commit 26f8f95f83

@ -1,6 +1,8 @@
package Tools.TestUnit;
import java.util.Arrays;
import java.lang.System;
import com.alibaba.dashscope.aigc.generation.Generation;
import com.alibaba.dashscope.aigc.generation.GenerationParam;
import com.alibaba.dashscope.aigc.generation.GenerationResult;
@ -11,6 +13,9 @@ import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.NoApiKeyException;
public class TestDeepSeek {
public static String R1 = "deepseek-r1";
public static String V3 = "deepseek-v3";
public static GenerationResult callWithMessage() throws ApiException, NoApiKeyException, InputRequiredException {
Generation gen = new Generation();
Message systemMsg = Message.builder()
@ -25,18 +30,19 @@ public class TestDeepSeek {
// 若没有配置环境变量请用百炼API Key将下行替换为.apiKey("sk-xxx")
.apiKey("sk-01d13a39e09844038322108ecdbd1bbc")
// 模型列表https://help.aliyun.com/zh/model-studio/getting-started/models
.model("deepseek-r1")
.model(V3)
.messages(Arrays.asList(systemMsg, userMsg))
.resultFormat(GenerationParam.ResultFormat.MESSAGE)
.build();
return gen.call(param);
}
public static void main(String[] args) {
try {
GenerationResult result = callWithMessage();
System.out.println(result.getOutput().getChoices().get(0).getMessage().getContent());
} catch (ApiException | NoApiKeyException | InputRequiredException e) {
System.err.println("错误信息:"+e.getMessage());
System.err.println("错误信息:" + e.getMessage());
System.out.println("请参考文档https://help.aliyun.com/zh/model-studio/developer-reference/error-code");
}
System.exit(0);

Loading…
Cancel
Save