From 323793018e9169713e488a348bb9e3d63bbe63f4 Mon Sep 17 00:00:00 2001 From: maojian <550076202@qq.com> Date: Tue, 3 Jun 2025 14:08:07 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B6=85=E6=97=B6=E6=97=B6=E9=97=B4=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/bfd/qanda/process/QandaPorcess.java | 22 ++++++++++++++++++++-- src/main/resources/logback-spring.xml | 6 +++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/bfd/qanda/process/QandaPorcess.java b/src/main/java/com/bfd/qanda/process/QandaPorcess.java index f046dcc..3da542f 100644 --- a/src/main/java/com/bfd/qanda/process/QandaPorcess.java +++ b/src/main/java/com/bfd/qanda/process/QandaPorcess.java @@ -71,6 +71,8 @@ public class QandaPorcess implements Runnable { String answerStr = qandaRequest(authorization, model, temperature, topP, prompt, data); log.info("answerStr:" + answerStr); Map answer = JSONObject.parseObject(answerStr); + Map results = new HashMap(16); + results.put(Constants.ID, UUID.randomUUID().toString()); try { //请求成功,正常解析 List> choices = (List>) answer.get(Constants.CHOICES); @@ -79,10 +81,17 @@ public class QandaPorcess implements Runnable { } catch (Exception e) { log.error("问答接口响应体异常:{}", answerStr, e); // TODO: handle exception + results.put("isLast", 1); + results.put("content", e.getMessage()); + result.put(Constants.RESULTS, JSONObject.toJSONString(results)); + result.put(Constants.MESSAGE, "异常"); + result.put(Constants.STATUS, 2); + task.put(Constants.RESULT, result); + //发送kafka + springBootKafka.send(topic, JSONObject.toJSONString(task)); + log.info("数据流转至下游-------"); continue; } - Map results = new HashMap(16); - results.put(Constants.ID, UUID.randomUUID().toString()); results.put(Constants.CONTENT, chatContent.toString()); if (fieldType != 0) { results.remove(Constants.CONTENT); @@ -96,6 +105,15 @@ public class QandaPorcess implements Runnable { } catch (Exception e) { log.error("问答接口响应体异常:{}", answerStr, e); // TODO: handle exception + results.put("isLast", 1); + results.put("content", e.getMessage()); + result.put(Constants.RESULTS, JSONObject.toJSONString(results)); + result.put(Constants.MESSAGE, "异常"); + result.put(Constants.STATUS, 2); + task.put(Constants.RESULT, result); + //发送kafka + springBootKafka.send(topic, JSONObject.toJSONString(task)); + log.info("数据流转至下游-------"); continue; } } diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml index 549c5ae..e7b4886 100644 --- a/src/main/resources/logback-spring.xml +++ b/src/main/resources/logback-spring.xml @@ -3,12 +3,12 @@ - %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %line %-5level %logger{50} - %msg%n - + --> @@ -31,6 +31,6 @@ - +