diff --git a/service-ai/service-ai-chat/pom.xml b/service-ai/service-ai-chat/pom.xml
index e2cb1e5..e85b63f 100644
--- a/service-ai/service-ai-chat/pom.xml
+++ b/service-ai/service-ai-chat/pom.xml
@@ -20,6 +20,21 @@
org.springframework.ai
spring-ai-starter-model-deepseek
+
+ org.springframework.ai
+ spring-ai-starter-model-openai
+ test
+
+
+ org.noear
+ solon-ai
+ test
+
+
+ org.noear
+ solon-ai-dialect-openai
+ test
+
diff --git a/service-ai/service-ai-chat/src/test/java/com/lanyuanxiaoyao/service/ai/chat/TestSpringAIToolChat.java b/service-ai/service-ai-chat/src/test/java/com/lanyuanxiaoyao/service/ai/chat/TestSpringAIToolChat.java
index ce976ea..e55eb78 100644
--- a/service-ai/service-ai-chat/src/test/java/com/lanyuanxiaoyao/service/ai/chat/TestSpringAIToolChat.java
+++ b/service-ai/service-ai-chat/src/test/java/com/lanyuanxiaoyao/service/ai/chat/TestSpringAIToolChat.java
@@ -1,71 +1,155 @@
package com.lanyuanxiaoyao.service.ai.chat;
+import java.io.IOException;
import java.net.http.HttpClient;
-import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
+import java.util.Arrays;
+import java.util.List;
+import org.noear.solon.ai.rag.Document;
+import org.noear.solon.ai.reranking.RerankingModel;
import org.springframework.ai.chat.client.ChatClient;
-import org.springframework.ai.deepseek.DeepSeekChatModel;
-import org.springframework.ai.deepseek.DeepSeekChatOptions;
-import org.springframework.ai.deepseek.api.DeepSeekApi;
-import org.springframework.ai.tool.ToolCallback;
-import org.springframework.ai.tool.definition.ToolDefinition;
+import org.springframework.ai.document.MetadataMode;
+import org.springframework.ai.embedding.EmbeddingModel;
+import org.springframework.ai.openai.OpenAiChatModel;
+import org.springframework.ai.openai.OpenAiChatOptions;
+import org.springframework.ai.openai.OpenAiEmbeddingModel;
+import org.springframework.ai.openai.OpenAiEmbeddingOptions;
+import org.springframework.ai.openai.api.OpenAiApi;
+import org.springframework.core.io.FileSystemResource;
import org.springframework.http.client.JdkClientHttpRequestFactory;
import org.springframework.http.client.reactive.JdkClientHttpConnector;
+import org.springframework.util.MimeTypeUtils;
import org.springframework.web.client.RestClient;
import org.springframework.web.reactive.function.client.WebClient;
-import reactor.core.Disposable;
/**
* @author lanyuanxiaoyao
* @version 20250514
*/
-@SuppressWarnings("NullableProblems")
public class TestSpringAIToolChat {
- public static void main(String[] args) {
- ChatClient client = ChatClient.builder(
- DeepSeekChatModel.builder()
- .deepSeekApi(
- DeepSeekApi.builder()
- .baseUrl("http://132.121.206.65:10086/v1")
+ public static void main(String[] args) throws IOException {
+ testChatModel();
+ testVisualModel();
+ // testEmbeddingModel();
+ // testRerankingModel();
+ }
+
+ private static void testChatModel() {
+ for (String model : List.of(
+ "Qwen3/qwen3-0.6b",
+ "Qwen3/qwen3-1.7b",
+ "Qwen3/qwen3-4b",
+ "Qwen3/qwen3-4b-q4km",
+ "Qwen3/qwen3-8b-q4km"
+ )) {
+ ChatClient client = chatClient(model);
+ String content = client.prompt()
+ .user("你好")
+ .call()
+ .content();
+ System.out.println(content);
+ }
+ }
+
+ private static void testVisualModel() {
+ for (String model : List.of(
+ "Qwen2.5/qwen2.5-vl-7b",
+ "Qwen2.5/qwen2.5-vl-7b-q4km",
+ "Qwen2.5/qwen2.5-vl-3b-instruct",
+ "Qwen2.5/qwen2.5-vl-3b-instruct-awq",
+ "Qwen2.5/qwen2.5-vl-7b-instruct",
+ "Qwen2.5/qwen2.5-vl-7b-instruct-awq",
+ "MiniCPM/minicpm-o-2.6-7.6b",
+ "MiniCPM/minicpm-o-2.6-7.6b-q4km"
+
+ )) {
+ ChatClient client = chatClient(model);
+ String content = client.prompt()
+ .user(spec -> spec.text("图片中有什么").media(MimeTypeUtils.IMAGE_PNG, new FileSystemResource("/Users/lanyuanxiaoyao/Pictures/deepseek.png")))
+ .call()
+ .content();
+ System.out.println(content);
+ }
+ }
+
+ private static void testEmbeddingModel() {
+ for (String model : List.of(
+ "Qwen3/qwen3-embedding-0.6b",
+ "Qwen3/qwen3-embedding-4b",
+ "Qwen3/qwen3-embedding-4b-q4km",
+ "Qwen3/qwen3-embedding-8b-q4km",
+ "BGE/bge-m3",
+ "BGE/bge-m3-q4km",
+ "MiniCPM/minicpm-embedding",
+ "MiniCPM/minicpm-embedding-light"
+ )) {
+ EmbeddingModel embeddingModel = embeddingModel(model);
+ float[] worlds = embeddingModel.embed("Hello world");
+ System.out.println(Arrays.toString(worlds));
+ }
+ }
+
+ private static void testRerankingModel() throws IOException {
+ for (String model : List.of(
+ "BGE/beg-reranker-v2",
+ "MiniCPM/minicpm-reranker",
+ "MiniCPM/minicpm-reranker-light",
+ "BGE/beg-reranker-v2",
+ "BGE/beg-reranker-v2-q4km"
+ )) {
+ RerankingModel rerankingModel = rerankingModel(model);
+ List list = rerankingModel.rerank(
+ "你好",
+ List.of(
+ new Document("go go go,滚犊子"),
+ new Document("我是tom,你最近过得好吗?"),
+ new Document("666,你就是大聪明")
+ )
+ );
+ list.forEach(System.out::println);
+ }
+ }
+
+ private static ChatClient chatClient(String model) {
+ return ChatClient.builder(
+ OpenAiChatModel.builder()
+ .openAiApi(
+ OpenAiApi.builder()
+ .baseUrl("http://132.121.206.65:10086")
.apiKey("*XMySqV%>hR&v>>g*NwCs3tpQ5FVMFEF2VHVTjhR&v>>g*NwCs3tpQ5FVMFEF2VHVTjhR&v>>g*NwCs3tpQ5FVMFEF2VHVTj