From f828983969d5886748d9c8cc291f5b14e668f2c6 Mon Sep 17 00:00:00 2001 From: xupei Date: Tue, 24 Jun 2025 16:41:41 +0800 Subject: [PATCH] =?UTF-8?q?BUGFIX:=E5=AF=B9=E8=AF=9D=20=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=E5=8F=B0=E8=BE=93=E5=87=BA=E6=94=B9=E4=B8=BA=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ai/da/service/impl/LLMServiceImpl.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/ai/da/service/impl/LLMServiceImpl.java b/src/main/java/com/ai/da/service/impl/LLMServiceImpl.java index 5fc7b66d..94efec5d 100644 --- a/src/main/java/com/ai/da/service/impl/LLMServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/LLMServiceImpl.java @@ -28,6 +28,7 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.text.StringEscapeUtils; import org.checkerframework.checker.units.qual.C; import org.springframework.beans.factory.annotation.Value; @@ -49,6 +50,7 @@ import java.util.*; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +@Slf4j @Service public class LLMServiceImpl implements LLMService { @@ -128,7 +130,7 @@ public class LLMServiceImpl implements LLMService { chatMessageMapper.insert(userMessage); try (OutputStream os = conn.getOutputStream()) { - System.out.println(jsonBodyObject.toJSONString()); + log.info(jsonBodyObject.toJSONString()); byte[] input = jsonBodyObject.toJSONString().getBytes(StandardCharsets.UTF_8); os.write(input, 0, input.length); } @@ -150,7 +152,7 @@ public class LLMServiceImpl implements LLMService { line = line.trim(); if (!line.isEmpty() && line.startsWith("data: ")) { String jsonStr = line.substring(6); - System.out.println(jsonStr); + log.info(jsonStr); JSONObject json = JSON.parseObject(jsonStr); String status = json.getString("status"); if (!StringUtils.isEmpty(status)) { @@ -219,7 +221,7 @@ public class LLMServiceImpl implements LLMService { emitter.complete(); } catch (Exception e) { - System.out.println("走进异常"); + log.info("走进异常"); emitter.completeWithError(e); } }); @@ -278,7 +280,7 @@ public class LLMServiceImpl implements LLMService { chatMessageMapper.insert(userMessage); try (OutputStream os = conn.getOutputStream()) { - System.out.println(jsonBodyObject.toJSONString()); + log.info(jsonBodyObject.toJSONString()); byte[] input = jsonBodyObject.toJSONString().getBytes(StandardCharsets.UTF_8); os.write(input, 0, input.length); } @@ -298,7 +300,7 @@ public class LLMServiceImpl implements LLMService { line = line.trim(); if (!line.isEmpty() && line.startsWith("data: ")) { String jsonStr = line.substring(12); - System.out.println(jsonStr); + log.info(jsonStr); JSONObject json = JSON.parseObject(jsonStr); String type = json.getString("type"); if (!StringUtils.isEmpty(type)) { @@ -387,7 +389,7 @@ public class LLMServiceImpl implements LLMService { } emitter.complete(); } catch (Exception e) { - System.out.println("走进异常: " + e.getMessage()); + log.info("走进异常: {}", e.getMessage()); e.printStackTrace(); // 详细栈信息 emitter.completeWithError(e); }