From bf651453943bb2993e5199cabd572bf7d32f0053 Mon Sep 17 00:00:00 2001 From: Liuyang <2746366019@qq.com> Date: Mon, 3 Mar 2025 11:41:51 +0800 Subject: [PATCH] =?UTF-8?q?refactor(llm):=20=E4=BC=98=E5=8C=96=20getCheckF?= =?UTF-8?q?ileList=20=E6=96=B9=E6=B3=95=E7=9A=84=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E5=92=8C=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 增加方法开始时的日志记录,包括 URL 和 Name 参数 -捕获异常时增加详细的错误日志,包括 URL、Name 和错误详情 - 在正常执行时增加请求完整路径的日志记录 - 增加 HTTP 请求完成后的日志记录,包括耗时、结果长度和结果摘要 -优化代码格式,调整缩进和空格 --- .../llm/service/http/TrainHttpService.java | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/http/TrainHttpService.java b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/http/TrainHttpService.java index cd1a68112..749658933 100644 --- a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/http/TrainHttpService.java +++ b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/http/TrainHttpService.java @@ -11,23 +11,17 @@ import kong.unirest.HttpResponse; import kong.unirest.Unirest; import kong.unirest.UnirestException; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.io.IOException; import java.io.InputStream; -import java.net.ConnectException; -import java.net.SocketTimeoutException; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; import java.util.stream.Stream; -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; - /** * 训练相关接口 */ @@ -359,10 +353,24 @@ public class TrainHttpService { public String getCheckFileList (String url, String name) { try { + log.info("开始获取文件列表 | URL参数: {}, Name参数: {}", url, name); String checkFileList = llmBackendProperties.getCheckFileList(); - return HttpUtils.get(url + checkFileList + name, null); - }catch (Exception e){ - log.error("获取文件列表失败:{}", e.getMessage()); + String fullUrl = url + checkFileList + name; + log.info("请求完整路径: {}", fullUrl); + + long startTime = System.currentTimeMillis(); + String result = HttpUtils.get(fullUrl, null); + long duration = System.currentTimeMillis() - startTime; + + log.info("HTTP请求完成 | 耗时: {}ms | 结果长度: {}", duration, (result != null ? result.length() : 0)); + if (result != null) { + log.info("结果摘要: {}", result.substring(0, Math.min(result.length(), 50))); + } else { + log.warn("返回空值"); + } + return result; + } catch (Exception e) { + log.error("获取文件列表异常 | URL: {} | Name: {} | 错误详情: {}", url, name, e.getMessage(), e); return null; } }