From 24681c81c09022f584a57006f2534b5f74723414 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期二, 30 六月 2026 09:27:31 +0800
Subject: [PATCH] 初始化项目

---
 yudao-module-ai/src/test/java/cn/iocoder/yudao/module/ai/framework/ai/core/model/chat/MoonshotChatModelTests.java |   46 ++++++++++++++++++++++++++++++----------------
 1 files changed, 30 insertions(+), 16 deletions(-)

diff --git a/yudao-module-ai/src/test/java/cn/iocoder/yudao/module/ai/framework/ai/core/model/chat/MoonshotChatModelTests.java b/yudao-module-ai/src/test/java/cn/iocoder/yudao/module/ai/framework/ai/core/model/chat/MoonshotChatModelTests.java
index b50ab80..22d04bf 100644
--- a/yudao-module-ai/src/test/java/cn/iocoder/yudao/module/ai/framework/ai/core/model/chat/MoonshotChatModelTests.java
+++ b/yudao-module-ai/src/test/java/cn/iocoder/yudao/module/ai/framework/ai/core/model/chat/MoonshotChatModelTests.java
@@ -1,19 +1,24 @@
 package cn.iocoder.yudao.module.ai.framework.ai.core.model.chat;
 
+import cn.hutool.system.SystemUtil;
+import cn.iocoder.yudao.module.ai.framework.ai.core.model.moonshot.MoonshotChatModel;
 import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Test;
-import org.springaicommunity.moonshot.MoonshotChatModel;
-import org.springaicommunity.moonshot.MoonshotChatOptions;
-import org.springaicommunity.moonshot.api.MoonshotApi;
 import org.springframework.ai.chat.messages.Message;
 import org.springframework.ai.chat.messages.SystemMessage;
 import org.springframework.ai.chat.messages.UserMessage;
 import org.springframework.ai.chat.model.ChatResponse;
 import org.springframework.ai.chat.prompt.Prompt;
+import org.springframework.ai.deepseek.DeepSeekChatModel;
+import org.springframework.ai.deepseek.DeepSeekChatOptions;
+import org.springframework.ai.deepseek.api.DeepSeekApi;
 import reactor.core.publisher.Flux;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Objects;
+
+import static cn.iocoder.yudao.module.ai.util.AiUtils.validateApiKey;
 
 /**
  * {@link MoonshotChatModel} 鐨勯泦鎴愭祴璇�
@@ -22,18 +27,27 @@
  */
 public class MoonshotChatModelTests {
 
-    private final MoonshotChatModel chatModel = MoonshotChatModel.builder()
-            .moonshotApi(MoonshotApi.builder()
-                    .apiKey("sk-aHYYV1SARscItye5QQRRNbXij4fy65Ee7pNZlC9gsSQnUKXA") // 瀵嗛挜
+    private static final String API_KEY = SystemUtil.get("MOONSHOT_API_KEY",
+            "sk-xxxx"); // 鎸夐渶鏀规垚浣犵殑 Moonshot API Key
+    private static final String MODEL = SystemUtil.get("MOONSHOT_MODEL",
+            MoonshotChatModel.MODEL_DEFAULT);
+
+    private final MoonshotChatModel chatModel = new MoonshotChatModel(DeepSeekChatModel.builder()
+            .deepSeekApi(DeepSeekApi.builder()
+                    .baseUrl(MoonshotChatModel.BASE_URL)
+                    .completionsPath(MoonshotChatModel.COMPLETE_PATH)
+                    .apiKey(API_KEY)
                     .build())
-            .defaultOptions(MoonshotChatOptions.builder()
-                    .model("kimi-k2-0711-preview") // 妯″瀷
+            .options(DeepSeekChatOptions.builder()
+                    .model(MODEL)
+                    .temperature(1D)
                     .build())
-            .build();
+            .build());
 
     @Test
     @Disabled
     public void testCall() {
+        validateApiKey(API_KEY);
         // 鍑嗗鍙傛暟
         List<Message> messages = new ArrayList<>();
         messages.add(new SystemMessage("浣犳槸涓�涓紭璐ㄧ殑鏂囪█鏂囦綔鑰咃紝鐢ㄦ枃瑷�鏂囨弿杩扮潃鍚勫煄甯傜殑浜烘枃椋庢櫙銆�"));
@@ -43,12 +57,13 @@
         ChatResponse response = chatModel.call(new Prompt(messages));
         // 鎵撳嵃缁撴灉
         System.out.println(response);
-        System.out.println(response.getResult().getOutput());
+        System.out.println(Objects.requireNonNull(response.getResult()).getOutput());
     }
 
     @Test
     @Disabled
     public void testStream() {
+        validateApiKey(API_KEY);
         // 鍑嗗鍙傛暟
         List<Message> messages = new ArrayList<>();
         messages.add(new SystemMessage("浣犳槸涓�涓紭璐ㄧ殑鏂囪█鏂囦綔鑰咃紝鐢ㄦ枃瑷�鏂囨弿杩扮潃鍚勫煄甯傜殑浜烘枃椋庢櫙銆�"));
@@ -59,20 +74,19 @@
         // 鎵撳嵃缁撴灉
         flux.doOnNext(response -> {
 //            System.out.println(response);
-            System.out.println(response.getResult().getOutput());
+            System.out.println(Objects.requireNonNull(response.getResult()).getOutput());
         }).then().block();
     }
 
-    // TODO @鑺嬭壙锛氭殏鏃舵病瑙f瀽 reasoning_content 缁撴灉锛岄渶瑕佺瓑瀹樻柟淇
     @Test
     @Disabled
     public void testStream_thinking() {
+        validateApiKey(API_KEY);
         // 鍑嗗鍙傛暟
         List<Message> messages = new ArrayList<>();
         messages.add(new UserMessage("璇︾粏鍒嗘瀽涓嬶紝濡備綍璁捐涓�涓數鍟嗙郴缁燂紵"));
-        MoonshotChatOptions options = MoonshotChatOptions.builder()
-//                .model("kimi-k2-0711-preview")
-                .model("kimi-thinking-preview")
+        DeepSeekChatOptions options = DeepSeekChatOptions.builder()
+                .model(MODEL)
                 .build();
 
         // 璋冪敤
@@ -80,7 +94,7 @@
         // 鎵撳嵃缁撴灉
         flux.doOnNext(response -> {
 //            System.out.println(response);
-            System.out.println(response.getResult().getOutput());
+            System.out.println(Objects.requireNonNull(response.getResult()).getOutput());
         }).then().block();
     }
 

--
Gitblit v1.9.3