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 @@ - +