Просмотр исходного кода

百度ERNIE_BOT_4替换原本调用

anderx лет назад: 2
Родитель
Сommit
cc09ca2970

+ 2 - 1
src/main/java/com/goafanti/ChatAI/service/impl/ChatAiServiceImpl.java

@@ -37,7 +37,8 @@ public class ChatAiServiceImpl implements ChatAiService {
         SseMap.sseEmitterMap.put(in.getUserId(), new SseResult(in.getUserId(), System.currentTimeMillis(), sseEmitter));
         try {
 //            先将数据返回,异步调用返回数据
-            baiduChatUtils.sendBaiduAiStream(in);
+//            baiduChatUtils.sendBaiduAiStream(in);
+            baiduChatUtils.sendERNIEBOT4Stream(in);
         } catch (IOException e) {
             e.printStackTrace();
             throw new BusinessException("文言一心调用失败"+e.getLocalizedMessage());

+ 15 - 2
src/main/java/com/goafanti/common/utils/BaiduChatUtils.java

@@ -37,6 +37,8 @@ public class BaiduChatUtils {
     private static final String BAIDU_CHAT_WXYY_URL="https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions?access_token=";
     /*Ernie-Lite地址*/
     private static final String BAIDU_CHAT_ERNIE_LITE_URL="https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/eb-instant?access_token=";
+    /*ERNIE_BOT_4*/
+    private static final String ERNIE_BOT_4="https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions_pro?access_token=";
     /*accessToken获取地址*/
     private static final String BAIDU_ACCESSTOKEN_URL="https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&";
 
@@ -45,9 +47,20 @@ public class BaiduChatUtils {
             .readTimeout(120000, TimeUnit.MILLISECONDS)
             .build();
 
-
     @Async
     public void sendBaiduAiStream(InputSendChat inputSendChat) throws IOException {
+        LoggerUtils.debug(getClass(),"ERNIE Bot");
+        sendStream(inputSendChat,BAIDU_CHAT_WXYY_URL);
+    }
+
+    @Async
+    public void sendERNIEBOT4Stream(InputSendChat inputSendChat) throws IOException {
+        LoggerUtils.debug(getClass(),"ERNIE_BOT_4");
+        sendStream(inputSendChat,ERNIE_BOT_4);
+    }
+
+    @Async
+    public void sendStream(InputSendChat inputSendChat,String httpUrl) throws IOException {
         SseResult res =  SseMap.sseEmitterMap.get(inputSendChat.getUserId());
 //        if (checkIp()){
 //            res.sseEmitter.send(new OutChatER(4004,"访问超过最大限制,陌生游客每天最多访问5次"));
@@ -60,7 +73,7 @@ public class BaiduChatUtils {
         OutputStream outputStream=null;
         try {
 
-            String baidu_url=BAIDU_CHAT_WXYY_URL+getRedisBaiduAccessToken();
+            String baidu_url=httpUrl+getRedisBaiduAccessToken();
             URL url = new URL(baidu_url);
             HttpURLConnection connection = (HttpURLConnection) url.openConnection();
             connection.setRequestMethod("POST");

+ 2 - 2
src/main/resources/props/config_local.properties

@@ -39,7 +39,7 @@ app.mobile.website=http://m.jishutao.com/1.0/template/index.html
 template.cacheable=false
 
 static.host=//ss.jishutao.com/client/1.2.11
-#portal.host=//ss.jishutao.com/portal/2.2.22
+portal.host=//ss.jishutao.com/portal/2.2.22
 skjt.host=//ss.jishutao.com/skjt/1.3
 
 
@@ -47,7 +47,7 @@ skjt.host=//ss.jishutao.com/skjt/1.3
 #static.host=//172.16.1.187/client/1.2.8
 #static.host=//172.16.0.255:3000/jitao/client/1.2.9
 #portal.host=//172.16.0.255:3000/jitao/portal/1.2.18
-portal.host=//172.16.1.187/portal/2.2.22
+#portal.host=//172.16.1.187/portal/2.2.22
 
 avatar.host=//ss.jishutao.com
 avatar.upload.host=//ss.jishutao.com/upload