Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
poc-api
Project
Project
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
poc
poc-api
Commits
e87e29c1
Commit
e87e29c1
authored
Jan 21, 2025
by
alex yao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:插件积分按调用扣减
parent
2d4f8b5f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
4 deletions
+35
-4
AgentApplicationInfoRestImpl.java
...t_application/rest/impl/AgentApplicationInfoRestImpl.java
+6
-1
AgentApplicationTools.java
...om/poc/agent_application/utils/AgentApplicationTools.java
+21
-0
PointDeductionRulesServiceImpl.java
...equity/aggregate/impl/PointDeductionRulesServiceImpl.java
+1
-1
AgentApplicationApiServiceImpl.java
...expose/aggregate/impl/AgentApplicationApiServiceImpl.java
+3
-1
AgentApplicationServiceImpl.java
...oc/expose/aggregate/impl/AgentApplicationServiceImpl.java
+4
-1
No files found.
src/main/java/cn/com/poc/agent_application/rest/impl/AgentApplicationInfoRestImpl.java
View file @
e87e29c1
...
@@ -12,6 +12,7 @@ import cn.com.poc.agent_application.utils.AgentApplicationTools;
...
@@ -12,6 +12,7 @@ import cn.com.poc.agent_application.utils.AgentApplicationTools;
import
cn.com.poc.common.annotation.RedisLimit
;
import
cn.com.poc.common.annotation.RedisLimit
;
import
cn.com.poc.common.constant.CommonConstant
;
import
cn.com.poc.common.constant.CommonConstant
;
import
cn.com.poc.common.utils.BlContext
;
import
cn.com.poc.common.utils.BlContext
;
import
cn.com.poc.common.utils.JsonUtils
;
import
cn.com.poc.data_analyze.aggregate.DataAnalyzeReportService
;
import
cn.com.poc.data_analyze.aggregate.DataAnalyzeReportService
;
import
cn.com.poc.data_analyze.constants.DataAnalyzeChannelEnum
;
import
cn.com.poc.data_analyze.constants.DataAnalyzeChannelEnum
;
import
cn.com.poc.equity.aggregate.MemberEquityService
;
import
cn.com.poc.equity.aggregate.MemberEquityService
;
...
@@ -25,6 +26,8 @@ import cn.com.poc.equity.service.BizPointDeductionRulesService;
...
@@ -25,6 +26,8 @@ import cn.com.poc.equity.service.BizPointDeductionRulesService;
import
cn.com.poc.knowledge.aggregate.KnowledgeService
;
import
cn.com.poc.knowledge.aggregate.KnowledgeService
;
import
cn.com.poc.support.security.oauth.entity.UserBaseEntity
;
import
cn.com.poc.support.security.oauth.entity.UserBaseEntity
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.dialogue.Tool
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.dialogue.Tool
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.function.FunctionCallResult
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.LargeModelFunctionEnum
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.long_memory.AgentLongMemoryEntity
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.long_memory.AgentLongMemoryEntity
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.long_memory.LongMemory
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.long_memory.LongMemory
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.memory_variable_writer.MemoryVariableWriter
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.memory_variable_writer.MemoryVariableWriter
;
...
@@ -257,8 +260,10 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
...
@@ -257,8 +260,10 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
Float
temperature
=
dto
.
getTemperature
()
==
null
?
infoEntity
.
getTemperature
()
:
dto
.
getTemperature
();
Float
temperature
=
dto
.
getTemperature
()
==
null
?
infoEntity
.
getTemperature
()
:
dto
.
getTemperature
();
String
agentSystem
=
StringUtils
.
isBlank
(
dto
.
getAgentSystem
())
?
infoEntity
.
getAgentSystem
()
:
dto
.
getAgentSystem
();
String
agentSystem
=
StringUtils
.
isBlank
(
dto
.
getAgentSystem
())
?
infoEntity
.
getAgentSystem
()
:
dto
.
getAgentSystem
();
// 判断是否调用function
List
<
Tool
>
deductionTools
=
AgentApplicationTools
.
checkPluginUse
(
dto
.
getMessages
(),
tools
);
//计算扣分数
//计算扣分数
Long
pointDeductionNum
=
pointDeductionRulesService
.
calculatePointDeductionNum
(
model
,
infoEntity
.
getCommunicationTurn
(),
t
ools
);
Long
pointDeductionNum
=
pointDeductionRulesService
.
calculatePointDeductionNum
(
model
,
infoEntity
.
getCommunicationTurn
(),
deductionT
ools
);
AgentUseModifyEventInfo
agentUseModifyEventInfo
=
new
AgentUseModifyEventInfo
();
AgentUseModifyEventInfo
agentUseModifyEventInfo
=
new
AgentUseModifyEventInfo
();
agentUseModifyEventInfo
.
setAgentId
(
agentId
);
agentUseModifyEventInfo
.
setAgentId
(
agentId
);
agentUseModifyEventInfo
.
setIsPublish
(
CommonConstant
.
IsDeleted
.
N
);
agentUseModifyEventInfo
.
setIsPublish
(
CommonConstant
.
IsDeleted
.
N
);
...
...
src/main/java/cn/com/poc/agent_application/utils/AgentApplicationTools.java
View file @
e87e29c1
...
@@ -4,11 +4,14 @@ import cn.com.poc.agent_application.entity.Variable;
...
@@ -4,11 +4,14 @@ import cn.com.poc.agent_application.entity.Variable;
import
cn.com.poc.common.constant.CommonConstant
;
import
cn.com.poc.common.constant.CommonConstant
;
import
cn.com.poc.common.utils.DocumentLoad
;
import
cn.com.poc.common.utils.DocumentLoad
;
import
cn.com.poc.common.utils.JsonUtils
;
import
cn.com.poc.common.utils.JsonUtils
;
import
cn.com.poc.common.utils.SpringUtils
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.dialogue.Message
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.dialogue.Message
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.dialogue.MultiContent
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.dialogue.MultiContent
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.dialogue.Tool
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.dialogue.Tool
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.function.FunctionCallResult
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.LargeModelFunctionEnum
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.LargeModelFunctionEnum
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.memory_variable_writer.MemoryVariableWriter
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.memory_variable_writer.MemoryVariableWriter
;
import
cn.com.poc.thirdparty.service.LLMService
;
import
cn.com.yict.framemax.core.i18n.I18nMessageException
;
import
cn.com.yict.framemax.core.i18n.I18nMessageException
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
...
@@ -155,4 +158,22 @@ public class AgentApplicationTools {
...
@@ -155,4 +158,22 @@ public class AgentApplicationTools {
}
}
return
imageUrls
;
return
imageUrls
;
}
}
/**
* 判断将会调用的插件-用于扣减积分
*/
public
static
List
<
Tool
>
checkPluginUse
(
List
<
Message
>
messages
,
List
<
Tool
>
tools
)
{
LLMService
llmService
=
SpringUtils
.
getBean
(
LLMService
.
class
);
String
query
=
messages
.
get
(
messages
.
size
()
-
1
).
getContent
().
toString
();
List
<
Tool
>
deductionTools
=
new
ArrayList
<>();
FunctionCallResult
functionCallResult
=
llmService
.
functionCall
(
query
,
tools
.
toArray
(
new
Tool
[
0
]));
if
(
functionCallResult
!=
null
&&
functionCallResult
.
isNeed
())
{
LargeModelFunctionEnum
functionEnum
=
LargeModelFunctionEnum
.
valueOf
(
functionCallResult
.
getFunctionCall
().
getName
());
String
llmConfig
=
functionEnum
.
getFunction
().
getLLMConfig
().
get
(
0
);
Tool
tool
=
JsonUtils
.
deSerialize
(
llmConfig
,
Tool
.
class
);
deductionTools
.
add
(
tool
);
}
return
deductionTools
;
}
}
}
src/main/java/cn/com/poc/equity/aggregate/impl/PointDeductionRulesServiceImpl.java
View file @
e87e29c1
...
@@ -47,7 +47,7 @@ public class PointDeductionRulesServiceImpl implements PointDeductionRulesServic
...
@@ -47,7 +47,7 @@ public class PointDeductionRulesServiceImpl implements PointDeductionRulesServic
List
<
BizPointDeductionRulesEntity
>
communicationTurnRules
=
map
.
get
(
RuleType
.
COMMUNICATION_TURN
.
getRuleType
());
List
<
BizPointDeductionRulesEntity
>
communicationTurnRules
=
map
.
get
(
RuleType
.
COMMUNICATION_TURN
.
getRuleType
());
for
(
BizPointDeductionRulesEntity
communicationTurnRule
:
communicationTurnRules
)
{
for
(
BizPointDeductionRulesEntity
communicationTurnRule
:
communicationTurnRules
)
{
if
(
communicationTurnRule
.
getRelationId
().
equals
(
String
.
valueOf
(
communicationTurn
)))
{
if
(
communicationTurnRule
.
getRelationId
().
equals
(
String
.
valueOf
(
communicationTurn
)))
{
pointDeductionNum
=
pointDeductionNum
*
communicationTurnRule
.
getNumber
();
pointDeductionNum
=
pointDeductionNum
+
communicationTurnRule
.
getNumber
();
break
;
break
;
}
}
}
}
...
...
src/main/java/cn/com/poc/expose/aggregate/impl/AgentApplicationApiServiceImpl.java
View file @
e87e29c1
...
@@ -142,7 +142,9 @@ public class AgentApplicationApiServiceImpl implements AgentApplicationApiServic
...
@@ -142,7 +142,9 @@ public class AgentApplicationApiServiceImpl implements AgentApplicationApiServic
Long
inputTimestamp
=
System
.
currentTimeMillis
();
Long
inputTimestamp
=
System
.
currentTimeMillis
();
//计算扣分数
//计算扣分数
Long
pointDeductionNum
=
pointDeductionRulesService
.
calculatePointDeductionNum
(
infoEntity
.
getLargeModel
(),
infoEntity
.
getCommunicationTurn
(),
tools
);
// 判断是否调用function
List
<
Tool
>
deductionTools
=
AgentApplicationTools
.
checkPluginUse
(
messages
,
tools
);
Long
pointDeductionNum
=
pointDeductionRulesService
.
calculatePointDeductionNum
(
infoEntity
.
getLargeModel
(),
infoEntity
.
getCommunicationTurn
(),
deductionTools
);
AgentUseModifyEventInfo
agentUseModifyEventInfo
=
new
AgentUseModifyEventInfo
();
AgentUseModifyEventInfo
agentUseModifyEventInfo
=
new
AgentUseModifyEventInfo
();
agentUseModifyEventInfo
.
setAgentId
(
agentId
);
agentUseModifyEventInfo
.
setAgentId
(
agentId
);
agentUseModifyEventInfo
.
setIsPublish
(
CommonConstant
.
IsDeleted
.
Y
);
agentUseModifyEventInfo
.
setIsPublish
(
CommonConstant
.
IsDeleted
.
Y
);
...
...
src/main/java/cn/com/poc/expose/aggregate/impl/AgentApplicationServiceImpl.java
View file @
e87e29c1
...
@@ -165,7 +165,10 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
...
@@ -165,7 +165,10 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
outputRecord
.
setTimestamp
(
System
.
currentTimeMillis
());
outputRecord
.
setTimestamp
(
System
.
currentTimeMillis
());
//计算扣分数
//计算扣分数
Long
pointDeductionNum
=
pointDeductionRulesService
.
calculatePointDeductionNum
(
infoEntity
.
getLargeModel
(),
infoEntity
.
getCommunicationTurn
(),
tools
);
// 判断是否调用function
List
<
Tool
>
deductionTools
=
AgentApplicationTools
.
checkPluginUse
(
messages
,
tools
);
Long
pointDeductionNum
=
pointDeductionRulesService
.
calculatePointDeductionNum
(
infoEntity
.
getLargeModel
(),
infoEntity
.
getCommunicationTurn
(),
deductionTools
);
AgentUseModifyEventInfo
agentUseModifyEventInfo
=
new
AgentUseModifyEventInfo
();
AgentUseModifyEventInfo
agentUseModifyEventInfo
=
new
AgentUseModifyEventInfo
();
agentUseModifyEventInfo
.
setAgentId
(
agentId
);
agentUseModifyEventInfo
.
setAgentId
(
agentId
);
agentUseModifyEventInfo
.
setIsPublish
(
CommonConstant
.
IsDeleted
.
Y
);
agentUseModifyEventInfo
.
setIsPublish
(
CommonConstant
.
IsDeleted
.
Y
);
...
...
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