Kaynağa Gözat

接入阿里百炼ai

sorelythrob 2 hafta önce
ebeveyn
işleme
d2c3cc7007

+ 1 - 3
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,7 +32,7 @@ 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(
                 aliBaiLianLLMPropertiesConfig.getModel(),

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

@@ -58,22 +58,22 @@ 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 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 {