|
@@ -23,6 +23,8 @@ public class DifyService {
|
|
|
private String url;
|
|
|
@Value("${DIFY.getAbstractKey}")
|
|
|
private String getAbstractKey;
|
|
|
+ @Value("${DIFY.getPctAbstractKey}")
|
|
|
+ private String getPctAbstractKey;
|
|
|
|
|
|
public String getCondensedAbstract(String text) throws Exception {
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
@@ -53,4 +55,34 @@ public class DifyService {
|
|
|
String content = jsonObject1.get("text").toString();
|
|
|
return DataUtils.unicodeDecode(content);
|
|
|
}
|
|
|
+
|
|
|
+ public String getPctCondensedAbstract(String text) throws Exception {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("content", text);
|
|
|
+ OAMessageDTO oaMessageDTO = new OAMessageDTO();
|
|
|
+ oaMessageDTO.setInputs(map);
|
|
|
+ oaMessageDTO.setResponseMode("blocking");
|
|
|
+ oaMessageDTO.setUser("1");
|
|
|
+
|
|
|
+ String param = new Gson().toJson(oaMessageDTO);
|
|
|
+ RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), param);
|
|
|
+ OkHttpClient client = new OkHttpClient.Builder()
|
|
|
+ .connectTimeout(600, TimeUnit.SECONDS)
|
|
|
+ .writeTimeout(600, TimeUnit.SECONDS)
|
|
|
+ .readTimeout(600, TimeUnit.SECONDS)
|
|
|
+ .build();
|
|
|
+ Request request = new Request.Builder()
|
|
|
+ .url(url + "workflows/run")
|
|
|
+ .addHeader("Authorization", "Bearer " + getPctAbstractKey)
|
|
|
+ .post(requestBody)
|
|
|
+ .build();
|
|
|
+ String res = Objects.requireNonNull(client.newCall(request).execute().body()).string();
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
+ String dataStr = jsonObject.get("data").toString();
|
|
|
+ JSONObject dataObject = JSONObject.parseObject(dataStr);
|
|
|
+ String outPuts = dataObject.get("outputs").toString();
|
|
|
+ JSONObject jsonObject1 = JSONObject.parseObject(outPuts);
|
|
|
+ String content = jsonObject1.get("text").toString();
|
|
|
+ return DataUtils.unicodeDecode(content);
|
|
|
+ }
|
|
|
}
|