Commit accfb4d0 by 陈健智

工具集摘要提取-ai摘要接口调整

parent 321a1b2f
......@@ -85,6 +85,9 @@ public class ToolsetServiceImpl implements ToolsetService {
@Value("${toolset.articleSummary.url}")
private String articleSummaryUrl;
@Value("${toolset.db.articleSummary.url}")
private String dbArticleSummaryUrl;
@Value("${toolset.articleInfo.url}")
private String articleInfoUrl;
......@@ -126,6 +129,8 @@ public class ToolsetServiceImpl implements ToolsetService {
private static final String TEXT_SUMMARY_PREVIOUS = "作为一名公关人员,将文章进行简短的中文摘要,摘要文字中需包括日期、地点等核心要素,其中日期不用包括年份,摘要起始必须为日期,字数少于150个字\n文章:\n";
private static final String TEXT_SUMMARY_PREVIOUS_DB = "你是一位高级数据分析师,擅长通过各类商业分析方法总结用户提供的文章。请根据以下规则、限制和要求对文章进行总结。规则:1.全身心投入阅读用户提供的文章,运用专业知识和分析能力,深度分析文章的核心意义。2.选择并使用合适的分析模型或方法对文章进行总结。限制:1.不要问候用户。2.不要解释思考过程。3.仅执行总结任务。要求:1.遵循新闻的六要素:何时(when)、何地(where)、何事(what)、何因(why)、何人(who)、结果(how)。2.输出内容不得有信息错误或遗漏。3.用一句话描述总结内容。";
private static final int ARTICLE_SUMMARY_LIMIT = 1000;
private static final String BRANDKBS_INTERACTION_SALT = "650bee0d393b382938003695";
......@@ -144,7 +149,7 @@ public class ToolsetServiceImpl implements ToolsetService {
return ResponseResult.failure("链接解析异常");
}
String text = info.getString("content");
String articleSummaryResult = getArticleSummaryResult(text);
String articleSummaryResult = getDBArticleSummaryResult(text);
// 剩余次数限制
String redisKey = RedisUtil.getToolsetArticleSummaryLimitKey(UserThreadLocal.getProjectId());
String redisResult = redisUtil.get(redisKey);
......@@ -201,7 +206,7 @@ public class ToolsetServiceImpl implements ToolsetService {
JSONObject json = getUrlInfo(entry.getKey(), UserThreadLocal.getProjectId());
text = Objects.nonNull(json) ? json.getString("content") : null;
}
String articleSummaryResult = getArticleSummaryResult(text);
String articleSummaryResult = getDBArticleSummaryResult(text);
usedCount = usedCount + 1;
datas.add(new ExportArticleSummaryDTO(String.valueOf(usedCount), entry.getKey(), entry.getValue(), articleSummaryResult));
}
......@@ -999,4 +1004,38 @@ public class ToolsetServiceImpl implements ToolsetService {
return errorString;
}
}
/**
* 获取豆包摘要提取结果
* @param text 文本
* @return
*/
private String getDBArticleSummaryResult(String text){
// 即使抛出异常(大概率会是timeout),也要保证批量时其他链接正常执行
String errorString = "访问超时,请稍后重试此条数据";
if (Objects.isNull(text)){
return errorString;
}
try {
// 请求接口
JSONObject info = new JSONObject();
info.put("model", "DOUBAO_PRO_32K");
info.put("prompt", TEXT_SUMMARY_PREVIOUS_DB);
info.put("content", StringUtils.substring(text, 0, 5000));
// 请求参数 请求头
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<String> request = new HttpEntity<>(info.toJSONString(), headers);
ResponseEntity<String> response = restTemplate.postForEntity(dbArticleSummaryUrl, request, String.class);
JSONObject jsonObject = JSONObject.parseObject(response.getBody());
if (Objects.isNull(jsonObject) || 200 != jsonObject.getIntValue("code")) {
log.error("访问新摘要提取接口异常-返回信息:{}", JSONObject.toJSONString(jsonObject));
return errorString;
}
return jsonObject.getJSONObject("data").getString("content");
}catch (Exception e){
log.error("访问新摘要提取接口异常-", e);
return errorString;
}
}
}
......@@ -126,6 +126,7 @@ wx.accesstoken.url=https://ef.zhiweidata.com/smallprogram/api/codeToken/getToken
wx.getuserphonenumber=https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=
#\u5DE5\u5177\u5E93\u76F8\u5173\u5916\u90E8\u63A5\u53E3
toolset.articleSummary.url=https://zhiweidata.xyz/api/front/chat-swagger
toolset.db.articleSummary.url=https://zhiwei-middleware.zhiweidata.com/ai-model-serve/model/common
toolset.articleInfo.url=https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface/middleware/match?url={1}&projectId={2}&submitter={3}
toolset.interactionUpdate.url=https://zhiwei-middleware.zhiweidata.com/interact/insertData
toolset.interactionResult.url=https://zhiwei-middleware.zhiweidata.com/interact/findDataBatch
......
......@@ -136,6 +136,7 @@ wx.accesstoken.url=https://ef.zhiweidata.com/smallprogram/api/codeToken/getToken
wx.getuserphonenumber=https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=
#\u5DE5\u5177\u5E93\u76F8\u5173\u5916\u90E8\u63A5\u53E3
toolset.articleSummary.url=https://zhiweidata.xyz/api/front/chat-swagger
toolset.db.articleSummary.url=https://zhiwei-middleware.zhiweidata.com/ai-model-serve/model/common
toolset.articleInfo.url=https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface/middleware/match?url={1}&projectId={2}&submitter={3}
toolset.interactionUpdate.url=https://zhiwei-middleware.zhiweidata.com/interact/insertData
toolset.interactionResult.url=https://zhiwei-middleware.zhiweidata.com/interact/findDataBatch
......
......@@ -126,6 +126,7 @@ wx.accesstoken.url=https://ef.zhiweidata.com/smallprogram/api/codeToken/getToken
wx.getuserphonenumber=https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=
#\u5DE5\u5177\u5E93\u76F8\u5173\u5916\u90E8\u63A5\u53E3
toolset.articleSummary.url=https://zhiweidata.xyz/api/front/chat-swagger
toolset.db.articleSummary.url=https://zhiwei-middleware.zhiweidata.com/ai-model-serve/model/common
toolset.articleInfo.url=https://yuqing.zhiweidata.com/qbjcbackPhoenix/interface/middleware/match?url={1}&projectId={2}&submitter={3}
toolset.interactionUpdate.url=https://zhiwei-middleware.zhiweidata.com/interact/insertData
toolset.interactionResult.url=https://zhiwei-middleware.zhiweidata.com/interact/findDataBatch
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment