|
|
@ -71,6 +71,8 @@ public class QandaPorcess implements Runnable { |
|
|
|
String answerStr = qandaRequest(authorization, model, temperature, topP, prompt, data); |
|
|
|
log.info("answerStr:" + answerStr); |
|
|
|
Map<String, Object> answer = JSONObject.parseObject(answerStr); |
|
|
|
Map<String, Object> results = new HashMap<String, Object>(16); |
|
|
|
results.put(Constants.ID, UUID.randomUUID().toString()); |
|
|
|
try { |
|
|
|
//请求成功,正常解析 |
|
|
|
List<Map<String, Object>> choices = (List<Map<String, Object>>) 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<String, Object> results = new HashMap<String, Object>(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; |
|
|
|
} |
|
|
|
} |
|
|
|