孙永军 преди 1 година
родител
ревизия
34bc33730a
променени са 1 файла, в които са добавени 9 реда и са изтрити 7 реда
  1. 9 7
      src/main/java/com/sxtvs/open/api/chat/service/impl/KimiChatServiceImpl.java

+ 9 - 7
src/main/java/com/sxtvs/open/api/chat/service/impl/KimiChatServiceImpl.java

@@ -78,12 +78,14 @@ log.info("发送kimi数据 {}",  JSON.toJSONString(kimiRequest));
                 .thenAccept(resp -> {
 //                    System.out.println(x);
                     log.info("流数据 -- {}",resp);
-                    Arrays.stream(resp.split("\n")).forEach(x -> {
-                        if(!TextUtils.isEmpty(x.replaceAll("\n", "").trim())){
-                            sseService.sendData( dataId, x );
-                            stream2db(x.substring(6), dataId);
-                        }
-                    });
+                    if (!TextUtils.isEmpty(resp)){
+                        Arrays.stream(resp.split("\n")).forEach(x -> {
+                            if(!TextUtils.isEmpty(x.replaceAll("\n", "").trim())){
+                                sseService.sendData( dataId, x );
+                                stream2db(x.substring(6), dataId);
+                            }
+                        });
+                    }
 
                 })
                 .join();
@@ -96,7 +98,7 @@ log.info("发送kimi数据 {}",  JSON.toJSONString(kimiRequest));
         try{
             kimiResponse =  JSON.parseObject(resp, KimiStreamResponse.class);
         }catch (Exception e){
-            log.error("解析失败 -- ",resp);
+            log.error("解析失败 -- {}",resp);
             return;
         }