Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
brandkbs2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
shenjunjie
brandkbs2
Commits
2409421d
Commit
2409421d
authored
Jun 26, 2024
by
shenjunjie
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'release' into 'master'
Release See merge request
!543
parents
00cdb86d
5c3c6a63
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
2 deletions
+44
-2
src/main/java/com/zhiwei/brandkbs2/service/impl/ToolsetServiceImpl.java
+41
-2
src/main/resources/application-dev.properties
+1
-0
src/main/resources/application-local.properties
+1
-0
src/main/resources/application-prod.properties
+1
-0
No files found.
src/main/java/com/zhiwei/brandkbs2/service/impl/ToolsetServiceImpl.java
View file @
2409421d
...
@@ -85,6 +85,9 @@ public class ToolsetServiceImpl implements ToolsetService {
...
@@ -85,6 +85,9 @@ public class ToolsetServiceImpl implements ToolsetService {
@Value
(
"${toolset.articleSummary.url}"
)
@Value
(
"${toolset.articleSummary.url}"
)
private
String
articleSummaryUrl
;
private
String
articleSummaryUrl
;
@Value
(
"${toolset.db.articleSummary.url}"
)
private
String
dbArticleSummaryUrl
;
@Value
(
"${toolset.articleInfo.url}"
)
@Value
(
"${toolset.articleInfo.url}"
)
private
String
articleInfoUrl
;
private
String
articleInfoUrl
;
...
@@ -126,6 +129,8 @@ public class ToolsetServiceImpl implements ToolsetService {
...
@@ -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
=
"作为一名公关人员,将文章进行简短的中文摘要,摘要文字中需包括日期、地点等核心要素,其中日期不用包括年份,摘要起始必须为日期,字数少于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
int
ARTICLE_SUMMARY_LIMIT
=
1000
;
private
static
final
String
BRANDKBS_INTERACTION_SALT
=
"650bee0d393b382938003695"
;
private
static
final
String
BRANDKBS_INTERACTION_SALT
=
"650bee0d393b382938003695"
;
...
@@ -144,7 +149,7 @@ public class ToolsetServiceImpl implements ToolsetService {
...
@@ -144,7 +149,7 @@ public class ToolsetServiceImpl implements ToolsetService {
return
ResponseResult
.
failure
(
"链接解析异常"
);
return
ResponseResult
.
failure
(
"链接解析异常"
);
}
}
String
text
=
info
.
getString
(
"content"
);
String
text
=
info
.
getString
(
"content"
);
String
articleSummaryResult
=
getArticleSummaryResult
(
text
);
String
articleSummaryResult
=
get
DB
ArticleSummaryResult
(
text
);
// 剩余次数限制
// 剩余次数限制
String
redisKey
=
RedisUtil
.
getToolsetArticleSummaryLimitKey
(
UserThreadLocal
.
getProjectId
());
String
redisKey
=
RedisUtil
.
getToolsetArticleSummaryLimitKey
(
UserThreadLocal
.
getProjectId
());
String
redisResult
=
redisUtil
.
get
(
redisKey
);
String
redisResult
=
redisUtil
.
get
(
redisKey
);
...
@@ -201,7 +206,7 @@ public class ToolsetServiceImpl implements ToolsetService {
...
@@ -201,7 +206,7 @@ public class ToolsetServiceImpl implements ToolsetService {
JSONObject
json
=
getUrlInfo
(
entry
.
getKey
(),
UserThreadLocal
.
getProjectId
());
JSONObject
json
=
getUrlInfo
(
entry
.
getKey
(),
UserThreadLocal
.
getProjectId
());
text
=
Objects
.
nonNull
(
json
)
?
json
.
getString
(
"content"
)
:
null
;
text
=
Objects
.
nonNull
(
json
)
?
json
.
getString
(
"content"
)
:
null
;
}
}
String
articleSummaryResult
=
getArticleSummaryResult
(
text
);
String
articleSummaryResult
=
get
DB
ArticleSummaryResult
(
text
);
usedCount
=
usedCount
+
1
;
usedCount
=
usedCount
+
1
;
datas
.
add
(
new
ExportArticleSummaryDTO
(
String
.
valueOf
(
usedCount
),
entry
.
getKey
(),
entry
.
getValue
(),
articleSummaryResult
));
datas
.
add
(
new
ExportArticleSummaryDTO
(
String
.
valueOf
(
usedCount
),
entry
.
getKey
(),
entry
.
getValue
(),
articleSummaryResult
));
}
}
...
@@ -999,4 +1004,38 @@ public class ToolsetServiceImpl implements ToolsetService {
...
@@ -999,4 +1004,38 @@ public class ToolsetServiceImpl implements ToolsetService {
return
errorString
;
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
;
}
}
}
}
src/main/resources/application-dev.properties
View file @
2409421d
...
@@ -126,6 +126,7 @@ wx.accesstoken.url=https://ef.zhiweidata.com/smallprogram/api/codeToken/getToken
...
@@ -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=
wx.getuserphonenumber
=
https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=
#\u5DE5\u5177\u5E93\u76F8\u5173\u5916\u90E8\u63A5\u53E3
#\u5DE5\u5177\u5E93\u76F8\u5173\u5916\u90E8\u63A5\u53E3
toolset.articleSummary.url
=
https://zhiweidata.xyz/api/front/chat-swagger
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.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.interactionUpdate.url
=
https://zhiwei-middleware.zhiweidata.com/interact/insertData
toolset.interactionResult.url
=
https://zhiwei-middleware.zhiweidata.com/interact/findDataBatch
toolset.interactionResult.url
=
https://zhiwei-middleware.zhiweidata.com/interact/findDataBatch
...
...
src/main/resources/application-local.properties
View file @
2409421d
...
@@ -136,6 +136,7 @@ wx.accesstoken.url=https://ef.zhiweidata.com/smallprogram/api/codeToken/getToken
...
@@ -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=
wx.getuserphonenumber
=
https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=
#\u5DE5\u5177\u5E93\u76F8\u5173\u5916\u90E8\u63A5\u53E3
#\u5DE5\u5177\u5E93\u76F8\u5173\u5916\u90E8\u63A5\u53E3
toolset.articleSummary.url
=
https://zhiweidata.xyz/api/front/chat-swagger
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.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.interactionUpdate.url
=
https://zhiwei-middleware.zhiweidata.com/interact/insertData
toolset.interactionResult.url
=
https://zhiwei-middleware.zhiweidata.com/interact/findDataBatch
toolset.interactionResult.url
=
https://zhiwei-middleware.zhiweidata.com/interact/findDataBatch
...
...
src/main/resources/application-prod.properties
View file @
2409421d
...
@@ -126,6 +126,7 @@ wx.accesstoken.url=https://ef.zhiweidata.com/smallprogram/api/codeToken/getToken
...
@@ -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=
wx.getuserphonenumber
=
https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=
#\u5DE5\u5177\u5E93\u76F8\u5173\u5916\u90E8\u63A5\u53E3
#\u5DE5\u5177\u5E93\u76F8\u5173\u5916\u90E8\u63A5\u53E3
toolset.articleSummary.url
=
https://zhiweidata.xyz/api/front/chat-swagger
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.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.interactionUpdate.url
=
https://zhiwei-middleware.zhiweidata.com/interact/insertData
toolset.interactionResult.url
=
https://zhiwei-middleware.zhiweidata.com/interact/findDataBatch
toolset.interactionResult.url
=
https://zhiwei-middleware.zhiweidata.com/interact/findDataBatch
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment