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); }