3 Angajamente 819d2a4c89 ... 23f5e522ae

Autor SHA1 Permisiunea de a trimite mesaje. Dacă este dezactivată, utilizatorul nu va putea trimite nici un fel de mesaj Data
  sorelythrob 23f5e522ae 接入阿里百炼ai 2 săptămâni în urmă
  sorelythrob d2c3cc7007 接入阿里百炼ai 2 săptămâni în urmă
  sorelythrob 8306f378e1 接入阿里百炼ai 2 săptămâni în urmă

+ 3 - 5
webchat-aigc/src/main/java/com/webchat/aigc/llm/AliBaiLianAIService.java

@@ -1,9 +1,7 @@
 package com.webchat.aigc.llm;
 
 import com.webchat.aigc.config.properties.AliBaiLianLLMPropertiesConfig;
-import com.webchat.aigc.config.properties.DeepseekLLMPropertiesConfig;
 import com.webchat.common.util.llm.AliBaiLianAIClient;
-import com.webchat.common.util.llm.DeepSeekAIClient;
 import com.webchat.domain.vo.llm.ChatCompletionMessage;
 import com.webchat.domain.vo.llm.ChatCompletionRequest;
 import com.webchat.domain.vo.llm.ChatCompletionResponse;
@@ -34,9 +32,9 @@ public class AliBaiLianAIService extends AbstractLLMChatService {
      * @throws Exception
      */
     public ChatCompletionResponse chat(List<ChatCompletionMessage> messageList) throws Exception {
-        DeepSeekAIClient client = new DeepSeekAIClient(aliBaiLianLLMPropertiesConfig.getApiKey());
+        AliBaiLianAIClient client = new AliBaiLianAIClient(aliBaiLianLLMPropertiesConfig.getApiKey());
         final List<ChatCompletionMessage> messages = messageList;
-        return client.ChatCompletion(new ChatCompletionRequest(
+        return client.chatCompletion(new ChatCompletionRequest(
                 aliBaiLianLLMPropertiesConfig.getModel(),
                 messages,
                 2000,
@@ -60,7 +58,7 @@ public class AliBaiLianAIService extends AbstractLLMChatService {
         AliBaiLianAIClient client = new AliBaiLianAIClient(aliBaiLianLLMPropertiesConfig.getApiKey());
         final List<ChatCompletionMessage> messages = messageList;
         try {
-            client.ChatCompletionStream(new ChatCompletionRequest(
+            client.chatCompletionStream(new ChatCompletionRequest(
                     aliBaiLianLLMPropertiesConfig.getModel(),
                     messages,
                     2000,

+ 1 - 1
webchat-aigc/src/main/java/com/webchat/aigc/llm/LLMServiceFactory.java

@@ -50,7 +50,7 @@ public class LLMServiceFactory implements InitializingBean, ApplicationContextAw
         /**
          * bailian,阿里云的ai平台
          */
-        serviceMap.put(LlmModelEnum.BAILIAN.getModel(), applicationContext.getBean(DeepSeekAIService.class));
+        serviceMap.put(LlmModelEnum.BAILIAN.getModel(), applicationContext.getBean(AliBaiLianAIService.class));
 
         /**
          * ollama

+ 20 - 20
webchat-common/src/main/java/com/webchat/common/util/llm/AliBaiLianAIClient.java

@@ -58,25 +58,25 @@ public class AliBaiLianAIClient {
         return apiKey;
     }
 
-//    public ModelsList ListModels() throws IOException {
-//        OkHttpClient client = new OkHttpClient();
-//        okhttp3.Request request = new okhttp3.Request.Builder()
-//                .url(getModelsUrl())
-//                .addHeader("Authorization", "Bearer " + getApiKey())
-//                .build();
-//        try {
-//            okhttp3.Response response = client.newCall(request).execute();
-//            String body = response.body().string();
-//            Gson gson = new Gson();
-//            return gson.fromJson(body, ModelsList.class);
-//        } catch (IOException e) {
-//            e.printStackTrace();
-//            throw e;
-//        }
-//    }
-
-
-    public ChatCompletionResponse ChatCompletion(ChatCompletionRequest request) throws IOException {
+    public ModelsList ListModels() throws IOException {
+        OkHttpClient client = new OkHttpClient();
+        okhttp3.Request request = new okhttp3.Request.Builder()
+                .url(getModelsUrl())
+                .addHeader("Authorization", "Bearer " + getApiKey())
+                .build();
+        try {
+            okhttp3.Response response = client.newCall(request).execute();
+            String body = response.body().string();
+            Gson gson = new Gson();
+            return gson.fromJson(body, ModelsList.class);
+        } catch (IOException e) {
+            e.printStackTrace();
+            throw e;
+        }
+    }
+
+
+    public ChatCompletionResponse chatCompletion(ChatCompletionRequest request) throws IOException {
         request.stream = false;
         OkHttpClient client = new OkHttpClient.Builder()
                 .connectTimeout(2, TimeUnit.MINUTES)
@@ -104,7 +104,7 @@ public class AliBaiLianAIClient {
     }
 
     // return a stream of ChatCompletionStreamResponse
-    public Flowable<ChatCompletionStreamResponse> ChatCompletionStream(ChatCompletionRequest request) throws IOException {
+    public Flowable<ChatCompletionStreamResponse> chatCompletionStream(ChatCompletionRequest request) throws IOException {
         request.stream = true;
         OkHttpClient client = new OkHttpClient();
         okhttp3.MediaType mediaType = okhttp3.MediaType.parse("application/json");