tanlie 4 hónapja
szülő
commit
e0a579c130

+ 25 - 1
alibaba-ai/src/test/java/cn/qinys/ai/service/impl/ChatServiceImplTest.java

@@ -2,10 +2,16 @@ package cn.qinys.ai.service.impl;
 
 
 import com.alibaba.cloud.ai.dashscope.chat.DashScopeChatModel;
+import com.alibaba.cloud.ai.dashscope.image.DashScopeImageModel;
+import com.alibaba.cloud.ai.dashscope.image.DashScopeImageOptions;
 import jakarta.annotation.Resource;
 import org.junit.jupiter.api.Test;
+import org.springframework.ai.image.ImagePrompt;
+import org.springframework.ai.image.ImageResponse;
 import org.springframework.boot.test.context.SpringBootTest;
 
+import java.io.InputStream;
+
 /**
  * @author lie tan
  * @description
@@ -16,14 +22,32 @@ class ChatServiceImplTest {
 
     @Resource
     DashScopeChatModel chatModel;
+    @Resource
+    DashScopeImageModel imageModel;
 
 
     @Test
-    void stringCallTest() {
+    void textToText() {
         String call = chatModel.call("你是谁?");
         System.out.println(call);
 
     }
 
+    @Test
+    void testToImage() {
+        DashScopeImageOptions imageOptions = new DashScopeImageOptions();
+        imageOptions.setModel("wanx-v1");
+        ImageResponse call = imageModel.call(new ImagePrompt("画一只英短猫,全身是白色的,尾巴是深灰色的,尾巴末端也是白色的,头部半边耳朵也是深灰色的,头顶还有一个小点也是深灰色的", imageOptions));
+        String url = call.getResult().getOutput().getUrl();
+        System.out.println(url);
+
+        // 图片base64
+         String b64Json = call.getResult().getOutput().getB64Json();
+
+        // 接收文件流
+        //InputStream in =
+
+    }
+
 
 }