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
2a3057da
Commit
2a3057da
authored
Jul 01, 2024
by
shenjunjie
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/feature' into feature
parents
9a3b79e2
0bd6a45b
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
4 deletions
+66
-4
src/main/java/com/zhiwei/brandkbs2/service/impl/ToolsetServiceImpl.java
+63
-4
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 @
2a3057da
...
...
@@ -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
=
get
DB
ArticleSummaryResult
(
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
=
get
DB
ArticleSummaryResult
(
text
);
usedCount
=
usedCount
+
1
;
datas
.
add
(
new
ExportArticleSummaryDTO
(
String
.
valueOf
(
usedCount
),
entry
.
getKey
(),
entry
.
getValue
(),
articleSummaryResult
));
}
...
...
@@ -729,10 +734,14 @@ public class ToolsetServiceImpl implements ToolsetService {
?
data
.
getPlatformType
()
:
"网媒"
,
data
.
getChannel
()));
// 1.分别将等级为S,A,B,C的渠道各自加和
if
(
Objects
.
nonNull
(
channelInfluence
)){
// 2024/5/21修改:
无论表中是否
匹配,当类型为D,取值=1
// 2024/5/21修改:
即使表中
匹配,当类型为D,取值=1
if
(
Objects
.
equals
(
"D"
,
channelInfluence
.
getLevel
())){
channelInfluence
.
setInfluence
(
1
d
);
}
// 对于表中匹配上的非D级渠道:当表中的渠道影响力为0或1时,给予对应等级的默认值
if
(!
Objects
.
equals
(
"D"
,
channelInfluence
.
getLevel
())
&&
(
0
==
channelInfluence
.
getInfluence
()
||
1
==
channelInfluence
.
getInfluence
())){
channelInfluence
.
setInfluence
(
getMatchedDefaultChannelInf
(
channelInfluence
.
getLevel
()));
}
levelSumH
.
compute
(
channelInfluence
.
getLevel
(),
(
k
,
v
)
->
Objects
.
isNull
(
v
)
?
channelInfluence
.
getInfluence
()
:
BigDecimal
.
valueOf
(
v
).
add
(
BigDecimal
.
valueOf
(
channelInfluence
.
getInfluence
())).
doubleValue
());
...
...
@@ -759,6 +768,21 @@ public class ToolsetServiceImpl implements ToolsetService {
return
BigDecimal
.
valueOf
(
result
).
setScale
(
1
,
RoundingMode
.
HALF_UP
).
doubleValue
();
}
private
double
getMatchedDefaultChannelInf
(
String
level
){
switch
(
level
){
case
"A"
:
return
72.1
;
case
"B"
:
return
57.1
;
case
"C"
:
return
37.5
;
case
"S"
:
return
88.1
;
default
:
return
1
d
;
}
}
/**
* 计算实时传播力(RMI)
* @param data
...
...
@@ -880,7 +904,8 @@ public class ToolsetServiceImpl implements ToolsetService {
* @return
*/
private
double
computeFinalInf
(
double
inf
,
double
RMI
){
return
BigDecimal
.
valueOf
(
inf
).
add
(
BigDecimal
.
valueOf
(
RMI
)).
divide
(
BigDecimal
.
valueOf
(
2
),
1
,
RoundingMode
.
HALF_UP
).
doubleValue
();
double
finalInf
=
BigDecimal
.
valueOf
(
inf
).
add
(
BigDecimal
.
valueOf
(
RMI
)).
divide
(
BigDecimal
.
valueOf
(
2
),
1
,
RoundingMode
.
HALF_UP
).
doubleValue
();
return
finalInf
>
1
?
finalInf
:
1
d
;
}
/**
...
...
@@ -999,4 +1024,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
;
}
}
}
src/main/resources/application-dev.properties
View file @
2a3057da
...
...
@@ -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
...
...
src/main/resources/application-local.properties
View file @
2a3057da
...
...
@@ -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
...
...
src/main/resources/application-prod.properties
View file @
2a3057da
...
...
@@ -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
...
...
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