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
cbfb29ad
Commit
cbfb29ad
authored
Dec 05, 2024
by
Roger Wu
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'release' of
ssh://gitlab.gsstcloud.com:10022/poc/poc-api
into release
parents
43aaf3a4
a13fec29
Hide whitespace changes
Inline
Side-by-side
Showing
106 changed files
with
4850 additions
and
1365 deletions
+4850
-1365
pom.xml
pom.xml
+19
-1
AgentApplicationInfoService.java
...nt_application/aggregate/AgentApplicationInfoService.java
+21
-5
AgentApplicationInfoServiceImpl.java
...ation/aggregate/impl/AgentApplicationInfoServiceImpl.java
+197
-156
AgentApplicationInfoConvert.java
...gent_application/convert/AgentApplicationInfoConvert.java
+38
-4
BizAgentApplicationPublishConvert.java
...pplication/convert/BizAgentApplicationPublishConvert.java
+35
-7
AgentApplicationKnowledgeConfig.java
...t_application/domain/AgentApplicationKnowledgeConfig.java
+14
-0
AgentApplicationVoiceConfig.java
...agent_application/domain/AgentApplicationVoiceConfig.java
+30
-0
AgentApplicationInfoDto.java
...om/poc/agent_application/dto/AgentApplicationInfoDto.java
+22
-13
AgentApplicationPreviewDto.java
...poc/agent_application/dto/AgentApplicationPreviewDto.java
+10
-0
BizAgentApplicationInfoEntity.java
...ent_application/entity/BizAgentApplicationInfoEntity.java
+31
-0
BizAgentApplicationPublishEntity.java
..._application/entity/BizAgentApplicationPublishEntity.java
+181
-120
CreateAgentTitleAndDescEntity.java
...ent_application/entity/CreateAgentTitleAndDescEntity.java
+6
-0
VoiceConfig.java
...java/cn/com/poc/agent_application/entity/VoiceConfig.java
+31
-0
BizAgentApplicationInfoModel.java
...agent_application/model/BizAgentApplicationInfoModel.java
+332
-269
BizAgentApplicationPublishModel.java
...nt_application/model/BizAgentApplicationPublishModel.java
+305
-246
AgentApplicationInfoQuery.sql
...poc/agent_application/query/AgentApplicationInfoQuery.sql
+2
-0
AgentApplicationInfoQueryItem.java
...gent_application/query/AgentApplicationInfoQueryItem.java
+35
-5
BizAgentApplicationPublishRest.java
...gent_application/rest/BizAgentApplicationPublishRest.java
+0
-2
AgentApplicationInfoRestImpl.java
...t_application/rest/impl/AgentApplicationInfoRestImpl.java
+35
-69
BizAgentApplicationPublishRestImpl.java
...ication/rest/impl/BizAgentApplicationPublishRestImpl.java
+0
-6
AgentApplicationMallSchedule.java
...nt_application/schedule/AgentApplicationMallSchedule.java
+1
-1
BizAgentApplicationPublishService.java
...pplication/service/BizAgentApplicationPublishService.java
+1
-1
BizAgentApplicationInfoServiceImpl.java
...tion/service/impl/BizAgentApplicationInfoServiceImpl.java
+9
-1
BizAgentApplicationPublishServiceImpl.java
...n/service/impl/BizAgentApplicationPublishServiceImpl.java
+13
-10
AgentApplicationTools.java
...om/poc/agent_application/utils/AgentApplicationTools.java
+122
-0
RedisLimit.java
src/main/java/cn/com/poc/common/annotation/RedisLimit.java
+3
-2
DocumentLoad.java
src/main/java/cn/com/poc/common/utils/DocumentLoad.java
+66
-0
PcmToWav.java
src/main/java/cn/com/poc/common/utils/PcmToWav.java
+54
-0
SQLUtils.java
src/main/java/cn/com/poc/common/utils/SQLUtils.java
+23
-14
WaveHeader.java
src/main/java/cn/com/poc/common/utils/WaveHeader.java
+63
-0
AgentApplicationService.java
.../cn/com/poc/expose/aggregate/AgentApplicationService.java
+25
-2
AgentApplicationServiceImpl.java
...oc/expose/aggregate/impl/AgentApplicationServiceImpl.java
+73
-85
AgentApplicationDto.java
src/main/java/cn/com/poc/expose/dto/AgentApplicationDto.java
+11
-0
UserDialoguesDto.java
src/main/java/cn/com/poc/expose/dto/UserDialoguesDto.java
+14
-0
AgentApplicationRest.java
...ain/java/cn/com/poc/expose/rest/AgentApplicationRest.java
+14
-0
AgentApplicationRestImpl.java
...cn/com/poc/expose/rest/impl/AgentApplicationRestImpl.java
+18
-2
SuperLinkWebSocketServer.java
...cn/com/poc/expose/websocket/SuperLinkWebSocketServer.java
+120
-0
SuperLinkWebSocketConfig.java
...poc/expose/websocket/config/SuperLinkWebSocketConfig.java
+19
-0
WsHandlerMatcher.java
...n/com/poc/expose/websocket/constant/WsHandlerMatcher.java
+25
-0
TextToSpeechTencentResponse.java
...poc/expose/websocket/dto/TextToSpeechTencentResponse.java
+65
-0
WebsocketException.java
...om/poc/expose/websocket/exception/WebsocketException.java
+66
-0
AbstractWsHandler.java
...n/com/poc/expose/websocket/handler/AbstractWsHandler.java
+13
-0
TextToSpeechTencentHandler.java
.../expose/websocket/handler/TextToSpeechTencentHandler.java
+150
-0
WSHandlerHolder.java
...a/cn/com/poc/expose/websocket/holder/WSHandlerHolder.java
+26
-0
SuperLinkWSRun.java
...java/cn/com/poc/expose/websocket/init/SuperLinkWSRun.java
+25
-0
AgentApplicationConsumerServiceImpl.java
...age/service/impl/AgentApplicationConsumerServiceImpl.java
+0
-2
DgtoolsAbstractHttpClient.java
...cn/com/poc/support/dgTools/DgtoolsAbstractHttpClient.java
+3
-3
AuthorizationServiceImpl.java
...upport/dgTools/service/impl/AuthorizationServiceImpl.java
+3
-3
AICreateImageServiceImpl.java
...ce/demand/ai/aggregate/impl/AICreateImageServiceImpl.java
+21
-21
AIDialogueServiceImpl.java
...ource/demand/ai/aggregate/impl/AIDialogueServiceImpl.java
+13
-13
DemandKnowledgeServiceImpl.java
.../demand/ai/aggregate/impl/DemandKnowledgeServiceImpl.java
+14
-14
AbstractLargeModelFunction.java
...source/demand/ai/function/AbstractLargeModelFunction.java
+11
-2
LargeModelFunctionEnum.java
...y/resource/demand/ai/function/LargeModelFunctionEnum.java
+19
-2
DocumentReaderFunction.java
...d/ai/function/document_reader/DocumentReaderFunction.java
+73
-0
DocumentUnderstandIngFunction.java
...document_understanding/DocumentUnderstandIngFunction.java
+93
-0
Function.java
...irdparty/resource/demand/ai/function/entity/Function.java
+47
-0
FunctionLLMConfig.java
...resource/demand/ai/function/entity/FunctionLLMConfig.java
+74
-0
Parameters.java
...dparty/resource/demand/ai/function/entity/Parameters.java
+35
-0
Properties.java
...dparty/resource/demand/ai/function/entity/Properties.java
+43
-0
HtmlReaderFunction.java
...ce/demand/ai/function/html_reader/HtmlReaderFunction.java
+58
-0
AgentLongMemoryEntity.java
...demand/ai/function/long_memory/AgentLongMemoryEntity.java
+1
-2
LongMemory.java
...y/resource/demand/ai/function/long_memory/LongMemory.java
+56
-0
SetLongMemoryFunction.java
...demand/ai/function/long_memory/SetLongMemoryFunction.java
+55
-45
MemoryVariableWriter.java
...function/memory_variable_writer/MemoryVariableWriter.java
+68
-0
MemoryVariableWriterConstants.java
...memory_variable_writer/MemoryVariableWriterConstants.java
+7
-0
MemoryVariableWriterFunction.java
.../memory_variable_writer/MemoryVariableWriterFunction.java
+110
-0
GetValueMemory.java
...ource/demand/ai/function/value_memory/GetValueMemory.java
+0
-24
SetValueMemoryConstants.java
...and/ai/function/value_memory/SetValueMemoryConstants.java
+0
-7
DgtoolsApiRoute.java
.../thirdparty/resource/demand/ai/route/DgtoolsApiRoute.java
+2
-2
DataReportServiceImpl.java
...demand/clickhouse/service/impl/DataReportServiceImpl.java
+5
-5
DemandAuthApi.java
.../thirdparty/resource/demand/member/api/DemandAuthApi.java
+3
-3
DemandMemberApi.java
...hirdparty/resource/demand/member/api/DemandMemberApi.java
+9
-9
MatchLangEnum.java
src/main/java/cn/com/poc/timbre/constants/MatchLangEnum.java
+45
-0
BizVoiceTimbreConvert.java
...java/cn/com/poc/timbre/convert/BizVoiceTimbreConvert.java
+130
-0
GetTimbreDto.java
src/main/java/cn/com/poc/timbre/dto/GetTimbreDto.java
+45
-0
TimbreInfo.java
src/main/java/cn/com/poc/timbre/dto/TimbreInfo.java
+48
-0
BizVoiceTimbreEntity.java
...n/java/cn/com/poc/timbre/entity/BizVoiceTimbreEntity.java
+163
-0
BizVoiceTimbreModel.java
...ain/java/cn/com/poc/timbre/model/BizVoiceTimbreModel.java
+238
-0
BizVoiceTimbreRepository.java
...n/com/poc/timbre/repository/BizVoiceTimbreRepository.java
+6
-0
BizVoiceTimbreRest.java
src/main/java/cn/com/poc/timbre/rest/BizVoiceTimbreRest.java
+29
-0
BizVoiceTimbreRest.java
.../java/cn/com/poc/timbre/rest/impl/BizVoiceTimbreRest.java
+45
-0
BizVoiceTimbreService.java
...java/cn/com/poc/timbre/service/BizVoiceTimbreService.java
+14
-0
BizVoiceTimbreServiceImpl.java
...om/poc/timbre/service/impl/BizVoiceTimbreServiceImpl.java
+55
-0
MemberInfoService.java
...n/java/cn/com/poc/user/aggregation/MemberInfoService.java
+10
-1
MemberInfoServiceImpl.java
.../com/poc/user/aggregation/impl/MemberInfoServiceImpl.java
+39
-5
EmailLoginChannel.java
src/main/java/cn/com/poc/user/builder/EmailLoginChannel.java
+30
-11
SmsLoginChannel.java
src/main/java/cn/com/poc/user/builder/SmsLoginChannel.java
+30
-11
CheckMemberInfoQuery.sql
src/main/java/cn/com/poc/user/query/CheckMemberInfoQuery.sql
+12
-0
CheckMemberInfoQueryCondition.java
.../cn/com/poc/user/query/CheckMemberInfoQueryCondition.java
+45
-0
CheckMemberInfoQueryItem.java
.../java/cn/com/poc/user/query/CheckMemberInfoQueryItem.java
+86
-0
BizMemberInfoRest.java
src/main/java/cn/com/poc/user/rest/BizMemberInfoRest.java
+10
-2
BizMemberInfoRestImpl.java
...java/cn/com/poc/user/rest/impl/BizMemberInfoRestImpl.java
+28
-11
BizMemberInfoService.java
...in/java/cn/com/poc/user/service/BizMemberInfoService.java
+15
-1
BizMemberInfoServiceImpl.java
...n/com/poc/user/service/impl/BizMemberInfoServiceImpl.java
+36
-0
exception.properties
...in/resources/framemax-config/i18n/en/exception.properties
+9
-1
exception.properties
...resources/framemax-config/i18n/zh_cn/exception.properties
+9
-1
exception.properties
...resources/framemax-config/i18n/zh_tw/exception.properties
+9
-1
AgentApplicationInfoTest.java
src/test/java/cn/com/poc/AgentApplicationInfoTest.java
+0
-80
AiDialogueTest.java
src/test/java/cn/com/poc/demand/AiDialogueTest.java
+0
-62
AgentApplicationServiceTest.java
...com/poc/expose/aggregate/AgentApplicationServiceTest.java
+83
-0
DocumentReaderFunctionTest.java
...source/demand/ai/function/DocumentReaderFunctionTest.java
+59
-0
DocumentUnderstandingFunctionTest.java
...demand/ai/function/DocumentUnderstandingFunctionTest.java
+50
-0
BizVoiceTimbreRestTest.java
...t/java/cn/com/poc/timbre/rest/BizVoiceTimbreRestTest.java
+87
-0
BizVoiceTimbreServiceTest.java
.../cn/com/poc/timbre/service/BizVoiceTimbreServiceTest.java
+44
-0
MemberInfoServiceTest.java
...va/cn/com/poc/user/aggregation/MemberInfoServiceTest.java
+43
-0
LoginChannelTest.java
src/test/java/cn/com/poc/user/builder/LoginChannelTest.java
+112
-0
No files found.
pom.xml
View file @
cbfb29ad
...
@@ -151,7 +151,18 @@
...
@@ -151,7 +151,18 @@
<version>
4.12
</version>
<version>
4.12
</version>
<scope>
test
</scope>
<scope>
test
</scope>
</dependency>
</dependency>
<dependency>
<groupId>
org.mockito
</groupId>
<artifactId>
mockito-core
</artifactId>
<version>
3.7.7
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.mockito
</groupId>
<artifactId>
mockito-inline
</artifactId>
<version>
3.7.7
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<dependency>
<groupId>
org.springframework
</groupId>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-test
</artifactId>
<artifactId>
spring-test
</artifactId>
...
@@ -375,6 +386,13 @@
...
@@ -375,6 +386,13 @@
<version>
0.10.328
</version>
<version>
0.10.328
</version>
</dependency>
</dependency>
<dependency>
<groupId>
io.github.furstenheim
</groupId>
<artifactId>
copy_down
</artifactId>
<version>
1.0
</version>
</dependency>
</dependencies>
</dependencies>
...
...
src/main/java/cn/com/poc/agent_application/aggregate/AgentApplicationInfoService.java
View file @
cbfb29ad
...
@@ -12,12 +12,16 @@ public interface AgentApplicationInfoService {
...
@@ -12,12 +12,16 @@ public interface AgentApplicationInfoService {
/**
/**
* 创建/更新应用
* 创建/更新应用
*
* @param entity 应用信息
*/
*/
BizAgentApplicationInfoEntity
saveOrUpdate
(
BizAgentApplicationInfoEntity
entity
)
throws
Exception
;
BizAgentApplicationInfoEntity
saveOrUpdate
(
BizAgentApplicationInfoEntity
entity
)
throws
Exception
;
/**
/**
* 更新并发布应用
* 更新并发布应用
*
* @param entity 应用信息
*/
*/
boolean
updateAndPublish
(
BizAgentApplicationInfoEntity
entity
)
throws
Exception
;
boolean
updateAndPublish
(
BizAgentApplicationInfoEntity
entity
)
throws
Exception
;
...
@@ -29,16 +33,28 @@ public interface AgentApplicationInfoService {
...
@@ -29,16 +33,28 @@ public interface AgentApplicationInfoService {
boolean
deletedAgentApplication
(
String
agentId
)
throws
Exception
;
boolean
deletedAgentApplication
(
String
agentId
)
throws
Exception
;
/**
/**
* 应用预览
* Agent应用对话
*
* @param agentId 应用ID
* @param identifier 对话唯一标识
* @param largeModel 模型
* @param agentSystem 应用角色指令
* @param knowledgeIds 知识库ID
* @param communicationTurn 对话轮数
* @param topP 模型参数topP
* @param temperature 模型参数temperature
* @param messages 对话消息
* @param tools 插件配置
* @param fileUrls 文件URL
*/
*/
String
callAgentApplication
(
String
identifier
,
String
largeModel
,
String
[]
unitIds
,
String
agentSystem
,
String
callAgentApplication
(
String
agentId
,
String
identifier
,
String
largeModel
,
String
agentSystem
,
Integer
[]
knowledgeIds
,
Integer
communicationTurn
,
Float
topP
,
Float
temperature
,
Integer
[]
knowledgeIds
,
Integer
communicationTurn
,
Float
topP
,
Float
temperature
,
List
<
Message
>
messages
,
List
<
Tool
>
tools
,
HttpServletResponse
httpServletResponse
)
throws
Exception
;
List
<
Message
>
messages
,
List
<
Tool
>
tools
,
List
<
String
>
fileUrls
,
HttpServletResponse
httpServletResponse
)
throws
Exception
;
/**
/**
* 应用下架
* 应用下架
*
*
* @param agentId
* @param agentId
应用ID
* @return
* @return
*/
*/
boolean
unPublish
(
String
agentId
)
throws
Exception
;
boolean
unPublish
(
String
agentId
)
throws
Exception
;
...
@@ -46,7 +62,7 @@ public interface AgentApplicationInfoService {
...
@@ -46,7 +62,7 @@ public interface AgentApplicationInfoService {
/**
/**
* 角色指令AI生成
* 角色指令AI生成
*
*
* @param input
* @param input
用户输入内容
* @param httpServletResponse
* @param httpServletResponse
* @return
* @return
*/
*/
...
...
src/main/java/cn/com/poc/agent_application/aggregate/impl/AgentApplicationInfoServiceImpl.java
View file @
cbfb29ad
...
@@ -4,13 +4,13 @@ import cn.com.poc.agent_application.aggregate.AgentApplicationInfoService;
...
@@ -4,13 +4,13 @@ import cn.com.poc.agent_application.aggregate.AgentApplicationInfoService;
import
cn.com.poc.agent_application.constant.AgentApplicationConstants
;
import
cn.com.poc.agent_application.constant.AgentApplicationConstants
;
import
cn.com.poc.agent_application.constant.AgentApplicationDialoguesRecordConstants
;
import
cn.com.poc.agent_application.constant.AgentApplicationDialoguesRecordConstants
;
import
cn.com.poc.agent_application.constant.AgentApplicationGCConfigConstants
;
import
cn.com.poc.agent_application.constant.AgentApplicationGCConfigConstants
;
import
cn.com.poc.agent_application.convert.AgentApplicationInfoConvert
;
import
cn.com.poc.agent_application.domain.FunctionResult
;
import
cn.com.poc.agent_application.domain.FunctionResult
;
import
cn.com.poc.agent_application.entity.*
;
import
cn.com.poc.agent_application.entity.*
;
import
cn.com.poc.agent_application.query.DialogsIdsQueryByAgentIdQueryItem
;
import
cn.com.poc.agent_application.query.DialogsIdsQueryByAgentIdQueryItem
;
import
cn.com.poc.agent_application.service.*
;
import
cn.com.poc.agent_application.service.*
;
import
cn.com.poc.agent_application.utils.AgentApplicationTools
;
import
cn.com.poc.common.constant.CommonConstant
;
import
cn.com.poc.common.constant.CommonConstant
;
import
cn.com.poc.common.
service.RedisService
;
import
cn.com.poc.common.
utils.Assert
;
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.common.utils.JsonUtils
;
import
cn.com.poc.knowledge.entity.BizKnowledgeDocumentEntity
;
import
cn.com.poc.knowledge.entity.BizKnowledgeDocumentEntity
;
...
@@ -19,7 +19,6 @@ import cn.com.poc.support.security.oauth.entity.UserBaseEntity;
...
@@ -19,7 +19,6 @@ import cn.com.poc.support.security.oauth.entity.UserBaseEntity;
import
cn.com.poc.thirdparty.resource.demand.ai.aggregate.AICreateImageService
;
import
cn.com.poc.thirdparty.resource.demand.ai.aggregate.AICreateImageService
;
import
cn.com.poc.thirdparty.resource.demand.ai.aggregate.DemandKnowledgeService
;
import
cn.com.poc.thirdparty.resource.demand.ai.aggregate.DemandKnowledgeService
;
import
cn.com.poc.thirdparty.resource.demand.ai.constants.LLMRoleEnum
;
import
cn.com.poc.thirdparty.resource.demand.ai.constants.LLMRoleEnum
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.dialogue.FunctionCall
;
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
;
...
@@ -29,11 +28,11 @@ import cn.com.poc.thirdparty.resource.demand.ai.entity.generations.BaiduAISailsT
...
@@ -29,11 +28,11 @@ import cn.com.poc.thirdparty.resource.demand.ai.entity.generations.BaiduAISailsT
import
cn.com.poc.thirdparty.resource.demand.ai.entity.largemodel.LargeModelDemandResult
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.largemodel.LargeModelDemandResult
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.largemodel.LargeModelResponse
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.largemodel.LargeModelResponse
;
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.long_memory.GetLongMemory
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.long_memory.LongMemory
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.long_memory.LongMemoryEntity
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.long_memory.AgentLongMemoryEntity
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.value_memory.GetValueMemory
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.memory_variable_writer.MemoryVariableWriter
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.value_memory.SetValueMemoryConstants
;
import
cn.com.poc.thirdparty.service.LLMService
;
import
cn.com.poc.thirdparty.service.LLMService
;
import
cn.com.yict.framemax.core.context.Context
;
import
cn.com.yict.framemax.core.i18n.I18nMessageException
;
import
cn.com.yict.framemax.core.i18n.I18nMessageException
;
import
cn.com.yict.framemax.data.model.PagingInfo
;
import
cn.com.yict.framemax.data.model.PagingInfo
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.bean.BeanUtil
;
...
@@ -96,16 +95,12 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
...
@@ -96,16 +95,12 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
@Resource
@Resource
private
BizAgentApplicationDialoguesRecordService
bizAgentApplicationDialoguesRecordService
;
private
BizAgentApplicationDialoguesRecordService
bizAgentApplicationDialoguesRecordService
;
@Resource
private
RedisService
redisService
;
@Override
@Override
public
BizAgentApplicationInfoEntity
saveOrUpdate
(
BizAgentApplicationInfoEntity
entity
)
throws
Exception
{
public
BizAgentApplicationInfoEntity
saveOrUpdate
(
BizAgentApplicationInfoEntity
entity
)
throws
Exception
{
// 如果存在agentId,则判断变量结构是否有变化,如果有变化,则删除redis中的数据
// 如果存在agentId,则判断变量结构是否有变化,如果有变化,则删除redis中的数据
if
(
StringUtils
.
isNotBlank
(
entity
.
getAgentId
()))
{
if
(
StringUtils
.
isNotBlank
(
entity
.
getAgentId
()))
{
String
contentKey
=
SetValueMemoryConstants
.
REDIS_PREFIX
+
entity
.
getAgentId
()
+
":"
+
entity
.
getMemberId
(
);
BizAgentApplicationInfoEntity
infoEntity
=
bizAgentApplicationInfoService
.
getByAgentId
(
entity
.
getAgentId
()
);
redisService
.
del
(
contentKey
);
updateStructVariable
(
entity
.
getAgentId
(),
infoEntity
.
getVariableStructure
(),
entity
.
getVariableStructure
()
);
}
}
// 保存或更新
// 保存或更新
return
StringUtils
.
isEmpty
(
entity
.
getAgentId
())
?
return
StringUtils
.
isEmpty
(
entity
.
getAgentId
())
?
...
@@ -125,18 +120,22 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
...
@@ -125,18 +120,22 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
}
}
//发布应用
//发布应用
bizAgentApplicationPublishService
.
deleteByAgentId
(
bizAgentApplicationInfoEntity
.
getAgentId
());
BizAgentApplicationPublishEntity
publishEntity
=
new
BizAgentApplicationPublishEntity
();
BizAgentApplicationPublishEntity
publishEntity
=
new
BizAgentApplicationPublishEntity
();
BeanUtil
.
copyProperties
(
bizAgentApplicationInfoEntity
,
publishEntity
);
BeanUtil
.
copyProperties
(
bizAgentApplicationInfoEntity
,
publishEntity
);
bizAgentApplicationPublishService
.
save
(
publishEntity
);
BizAgentApplicationPublishEntity
oldPublishEntity
=
bizAgentApplicationPublishService
.
getByAgentId
(
bizAgentApplicationInfoEntity
.
getAgentId
());
if
(
oldPublishEntity
!=
null
)
{
publishEntity
.
setId
(
oldPublishEntity
.
getId
());
bizAgentApplicationPublishService
.
update
(
publishEntity
);
}
else
{
bizAgentApplicationPublishService
.
save
(
publishEntity
);
}
//【变量】结构改变,删除会话缓存
//【变量】结构改变,删除会话缓存
List
<
DialogsIdsQueryByAgentIdQueryItem
>
items
=
bizAgentApplicationDialoguesRecordService
.
queryDialogsIds
(
bizAgentApplicationInfoEntity
.
getAgentId
());
List
<
DialogsIdsQueryByAgentIdQueryItem
>
items
=
bizAgentApplicationDialoguesRecordService
.
queryDialogsIds
(
bizAgentApplicationInfoEntity
.
getAgentId
());
if
(
CollectionUtils
.
isNotEmpty
(
items
))
{
if
(
CollectionUtils
.
isNotEmpty
(
items
))
{
logger
.
info
(
"variables structure cache remove,items:{}"
,
items
);
logger
.
info
(
"variables structure cache remove,items:{}"
,
items
);
for
(
DialogsIdsQueryByAgentIdQueryItem
item
:
items
)
{
for
(
DialogsIdsQueryByAgentIdQueryItem
item
:
items
)
{
String
contentKey
=
SetValueMemoryConstants
.
REDIS_PREFIX
+
item
.
getDialogsId
()
+
":"
;
MemoryVariableWriter
.
cleanByPre
(
AgentApplicationTools
.
identifier
(
item
.
getDialogsId
(),
bizAgentApplicationInfoEntity
.
getAgentId
()));
redisService
.
delByPre
(
contentKey
);
}
}
}
}
...
@@ -159,16 +158,19 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
...
@@ -159,16 +158,19 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
}
}
@Override
@Override
public
String
callAgentApplication
(
String
identifier
,
String
largeModel
,
String
[]
unitIds
,
String
agentSystem
,
Integer
[]
kdIds
,
Integer
communicationTurn
,
Float
topP
,
Float
temperature
,
List
<
Message
>
messages
,
List
<
Tool
>
tools
,
HttpServletResponse
httpServletResponse
)
throws
Exception
{
public
String
callAgentApplication
(
String
agentId
,
String
dialogueId
,
String
largeModel
,
logger
.
info
(
"--------- Call Agent Application large model:{},unitIds:{},agentSystem:{},knowledgeIds:{}"
+
" communicationTurn:{},topP:{},messages:{}--------------"
,
largeModel
,
unitIds
,
agentSystem
,
kdIds
,
communicationTurn
,
topP
,
messages
);
String
agentSystem
,
Integer
[]
kdIds
,
Integer
communicationTurn
,
Float
topP
,
Float
temperature
,
List
<
Message
>
messages
,
List
<
Tool
>
tools
,
List
<
String
>
fileUrls
,
HttpServletResponse
httpServletResponse
)
throws
Exception
{
logger
.
info
(
"Call Agent Application, agentId:{}, dialogueId:{},largeModel:{},agentSystem:{},kdIds:{},communicationTurn:{},topP:{},temperature:{},messages:{}, tools:{}"
,
agentId
,
dialogueId
,
largeModel
,
agentSystem
,
kdIds
,
communicationTurn
,
topP
,
temperature
,
messages
,
tools
);
String
model
=
modelConvert
(
largeModel
);
String
model
=
modelConvert
(
largeModel
);
Tool
[]
toolArray
=
tools
.
toArray
(
new
Tool
[
0
]);
Tool
[]
toolArray
=
tools
.
toArray
(
new
Tool
[
0
]);
FunctionResult
functionResult
=
functionCall
(
identifier
,
messages
,
toolArray
);
FunctionResult
functionResult
=
functionCall
(
dialogueId
,
messages
,
toolArray
,
agentId
,
fileUrls
);
String
promptTemplate
=
buildDialogsPrompt
(
functionResult
,
messages
,
agentSystem
,
kdIds
,
toolArray
,
identifier
);
String
promptTemplate
=
buildDialogsPrompt
(
functionResult
,
messages
,
agentSystem
,
kdIds
,
toolArray
,
dialogueId
,
agentId
);
Message
[]
messageArray
=
buildMessages
(
messages
,
communicationTurn
,
promptTemplate
);
Message
[]
messageArray
=
buildMessages
(
messages
,
communicationTurn
,
promptTemplate
);
...
@@ -516,16 +518,36 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
...
@@ -516,16 +518,36 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
* @param agentSystem 应用角色指令
* @param agentSystem 应用角色指令
* @param kdIds 知识库id
* @param kdIds 知识库id
* @param tools 组件
* @param tools 组件
* @param
identifier
对话标识符
* @param
dialogueId
对话标识符
* @return
* @return
*/
*/
private
String
buildDialogsPrompt
(
FunctionResult
functionResult
,
List
<
Message
>
messages
,
String
agentSystem
,
Integer
[]
kdIds
,
Tool
[]
tools
,
String
identifier
)
{
private
String
buildDialogsPrompt
(
FunctionResult
functionResult
,
List
<
Message
>
messages
,
String
agentSystem
,
Integer
[]
kdIds
,
Tool
[]
tools
,
String
dialogueId
,
String
agentId
)
{
String
promptTemplate
=
bizAgentApplicationGcConfigService
.
getByConfigCode
(
AgentApplicationGCConfigConstants
.
AGENT_BASE_SYSTEM
).
getConfigSystem
();
String
promptTemplate
=
bizAgentApplicationGcConfigService
.
getByConfigCode
(
AgentApplicationGCConfigConstants
.
AGENT_BASE_SYSTEM
).
getConfigSystem
();
Locale
currentLocale
=
Context
.
get
().
getMessageSource
().
getCurrentLocale
();
// 系统语言
promptTemplate
=
promptTemplate
.
replace
(
"${language}"
,
currentLocale
.
toLanguageTag
());
// 应用角色指令
promptTemplate
=
promptTemplate
.
replace
(
"${agentSystem}"
,
StringUtils
.
isNotBlank
(
agentSystem
)
?
agentSystem
:
StringUtils
.
EMPTY
);
promptTemplate
=
promptTemplate
.
replace
(
"${agentSystem}"
,
StringUtils
.
isNotBlank
(
agentSystem
)
?
agentSystem
:
StringUtils
.
EMPTY
);
// 调用知识库
// 调用知识库
promptTemplate
=
buildKnowledgePrompt
(
messages
,
kdIds
,
promptTemplate
);
// 记忆
promptTemplate
=
buildMemoryPrompt
(
promptTemplate
,
tools
,
dialogueId
,
agentId
);
// 函数调用
promptTemplate
=
buildFunctionPrompt
(
functionResult
,
promptTemplate
);
return
promptTemplate
;
}
/**
* 构建知识库提示词
*
* @param messages
* @param kdIds
* @param promptTemplate
* @return
*/
private
String
buildKnowledgePrompt
(
List
<
Message
>
messages
,
Integer
[]
kdIds
,
String
promptTemplate
)
{
if
(
ArrayUtils
.
isNotEmpty
(
kdIds
))
{
if
(
ArrayUtils
.
isNotEmpty
(
kdIds
))
{
List
<
String
>
knowledgeIds
=
new
ArrayList
<>();
List
<
String
>
knowledgeIds
=
new
ArrayList
<>();
for
(
Integer
kdId
:
kdIds
)
{
for
(
Integer
kdId
:
kdIds
)
{
BizKnowledgeDocumentEntity
knowledgeDocumentEntity
=
bizKnowledgeDocumentService
.
get
(
kdId
);
BizKnowledgeDocumentEntity
knowledgeDocumentEntity
=
bizKnowledgeDocumentService
.
get
(
kdId
);
if
(
null
==
knowledgeDocumentEntity
)
{
if
(
null
==
knowledgeDocumentEntity
)
{
...
@@ -533,45 +555,59 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
...
@@ -533,45 +555,59 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
}
}
knowledgeIds
.
add
(
knowledgeDocumentEntity
.
getKnowledgeId
());
knowledgeIds
.
add
(
knowledgeDocumentEntity
.
getKnowledgeId
());
}
}
Object
content
=
messages
.
get
(
messages
.
size
()
-
1
).
getContent
();
Object
content
=
messages
.
get
(
messages
.
size
()
-
1
).
getContent
();
String
query
=
""
;
String
query
=
""
;
if
(
content
instanceof
List
)
{
if
(
content
instanceof
List
)
{
query
=
((
List
<
HashMap
>)
content
).
get
(
0
).
get
(
"text"
).
toString
();
query
=
((
List
<
HashMap
>)
content
).
get
(
0
).
get
(
"text"
).
toString
();
}
else
{
}
else
{
query
=
content
.
toString
();
query
=
content
.
toString
();
}
}
List
<
String
>
knowledgeResults
=
demandKnowledgeService
.
searchKnowledge
(
query
,
knowledgeIds
,
3
);
List
<
String
>
knowledgeResults
=
demandKnowledgeService
.
searchKnowledge
(
query
,
knowledgeIds
,
3
);
promptTemplate
=
promptTemplate
.
replace
(
"${knowledgeResults}"
,
knowledgeResults
.
toString
());
StringBuilder
knowledgeResultsBuilder
=
new
StringBuilder
();
if
(
CollectionUtils
.
isNotEmpty
(
knowledgeResults
))
{
for
(
int
i
=
1
;
i
<=
knowledgeResults
.
size
();
i
++)
{
knowledgeResultsBuilder
.
append
(
"### Chunk "
).
append
(
i
).
append
(
":"
).
append
(
StringUtils
.
LF
).
append
(
knowledgeResults
.
get
(
i
-
1
)).
append
(
StringUtils
.
LF
);
}
}
promptTemplate
=
promptTemplate
.
replace
(
"${knowledgeResults}"
,
knowledgeResultsBuilder
.
toString
());
}
}
// 记忆
return
promptTemplate
;
}
/**
* 构造记忆体提示词
*
* @param promptTemplate
* @param tools
* @param dialogueId
* @param agentId
* @return
*/
private
String
buildMemoryPrompt
(
String
promptTemplate
,
Tool
[]
tools
,
String
dialogueId
,
String
agentId
)
{
String
longMemoryContent
=
StringUtils
.
EMPTY
;
String
valueMemoryContent
=
StringUtils
.
EMPTY
;
if
(
ArrayUtils
.
isNotEmpty
(
tools
))
{
if
(
ArrayUtils
.
isNotEmpty
(
tools
))
{
for
(
Tool
tool
:
tools
)
{
for
(
Tool
tool
:
tools
)
{
String
name
=
tool
.
getFunction
().
getName
();
String
name
=
tool
.
getFunction
().
getName
();
// 长期记忆
// 长期记忆
if
(
LargeModelFunctionEnum
.
set_long_memory
.
name
().
equals
(
name
))
{
if
(
LargeModelFunctionEnum
.
set_long_memory
.
name
().
equals
(
name
))
{
List
<
LongMemoryEntity
>
longMemoryEntities
=
GetLongMemory
.
get
(
identifier
);
List
<
AgentLongMemoryEntity
>
longMemoryEntities
=
LongMemory
.
get
(
AgentApplicationTools
.
identifier
(
dialogueId
,
agentId
)
);
if
(
CollectionUtils
.
isNotEmpty
(
longMemoryEntities
))
{
if
(
CollectionUtils
.
isNotEmpty
(
longMemoryEntities
))
{
StringBuilder
stringBuilder
=
new
StringBuilder
(
""
);
StringBuilder
stringBuilder
=
new
StringBuilder
(
""
);
for
(
LongMemoryEntity
l
ongMemoryEntity
:
longMemoryEntities
)
{
for
(
AgentLongMemoryEntity
agentL
ongMemoryEntity
:
longMemoryEntities
)
{
stringBuilder
stringBuilder
.
append
(
"Time"
).
append
(
":"
).
append
(
l
ongMemoryEntity
.
getTimestamp
())
.
append
(
"Time"
).
append
(
":"
).
append
(
agentL
ongMemoryEntity
.
getTimestamp
())
.
append
(
StringUtils
.
SPACE
)
.
append
(
StringUtils
.
SPACE
)
.
append
(
"Content"
).
append
(
":"
).
append
(
l
ongMemoryEntity
.
getContent
())
.
append
(
"Content"
).
append
(
":"
).
append
(
agentL
ongMemoryEntity
.
getContent
())
.
append
(
StringUtils
.
LF
);
.
append
(
StringUtils
.
LF
);
}
}
String
searchMemoryContent
=
stringBuilder
.
toString
();
longMemoryContent
=
stringBuilder
.
toString
();
promptTemplate
=
promptTemplate
.
replace
(
"${longMemoryResult}"
,
searchMemoryContent
);
}
else
{
promptTemplate
=
promptTemplate
.
replace
(
"${longMemoryResult}"
,
StringUtils
.
EMPTY
);
}
}
}
}
// 变量
// 变量
记忆
if
(
LargeModelFunctionEnum
.
set_value_memory
.
name
().
equals
(
name
))
{
if
(
LargeModelFunctionEnum
.
memory_variable_writer
.
name
().
equals
(
name
))
{
Map
<
Object
,
Object
>
map
=
GetValueMemory
.
get
(
identifier
);
Map
<
Object
,
Object
>
map
=
MemoryVariableWriter
.
get
(
AgentApplicationTools
.
identifier
(
dialogueId
,
agentId
)
);
StringBuilder
stringBuilder
=
new
StringBuilder
(
""
);
StringBuilder
stringBuilder
=
new
StringBuilder
(
""
);
if
(
MapUtils
.
isNotEmpty
(
map
))
{
if
(
MapUtils
.
isNotEmpty
(
map
))
{
Set
<
Object
>
keySet
=
map
.
keySet
();
Set
<
Object
>
keySet
=
map
.
keySet
();
...
@@ -579,18 +615,26 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
...
@@ -579,18 +615,26 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
stringBuilder
.
append
(
key
.
toString
()).
append
(
":"
).
append
(
map
.
get
(
key
)).
append
(
StringUtils
.
LF
);
stringBuilder
.
append
(
key
.
toString
()).
append
(
":"
).
append
(
map
.
get
(
key
)).
append
(
StringUtils
.
LF
);
}
}
}
}
promptTemplate
=
promptTemplate
.
replace
(
"${valueMemoryResult}"
,
stringBuilder
.
toString
());
valueMemoryContent
=
stringBuilder
.
toString
();
}
else
{
promptTemplate
=
promptTemplate
.
replace
(
"${valueMemoryResult}"
,
StringUtils
.
EMPTY
);
}
}
}
}
// 函数
}
if
(
functionResult
!=
null
)
{
return
promptTemplate
.
replace
(
"${longMemoryResult}"
,
longMemoryContent
).
replace
(
"${valueMemoryResult}"
,
valueMemoryContent
);
promptTemplate
=
promptTemplate
.
replace
(
"${functionName}"
,
StringUtils
.
isNotBlank
(
functionResult
.
getFunctionName
())
?
functionResult
.
getFunctionName
()
:
StringUtils
.
EMPTY
);
}
promptTemplate
=
promptTemplate
.
replace
(
"${functionArg}"
,
StringUtils
.
isNotBlank
(
functionResult
.
getFunctionArg
())
?
functionResult
.
getFunctionArg
()
:
StringUtils
.
EMPTY
);
promptTemplate
=
promptTemplate
.
replace
(
"${functionDesc}"
,
StringUtils
.
isNotBlank
(
functionResult
.
getFunctionDesc
())
?
functionResult
.
getFunctionDesc
()
:
StringUtils
.
EMPTY
);
/**
promptTemplate
=
promptTemplate
.
replace
(
"${functionResult}"
,
StringUtils
.
isNotBlank
(
functionResult
.
getFunctionResult
())
?
functionResult
.
getFunctionResult
()
:
StringUtils
.
EMPTY
);
* 构建函数调用提示词
}
*
* @param functionResult
* @param promptTemplate
* @return
*/
private
String
buildFunctionPrompt
(
FunctionResult
functionResult
,
String
promptTemplate
)
{
if
(
functionResult
!=
null
)
{
promptTemplate
=
promptTemplate
.
replace
(
"${functionName}"
,
StringUtils
.
isNotBlank
(
functionResult
.
getFunctionName
())
?
functionResult
.
getFunctionName
()
:
StringUtils
.
EMPTY
)
.
replace
(
"${functionArg}"
,
StringUtils
.
isNotBlank
(
functionResult
.
getFunctionArg
())
?
functionResult
.
getFunctionArg
()
:
StringUtils
.
EMPTY
)
.
replace
(
"${functionDesc}"
,
StringUtils
.
isNotBlank
(
functionResult
.
getFunctionDesc
())
?
functionResult
.
getFunctionDesc
()
:
StringUtils
.
EMPTY
)
.
replace
(
"${functionResult}"
,
StringUtils
.
isNotBlank
(
functionResult
.
getFunctionResult
())
?
functionResult
.
getFunctionResult
()
:
StringUtils
.
EMPTY
);
}
}
return
promptTemplate
;
return
promptTemplate
;
}
}
...
@@ -612,108 +656,6 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
...
@@ -612,108 +656,6 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
largeModelResponse
.
setStream
(
true
);
largeModelResponse
.
setStream
(
true
);
largeModelResponse
.
setUser
(
"POE"
);
largeModelResponse
.
setUser
(
"POE"
);
return
llmService
.
chatChunk
(
largeModelResponse
);
return
llmService
.
chatChunk
(
largeModelResponse
);
// bufferedReader.mark(200);
//
// String res = "";
//
// boolean isFunctionCall = false;
// String functionResult = null;
// StringBuffer finishReason = new StringBuffer();
// StringBuffer functionName = new StringBuffer();
// StringBuffer functionArguments = new StringBuffer();
//
// while ((res = bufferedReader.readLine()) != null) {
// if (StringUtils.isBlank(res)) {
// continue;
// }
// // 添加function 参数 LargeModelDemandResult 和中台接口一致
// LargeModelDemandResult result = JsonUtils.deSerialize(res.replaceFirst(EVENT_STREAM_PREFIX, StringUtils.EMPTY), LargeModelDemandResult.class);
// if (!"0".equals(result.getCode())) {
// logger.error("LLM Error,code:{}", result.getCode());
// throw new I18nMessageException("exception/call.failure");
// }
//
// if (StringUtils.isBlank(result.getMessage())
// && StringUtils.isBlank(result.getFunction().getName())
// && StringUtils.isBlank(result.getFunction().getArguments())
// && StringUtils.isBlank(result.getFinish_reason())) {
// continue;
// }
//
// if (!(result.getFunction() != null && (StringUtils.isNotBlank(result.getFunction().getName()) || StringUtils.isNotBlank(result.getFunction().getArguments()))) && !isFunctionCall) {
// bufferedReader.reset();
// break;
// } else {
// isFunctionCall = true;
// if (result.getFunction().getName() != null && !result.getFunction().getName().isEmpty()) {
// functionName.append(result.getFunction().getName());
// }
// if (result.getFunction().getArguments() != null && !result.getFunction().getArguments().isEmpty()) {
// functionArguments.append(result.getFunction().getArguments());
// }
// }
//
// if (result.getFinish_reason() != null) {
// finishReason.append(result.getFinish_reason());
// }
// // 走到了最后一个流,判断是否为function_call
// // 如果是function_call,则处理function
// if (finishReason.toString().equals("tool_calls")) {
// // 如果是function_call,则处理function
// if (!functionName.toString().isEmpty() && !functionArguments.toString().isEmpty()) {
// // 执行函数返回结果
// LargeModelFunctionEnum functionEnum = LargeModelFunctionEnum.valueOf(functionName.toString());
// functionResult = functionEnum.getFunction().doFunction(functionArguments.toString(), identifier);
// }
//
// if (functionResult != null) {
// // 处理function - 1,获取function_call 2. 调用对应function 3. 返回function_call并且调用LLM 4.获取bufferedReader 返回
// String functionRole = largeModelResponse.getModel().startsWith("qwen") ? LLMRoleEnum.FUNCTION.getRole() : LLMRoleEnum.TOOL.getRole();
// Message[] sendMessage = buildFunctionMessage(messageArray, functionName.toString(), functionArguments.toString(), functionResult, functionRole);
// largeModelResponse.setMessages(sendMessage);
// return llmService.chatChunk(largeModelResponse);
// }
// }
// }
// // 若不为function_call,则直接返回bufferedReader
// return bufferedReader;
}
/**
* 构建function_call消息体
*
* @param messageArray
* @param functionName
* @param functionArguments
* @param functionResult
* @return
*/
private
Message
[]
buildFunctionMessage
(
Message
[]
messageArray
,
String
functionName
,
String
functionArguments
,
String
functionResult
,
String
functionRole
)
{
List
<
FunctionCall
>
functionCalls
=
new
ArrayList
<>();
FunctionCall
functionCall
=
new
FunctionCall
();
functionCall
.
setName
(
functionName
);
functionCall
.
setArguments
(
functionArguments
);
functionCalls
.
add
(
functionCall
);
Message
assistantMessage
=
new
Message
();
assistantMessage
.
setRole
(
LLMRoleEnum
.
ASSISTANT
.
getRole
());
assistantMessage
.
setContent
(
null
);
assistantMessage
.
setFunction_call
(
functionCalls
);
Message
functionMessage
=
new
Message
();
functionMessage
.
setRole
(
functionRole
);
functionMessage
.
setName
(
functionName
);
functionMessage
.
setContent
(
functionResult
);
Message
[]
sendMessage
=
new
Message
[
messageArray
.
length
+
2
];
for
(
int
i
=
0
;
i
<
messageArray
.
length
;
i
++)
{
sendMessage
[
i
]
=
messageArray
[
i
];
}
sendMessage
[
messageArray
.
length
]
=
assistantMessage
;
sendMessage
[
messageArray
.
length
+
1
]
=
functionMessage
;
return
sendMessage
;
}
}
...
@@ -742,7 +684,9 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
...
@@ -742,7 +684,9 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
writer
.
flush
();
writer
.
flush
();
throw
ex
;
throw
ex
;
}
}
output
.
append
(
result
.
getMessage
());
if
(
StringUtils
.
isNotBlank
(
result
.
getMessage
()))
{
output
.
append
(
result
.
getMessage
());
}
writer
.
write
(
res
+
"\n\n"
);
writer
.
write
(
res
+
"\n\n"
);
writer
.
flush
();
writer
.
flush
();
}
}
...
@@ -808,11 +752,12 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
...
@@ -808,11 +752,12 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
/**
/**
* 判断是否需要FunctionCall
* 判断是否需要FunctionCall
*
*
* @param
identifier
* @param
dialogueId
* @param messages
* @param messages
* @param tools
* @param tools
* @param agentId
*/
*/
private
FunctionResult
functionCall
(
String
identifier
,
List
<
Message
>
messages
,
Tool
[]
too
ls
)
{
private
FunctionResult
functionCall
(
String
dialogueId
,
List
<
Message
>
messages
,
Tool
[]
tools
,
String
agentId
,
List
<
String
>
fileUr
ls
)
{
FunctionResult
result
=
new
FunctionResult
();
FunctionResult
result
=
new
FunctionResult
();
if
(
ArrayUtils
.
isEmpty
(
tools
))
{
if
(
ArrayUtils
.
isEmpty
(
tools
))
{
return
result
;
return
result
;
...
@@ -824,11 +769,16 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
...
@@ -824,11 +769,16 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
}
else
{
}
else
{
query
=
content
.
toString
();
query
=
content
.
toString
();
}
}
if
(
CollectionUtils
.
isNotEmpty
(
fileUrls
))
{
query
=
JsonUtils
.
serialize
(
fileUrls
)
+
query
;
}
FunctionCallResult
functionCallResult
=
llmService
.
functionCall
(
query
,
tools
);
FunctionCallResult
functionCallResult
=
llmService
.
functionCall
(
query
,
tools
);
if
(
functionCallResult
!=
null
&&
functionCallResult
.
isNeed
())
{
if
(
functionCallResult
!=
null
&&
functionCallResult
.
isNeed
())
{
// 执行函数返回结果
// 执行函数返回结果
LargeModelFunctionEnum
functionEnum
=
LargeModelFunctionEnum
.
valueOf
(
functionCallResult
.
getFunctionCall
().
getName
());
LargeModelFunctionEnum
functionEnum
=
LargeModelFunctionEnum
.
valueOf
(
functionCallResult
.
getFunctionCall
().
getName
());
String
functionResult
=
functionEnum
.
getFunction
().
doFunction
(
functionCallResult
.
getFunctionCall
().
getArguments
(),
identifier
);
String
functionResult
=
functionEnum
.
getFunction
().
doFunction
(
functionCallResult
.
getFunctionCall
().
getArguments
(),
AgentApplicationTools
.
identifier
(
dialogueId
,
agentId
)
);
//构造返回结果
//构造返回结果
result
.
setFunctionName
(
functionCallResult
.
getFunctionCall
().
getName
());
result
.
setFunctionName
(
functionCallResult
.
getFunctionCall
().
getName
());
...
@@ -840,4 +790,95 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
...
@@ -840,4 +790,95 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
}
}
/**
* 更新【记忆变量】结构
*
* @param agentId 应用ID
* @param originals 原字段结构
* @param transformed 变换后的字段结构
* @author alex.yao
* @deprecated 更新规则:
* 1. 原字段已存在,并存在值则不更新,否则更新并赋予该字段新结构默认值
* 2. 原字段不存在,则新增并赋予新结构的默认值
* 3. 原字段存在,但新结构中不存在,则删除原字段
* 注意: 若transformed为空会清除所有字段,删除对话中所有【记忆变量】缓存
*/
private
void
updateStructVariable
(
String
agentId
,
List
<
Variable
>
originals
,
List
<
Variable
>
transformed
)
{
Assert
.
notBlank
(
agentId
);
String
identifier
=
AgentApplicationTools
.
identifier
(
agentId
,
agentId
);
if
(
CollectionUtils
.
isEmpty
(
transformed
))
{
// 清除所有字段
MemoryVariableWriter
.
clean
(
identifier
);
}
// 原【变量记忆】为空,则不需要处理
if
(
CollectionUtils
.
isEmpty
(
originals
))
{
return
;
}
// 【记忆变量】对话缓存不存在,则不需要处理
Map
<
Object
,
Object
>
memoryVariable
=
MemoryVariableWriter
.
get
(
identifier
);
if
(
MapUtils
.
isEmpty
(
memoryVariable
))
{
return
;
}
// 1. 获取需要删除的字段集合
// 2. 获取需要更新值的字段集合
Set
<
String
>
delKeys
=
new
HashSet
<>();
Set
<
String
>
updateKeys
=
new
HashSet
<>();
for
(
Variable
variable
:
originals
)
{
String
key
=
variable
.
getKey
();
boolean
needDel
=
transformed
.
stream
().
noneMatch
(
v
->
v
.
getKey
().
equals
(
key
));
if
(
needDel
)
{
delKeys
.
add
(
key
);
}
boolean
needUpdate
=
transformed
.
stream
().
anyMatch
(
v
->
v
.
getKey
().
equals
(
key
));
if
(
needUpdate
)
{
Optional
<
Variable
>
target
=
transformed
.
stream
().
filter
(
v
->
v
.
getKey
().
equals
(
key
)).
findFirst
();
if
(
StringUtils
.
isBlank
(
target
.
get
().
getVariableDefault
()))
{
continue
;
}
Map
<
Object
,
Object
>
map
=
MemoryVariableWriter
.
get
(
identifier
);
if
(
map
==
null
)
{
map
=
new
HashMap
<>();
}
Object
value
=
map
.
get
(
key
);
if
(
value
==
null
||
StringUtils
.
isBlank
(
value
.
toString
()))
{
updateKeys
.
add
(
key
);
}
}
}
// 3. 获取需要新增的字段集合
Set
<
String
>
addKeys
=
new
HashSet
<>();
for
(
Variable
variable
:
transformed
)
{
String
key
=
variable
.
getKey
();
boolean
needAdd
=
originals
.
stream
().
noneMatch
(
v
->
v
.
getKey
().
equals
(
key
));
if
(
needAdd
)
{
addKeys
.
add
(
key
);
}
}
// 删除
if
(!
delKeys
.
isEmpty
())
{
MemoryVariableWriter
.
delItem
(
identifier
,
delKeys
.
toArray
(
new
String
[
0
]));
}
// 新增
if
(!
addKeys
.
isEmpty
())
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
for
(
String
key
:
addKeys
)
{
Variable
variable
=
transformed
.
stream
().
filter
(
v
->
v
.
getKey
().
equals
(
key
)).
findFirst
().
get
();
map
.
put
(
variable
.
getKey
(),
variable
.
getVariableDefault
());
}
MemoryVariableWriter
.
addItem
(
identifier
,
map
);
}
// 更新
if
(!
updateKeys
.
isEmpty
())
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
for
(
String
key
:
updateKeys
)
{
Variable
variable
=
transformed
.
stream
().
filter
(
v
->
v
.
getKey
().
equals
(
key
)).
findFirst
().
get
();
map
.
put
(
variable
.
getKey
(),
variable
.
getVariableDefault
());
}
MemoryVariableWriter
.
addItem
(
identifier
,
map
);
}
}
}
}
src/main/java/cn/com/poc/agent_application/convert/AgentApplicationInfoConvert.java
View file @
cbfb29ad
package
cn
.
com
.
poc
.
agent_application
.
convert
;
package
cn
.
com
.
poc
.
agent_application
.
convert
;
import
cn.com.poc.agent_application.domain.AgentApplicationBaseInfo
;
import
cn.com.poc.agent_application.domain.*
;
import
cn.com.poc.agent_application.domain.AgentApplicationCommConfig
;
import
cn.com.poc.agent_application.domain.AgentApplicationCommModelConfig
;
import
cn.com.poc.agent_application.domain.AgentApplicationKnowledgeConfig
;
import
cn.com.poc.agent_application.dto.AgentApplicationInfoDto
;
import
cn.com.poc.agent_application.dto.AgentApplicationInfoDto
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationInfoEntity
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationInfoEntity
;
import
cn.com.poc.agent_application.entity.Variable
;
import
cn.com.poc.agent_application.entity.Variable
;
import
cn.com.poc.agent_application.entity.VoiceConfig
;
import
cn.com.poc.agent_application.model.BizAgentApplicationInfoModel
;
import
cn.com.poc.agent_application.model.BizAgentApplicationInfoModel
;
import
cn.com.poc.agent_application.query.AgentApplicationInfoQueryItem
;
import
cn.com.poc.agent_application.query.AgentApplicationInfoQueryItem
;
import
cn.com.poc.agent_application.query.PublishAgentApplicationQueryItem
;
import
cn.com.poc.agent_application.query.PublishAgentApplicationQueryItem
;
import
cn.com.poc.common.constant.CommonConstant
;
import
cn.com.poc.common.utils.JsonUtils
;
import
cn.com.poc.common.utils.JsonUtils
;
import
cn.com.poc.expose.dto.SearchAgentApplicationDto
;
import
cn.com.poc.expose.dto.SearchAgentApplicationDto
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.ObjectUtil
;
...
@@ -65,12 +64,17 @@ public class AgentApplicationInfoConvert {
...
@@ -65,12 +64,17 @@ public class AgentApplicationInfoConvert {
if
(
StringUtils
.
isNotBlank
(
model
.
getKnowledgeIds
()))
{
if
(
StringUtils
.
isNotBlank
(
model
.
getKnowledgeIds
()))
{
entity
.
setKnowledgeIds
(
JsonUtils
.
deSerialize
(
model
.
getKnowledgeIds
(),
Integer
[].
class
));
entity
.
setKnowledgeIds
(
JsonUtils
.
deSerialize
(
model
.
getKnowledgeIds
(),
Integer
[].
class
));
}
}
entity
.
setIsDocumentParsing
(
model
.
getIsDocumentParsing
());
entity
.
setLargeModel
(
model
.
getLargeModel
());
entity
.
setLargeModel
(
model
.
getLargeModel
());
entity
.
setTopP
(
model
.
getTopP
());
entity
.
setTopP
(
model
.
getTopP
());
entity
.
setTemperature
(
model
.
getTemperature
());
entity
.
setTemperature
(
model
.
getTemperature
());
if
(
StringUtils
.
isNotBlank
(
model
.
getUnitIds
()))
{
if
(
StringUtils
.
isNotBlank
(
model
.
getUnitIds
()))
{
entity
.
setUnitIds
(
JsonUtils
.
deSerialize
(
model
.
getUnitIds
(),
String
[].
class
));
entity
.
setUnitIds
(
JsonUtils
.
deSerialize
(
model
.
getUnitIds
(),
String
[].
class
));
}
}
if
(
StringUtils
.
isNotBlank
(
model
.
getVoiceConfig
()))
{
VoiceConfig
voiceConfig
=
JsonUtils
.
deSerialize
(
model
.
getVoiceConfig
(),
VoiceConfig
.
class
);
entity
.
setVoiceConfig
(
voiceConfig
);
}
entity
.
setIsDeleted
(
model
.
getIsDeleted
());
entity
.
setIsDeleted
(
model
.
getIsDeleted
());
entity
.
setCreator
(
model
.
getCreator
());
entity
.
setCreator
(
model
.
getCreator
());
entity
.
setCreatedTime
(
model
.
getCreatedTime
());
entity
.
setCreatedTime
(
model
.
getCreatedTime
());
...
@@ -93,6 +97,7 @@ public class AgentApplicationInfoConvert {
...
@@ -93,6 +97,7 @@ public class AgentApplicationInfoConvert {
model
.
setPreamble
(
entity
.
getPreamble
());
model
.
setPreamble
(
entity
.
getPreamble
());
model
.
setPublishTime
(
entity
.
getPublishTime
());
model
.
setPublishTime
(
entity
.
getPublishTime
());
model
.
setIsLongMemory
(
entity
.
getIsLongMemory
());
model
.
setIsLongMemory
(
entity
.
getIsLongMemory
());
model
.
setIsDocumentParsing
(
entity
.
getIsDocumentParsing
());
if
(
CollectionUtils
.
isNotEmpty
(
entity
.
getVariableStructure
()))
{
if
(
CollectionUtils
.
isNotEmpty
(
entity
.
getVariableStructure
()))
{
model
.
setVariableStructure
(
JsonUtils
.
serialize
(
entity
.
getVariableStructure
()));
model
.
setVariableStructure
(
JsonUtils
.
serialize
(
entity
.
getVariableStructure
()));
}
}
...
@@ -112,6 +117,9 @@ public class AgentApplicationInfoConvert {
...
@@ -112,6 +117,9 @@ public class AgentApplicationInfoConvert {
if
(
ArrayUtils
.
isNotEmpty
(
entity
.
getUnitIds
()))
{
if
(
ArrayUtils
.
isNotEmpty
(
entity
.
getUnitIds
()))
{
model
.
setUnitIds
(
JsonUtil
.
toJson
(
entity
.
getUnitIds
()));
model
.
setUnitIds
(
JsonUtil
.
toJson
(
entity
.
getUnitIds
()));
}
}
if
(
ObjectUtil
.
isNotEmpty
(
entity
.
getVoiceConfig
()))
{
model
.
setVoiceConfig
(
JsonUtils
.
serialize
(
entity
.
getVoiceConfig
()));
}
model
.
setIsDeleted
(
entity
.
getIsDeleted
());
model
.
setIsDeleted
(
entity
.
getIsDeleted
());
model
.
setCreator
(
entity
.
getCreator
());
model
.
setCreator
(
entity
.
getCreator
());
model
.
setCreatedTime
(
entity
.
getCreatedTime
());
model
.
setCreatedTime
(
entity
.
getCreatedTime
());
...
@@ -144,6 +152,7 @@ public class AgentApplicationInfoConvert {
...
@@ -144,6 +152,7 @@ public class AgentApplicationInfoConvert {
AgentApplicationKnowledgeConfig
knowledgeConfig
=
new
AgentApplicationKnowledgeConfig
();
AgentApplicationKnowledgeConfig
knowledgeConfig
=
new
AgentApplicationKnowledgeConfig
();
knowledgeConfig
.
setKnowledgeIds
(
entity
.
getKnowledgeIds
());
knowledgeConfig
.
setKnowledgeIds
(
entity
.
getKnowledgeIds
());
knowledgeConfig
.
setIsDocumentParsing
(
entity
.
getIsDocumentParsing
());
AgentApplicationCommModelConfig
commModelConfig
=
new
AgentApplicationCommModelConfig
();
AgentApplicationCommModelConfig
commModelConfig
=
new
AgentApplicationCommModelConfig
();
commModelConfig
.
setLargeModel
(
entity
.
getLargeModel
());
commModelConfig
.
setLargeModel
(
entity
.
getLargeModel
());
...
@@ -151,11 +160,21 @@ public class AgentApplicationInfoConvert {
...
@@ -151,11 +160,21 @@ public class AgentApplicationInfoConvert {
commModelConfig
.
setTemperature
(
entity
.
getTemperature
());
commModelConfig
.
setTemperature
(
entity
.
getTemperature
());
commModelConfig
.
setCommunicationTurn
(
entity
.
getCommunicationTurn
());
commModelConfig
.
setCommunicationTurn
(
entity
.
getCommunicationTurn
());
AgentApplicationVoiceConfig
voiceConfig
=
new
AgentApplicationVoiceConfig
();
if
(
ObjectUtil
.
isNotEmpty
(
entity
.
getVoiceConfig
()))
{
voiceConfig
.
setDefaultOpen
(
entity
.
getVoiceConfig
().
getDefaultOpen
());
voiceConfig
.
setTimbreId
(
entity
.
getVoiceConfig
().
getTimbreId
());
}
else
{
voiceConfig
.
setDefaultOpen
(
CommonConstant
.
YOrN
.
N
);
voiceConfig
.
setTimbreId
(
StringUtils
.
EMPTY
);
}
AgentApplicationInfoDto
dto
=
new
AgentApplicationInfoDto
();
AgentApplicationInfoDto
dto
=
new
AgentApplicationInfoDto
();
dto
.
setBaseInfo
(
baseInfo
);
dto
.
setBaseInfo
(
baseInfo
);
dto
.
setCommConfig
(
commConfig
);
dto
.
setCommConfig
(
commConfig
);
dto
.
setKnowledgeConfig
(
knowledgeConfig
);
dto
.
setKnowledgeConfig
(
knowledgeConfig
);
dto
.
setCommModelConfig
(
commModelConfig
);
dto
.
setCommModelConfig
(
commModelConfig
);
dto
.
setVoiceConfig
(
voiceConfig
);
dto
.
setUnitIds
(
entity
.
getUnitIds
());
dto
.
setUnitIds
(
entity
.
getUnitIds
());
dto
.
setCreator
(
entity
.
getCreator
());
dto
.
setCreator
(
entity
.
getCreator
());
dto
.
setCreatedTime
(
entity
.
getCreatedTime
());
dto
.
setCreatedTime
(
entity
.
getCreatedTime
());
...
@@ -191,6 +210,7 @@ public class AgentApplicationInfoConvert {
...
@@ -191,6 +210,7 @@ public class AgentApplicationInfoConvert {
if
(
ObjectUtil
.
isNotEmpty
(
dto
.
getKnowledgeConfig
()))
{
if
(
ObjectUtil
.
isNotEmpty
(
dto
.
getKnowledgeConfig
()))
{
entity
.
setKnowledgeIds
(
dto
.
getKnowledgeConfig
().
getKnowledgeIds
());
entity
.
setKnowledgeIds
(
dto
.
getKnowledgeConfig
().
getKnowledgeIds
());
entity
.
setIsDocumentParsing
(
dto
.
getKnowledgeConfig
().
getIsDocumentParsing
());
}
}
if
(
ObjectUtil
.
isNotEmpty
(
dto
.
getCommModelConfig
()))
{
if
(
ObjectUtil
.
isNotEmpty
(
dto
.
getCommModelConfig
()))
{
...
@@ -200,6 +220,16 @@ public class AgentApplicationInfoConvert {
...
@@ -200,6 +220,16 @@ public class AgentApplicationInfoConvert {
entity
.
setCommunicationTurn
(
dto
.
getCommModelConfig
().
getCommunicationTurn
());
entity
.
setCommunicationTurn
(
dto
.
getCommModelConfig
().
getCommunicationTurn
());
}
}
VoiceConfig
voiceConfig
=
new
VoiceConfig
();
if
(
ObjectUtil
.
isNotEmpty
(
dto
.
getVoiceConfig
()))
{
voiceConfig
.
setDefaultOpen
(
dto
.
getVoiceConfig
().
getDefaultOpen
());
voiceConfig
.
setTimbreId
(
dto
.
getVoiceConfig
().
getTimbreId
());
}
else
{
voiceConfig
.
setDefaultOpen
(
CommonConstant
.
YOrN
.
N
);
voiceConfig
.
setTimbreId
(
StringUtils
.
EMPTY
);
}
entity
.
setVoiceConfig
(
voiceConfig
);
entity
.
setUnitIds
(
dto
.
getUnitIds
());
entity
.
setUnitIds
(
dto
.
getUnitIds
());
entity
.
setCreator
(
dto
.
getCreator
());
entity
.
setCreator
(
dto
.
getCreator
());
entity
.
setCreatedTime
(
dto
.
getCreatedTime
());
entity
.
setCreatedTime
(
dto
.
getCreatedTime
());
...
@@ -221,6 +251,7 @@ public class AgentApplicationInfoConvert {
...
@@ -221,6 +251,7 @@ public class AgentApplicationInfoConvert {
entity
.
setPreamble
(
infoQueryItem
.
getPreamble
());
entity
.
setPreamble
(
infoQueryItem
.
getPreamble
());
entity
.
setPublishTime
(
infoQueryItem
.
getPublishTime
());
entity
.
setPublishTime
(
infoQueryItem
.
getPublishTime
());
entity
.
setIsLongMemory
(
infoQueryItem
.
getIsLongMemory
());
entity
.
setIsLongMemory
(
infoQueryItem
.
getIsLongMemory
());
entity
.
setIsDocumentParsing
(
infoQueryItem
.
getIsDocumentParsing
());
if
(
StringUtils
.
isNotBlank
(
infoQueryItem
.
getVariableStructure
()))
{
if
(
StringUtils
.
isNotBlank
(
infoQueryItem
.
getVariableStructure
()))
{
entity
.
setVariableStructure
(
JsonUtils
.
deSerialize
(
infoQueryItem
.
getVariableStructure
(),
new
TypeReference
<
List
<
Variable
>>()
{
entity
.
setVariableStructure
(
JsonUtils
.
deSerialize
(
infoQueryItem
.
getVariableStructure
(),
new
TypeReference
<
List
<
Variable
>>()
{
...
@@ -243,6 +274,9 @@ public class AgentApplicationInfoConvert {
...
@@ -243,6 +274,9 @@ public class AgentApplicationInfoConvert {
if
(
StringUtils
.
isNotBlank
(
infoQueryItem
.
getUnitIds
()))
{
if
(
StringUtils
.
isNotBlank
(
infoQueryItem
.
getUnitIds
()))
{
entity
.
setUnitIds
(
JsonUtils
.
deSerialize
(
infoQueryItem
.
getUnitIds
(),
String
[].
class
));
entity
.
setUnitIds
(
JsonUtils
.
deSerialize
(
infoQueryItem
.
getUnitIds
(),
String
[].
class
));
}
}
if
(
StringUtils
.
isNotBlank
(
infoQueryItem
.
getVoiceConfig
()))
{
entity
.
setVoiceConfig
(
JsonUtils
.
deSerialize
(
infoQueryItem
.
getVoiceConfig
(),
VoiceConfig
.
class
));
}
entity
.
setIsDeleted
(
infoQueryItem
.
getIsDeleted
());
entity
.
setIsDeleted
(
infoQueryItem
.
getIsDeleted
());
entity
.
setCreator
(
infoQueryItem
.
getCreator
());
entity
.
setCreator
(
infoQueryItem
.
getCreator
());
entity
.
setCreatedTime
(
infoQueryItem
.
getCreatedTime
());
entity
.
setCreatedTime
(
infoQueryItem
.
getCreatedTime
());
...
...
src/main/java/cn/com/poc/agent_application/convert/BizAgentApplicationPublishConvert.java
View file @
cbfb29ad
package
cn
.
com
.
poc
.
agent_application
.
convert
;
package
cn
.
com
.
poc
.
agent_application
.
convert
;
import
cn.com.poc.agent_application.domain.AgentApplicationBaseInfo
;
import
cn.com.poc.agent_application.domain.*
;
import
cn.com.poc.agent_application.domain.AgentApplicationCommConfig
;
import
cn.com.poc.agent_application.domain.AgentApplicationCommModelConfig
;
import
cn.com.poc.agent_application.domain.AgentApplicationKnowledgeConfig
;
import
cn.com.poc.agent_application.dto.BizAgentApplicationPublishDto
;
import
cn.com.poc.agent_application.dto.BizAgentApplicationPublishDto
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationPublishEntity
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationPublishEntity
;
import
cn.com.poc.agent_application.entity.Variable
;
import
cn.com.poc.agent_application.entity.Variable
;
import
cn.com.poc.agent_application.entity.VoiceConfig
;
import
cn.com.poc.agent_application.model.BizAgentApplicationPublishModel
;
import
cn.com.poc.agent_application.model.BizAgentApplicationPublishModel
;
import
cn.com.poc.common.constant.CommonConstant
;
import
cn.com.poc.common.utils.JsonUtils
;
import
cn.com.poc.common.utils.JsonUtils
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.fasterxml.jackson.core.type.TypeReference
;
...
@@ -35,7 +34,8 @@ public class BizAgentApplicationPublishConvert {
...
@@ -35,7 +34,8 @@ public class BizAgentApplicationPublishConvert {
entity
.
setAgentSystem
(
model
.
getAgentSystem
());
entity
.
setAgentSystem
(
model
.
getAgentSystem
());
entity
.
setPreamble
(
model
.
getPreamble
());
entity
.
setPreamble
(
model
.
getPreamble
());
entity
.
setIsLongMemory
(
model
.
getIsLongMemory
());
entity
.
setIsLongMemory
(
model
.
getIsLongMemory
());
entity
.
setPublishTime
(
model
.
getCreatedTime
());
entity
.
setPublishTime
(
model
.
getModifiedTime
());
entity
.
setIsDocumentParsing
(
model
.
getIsDocumentParsing
());
if
(
StringUtils
.
isNotBlank
(
model
.
getVariableStructure
()))
{
if
(
StringUtils
.
isNotBlank
(
model
.
getVariableStructure
()))
{
entity
.
setVariableStructure
(
JsonUtils
.
deSerialize
(
model
.
getVariableStructure
(),
new
TypeReference
<
List
<
Variable
>>()
{
entity
.
setVariableStructure
(
JsonUtils
.
deSerialize
(
model
.
getVariableStructure
(),
new
TypeReference
<
List
<
Variable
>>()
{
}.
getType
()));
}.
getType
()));
...
@@ -57,12 +57,15 @@ public class BizAgentApplicationPublishConvert {
...
@@ -57,12 +57,15 @@ public class BizAgentApplicationPublishConvert {
if
(
StringUtils
.
isNotBlank
(
model
.
getUnitIds
()))
{
if
(
StringUtils
.
isNotBlank
(
model
.
getUnitIds
()))
{
entity
.
setUnitIds
(
JsonUtils
.
deSerialize
(
model
.
getUnitIds
(),
String
[].
class
));
entity
.
setUnitIds
(
JsonUtils
.
deSerialize
(
model
.
getUnitIds
(),
String
[].
class
));
}
}
if
(
StringUtils
.
isNotBlank
(
model
.
getVoiceConfig
()))
{
VoiceConfig
voiceConfig
=
JsonUtils
.
deSerialize
(
model
.
getVoiceConfig
(),
VoiceConfig
.
class
);
entity
.
setVoiceConfig
(
voiceConfig
);
}
entity
.
setIsDeleted
(
model
.
getIsDeleted
());
entity
.
setIsDeleted
(
model
.
getIsDeleted
());
entity
.
setCreator
(
model
.
getCreator
());
entity
.
setCreator
(
model
.
getCreator
());
entity
.
setCreatedTime
(
model
.
getCreatedTime
());
entity
.
setCreatedTime
(
model
.
getCreatedTime
());
entity
.
setModifier
(
model
.
getModifier
());
entity
.
setModifier
(
model
.
getModifier
());
entity
.
setModifiedTime
(
model
.
getModifiedTime
());
entity
.
setModifiedTime
(
model
.
getModifiedTime
());
entity
.
setSysVersion
(
model
.
getSysVersion
());
return
entity
;
return
entity
;
}
}
...
@@ -77,6 +80,7 @@ public class BizAgentApplicationPublishConvert {
...
@@ -77,6 +80,7 @@ public class BizAgentApplicationPublishConvert {
model
.
setAgentSystem
(
entity
.
getAgentSystem
());
model
.
setAgentSystem
(
entity
.
getAgentSystem
());
model
.
setPreamble
(
entity
.
getPreamble
());
model
.
setPreamble
(
entity
.
getPreamble
());
model
.
setIsLongMemory
(
entity
.
getIsLongMemory
());
model
.
setIsLongMemory
(
entity
.
getIsLongMemory
());
model
.
setIsDocumentParsing
(
entity
.
getIsDocumentParsing
());
if
(
CollectionUtils
.
isNotEmpty
(
entity
.
getVariableStructure
()))
{
if
(
CollectionUtils
.
isNotEmpty
(
entity
.
getVariableStructure
()))
{
model
.
setVariableStructure
(
JsonUtils
.
serialize
(
entity
.
getVariableStructure
()));
model
.
setVariableStructure
(
JsonUtils
.
serialize
(
entity
.
getVariableStructure
()));
}
}
...
@@ -96,12 +100,15 @@ public class BizAgentApplicationPublishConvert {
...
@@ -96,12 +100,15 @@ public class BizAgentApplicationPublishConvert {
if
(
ArrayUtils
.
isNotEmpty
(
entity
.
getUnitIds
()))
{
if
(
ArrayUtils
.
isNotEmpty
(
entity
.
getUnitIds
()))
{
model
.
setUnitIds
(
JsonUtil
.
toJson
(
entity
.
getUnitIds
()));
model
.
setUnitIds
(
JsonUtil
.
toJson
(
entity
.
getUnitIds
()));
}
}
if
(
ObjectUtil
.
isNotEmpty
(
entity
.
getVoiceConfig
()))
{
model
.
setVoiceConfig
(
JsonUtils
.
serialize
(
entity
.
getVoiceConfig
()));
}
model
.
setIsDeleted
(
entity
.
getIsDeleted
());
model
.
setIsDeleted
(
entity
.
getIsDeleted
());
model
.
setCreator
(
entity
.
getCreator
());
model
.
setCreator
(
entity
.
getCreator
());
model
.
setCreatedTime
(
entity
.
getCreatedTime
());
model
.
setCreatedTime
(
entity
.
getCreatedTime
());
model
.
setModifier
(
entity
.
getModifier
());
model
.
setModifier
(
entity
.
getModifier
());
model
.
setModifiedTime
(
entity
.
getModifiedTime
());
model
.
setModifiedTime
(
entity
.
getModifiedTime
());
model
.
setSysVersion
(
entity
.
getSysVersion
());
return
model
;
return
model
;
}
}
...
@@ -128,6 +135,7 @@ public class BizAgentApplicationPublishConvert {
...
@@ -128,6 +135,7 @@ public class BizAgentApplicationPublishConvert {
AgentApplicationKnowledgeConfig
knowledgeConfig
=
new
AgentApplicationKnowledgeConfig
();
AgentApplicationKnowledgeConfig
knowledgeConfig
=
new
AgentApplicationKnowledgeConfig
();
knowledgeConfig
.
setKnowledgeIds
(
entity
.
getKnowledgeIds
());
knowledgeConfig
.
setKnowledgeIds
(
entity
.
getKnowledgeIds
());
knowledgeConfig
.
setIsDocumentParsing
(
entity
.
getIsDocumentParsing
());
AgentApplicationCommModelConfig
commModelConfig
=
new
AgentApplicationCommModelConfig
();
AgentApplicationCommModelConfig
commModelConfig
=
new
AgentApplicationCommModelConfig
();
commModelConfig
.
setLargeModel
(
entity
.
getLargeModel
());
commModelConfig
.
setLargeModel
(
entity
.
getLargeModel
());
...
@@ -135,10 +143,21 @@ public class BizAgentApplicationPublishConvert {
...
@@ -135,10 +143,21 @@ public class BizAgentApplicationPublishConvert {
commModelConfig
.
setTemperature
(
entity
.
getTemperature
());
commModelConfig
.
setTemperature
(
entity
.
getTemperature
());
commModelConfig
.
setCommunicationTurn
(
entity
.
getCommunicationTurn
());
commModelConfig
.
setCommunicationTurn
(
entity
.
getCommunicationTurn
());
AgentApplicationVoiceConfig
voiceConfig
=
new
AgentApplicationVoiceConfig
();
if
(
ObjectUtil
.
isNotEmpty
(
entity
.
getVoiceConfig
()))
{
voiceConfig
.
setDefaultOpen
(
entity
.
getVoiceConfig
().
getDefaultOpen
());
voiceConfig
.
setTimbreId
(
entity
.
getVoiceConfig
().
getTimbreId
());
}
else
{
voiceConfig
.
setDefaultOpen
(
CommonConstant
.
YOrN
.
N
);
voiceConfig
.
setTimbreId
(
StringUtils
.
EMPTY
);
}
dto
.
setBaseInfo
(
baseInfo
);
dto
.
setBaseInfo
(
baseInfo
);
dto
.
setCommConfig
(
commConfig
);
dto
.
setCommConfig
(
commConfig
);
dto
.
setKnowledgeConfig
(
knowledgeConfig
);
dto
.
setKnowledgeConfig
(
knowledgeConfig
);
dto
.
setCommModelConfig
(
commModelConfig
);
dto
.
setCommModelConfig
(
commModelConfig
);
dto
.
setVoiceConfig
(
voiceConfig
);
dto
.
setUnitIds
(
entity
.
getUnitIds
());
dto
.
setUnitIds
(
entity
.
getUnitIds
());
dto
.
setCreator
(
entity
.
getCreator
());
dto
.
setCreator
(
entity
.
getCreator
());
dto
.
setCreatedTime
(
entity
.
getCreatedTime
());
dto
.
setCreatedTime
(
entity
.
getCreatedTime
());
...
@@ -175,6 +194,7 @@ public class BizAgentApplicationPublishConvert {
...
@@ -175,6 +194,7 @@ public class BizAgentApplicationPublishConvert {
if
(
ObjectUtil
.
isNotEmpty
(
dto
.
getKnowledgeConfig
()))
{
if
(
ObjectUtil
.
isNotEmpty
(
dto
.
getKnowledgeConfig
()))
{
entity
.
setKnowledgeIds
(
dto
.
getKnowledgeConfig
().
getKnowledgeIds
());
entity
.
setKnowledgeIds
(
dto
.
getKnowledgeConfig
().
getKnowledgeIds
());
entity
.
setIsDocumentParsing
(
dto
.
getKnowledgeConfig
().
getIsDocumentParsing
());
}
}
if
(
ObjectUtil
.
isNotEmpty
(
dto
.
getCommModelConfig
()))
{
if
(
ObjectUtil
.
isNotEmpty
(
dto
.
getCommModelConfig
()))
{
...
@@ -183,6 +203,14 @@ public class BizAgentApplicationPublishConvert {
...
@@ -183,6 +203,14 @@ public class BizAgentApplicationPublishConvert {
entity
.
setTemperature
(
dto
.
getCommModelConfig
().
getTemperature
());
entity
.
setTemperature
(
dto
.
getCommModelConfig
().
getTemperature
());
}
}
VoiceConfig
voiceConfig
=
new
VoiceConfig
();
if
(
ObjectUtil
.
isNotEmpty
(
dto
.
getVoiceConfig
()))
{
voiceConfig
.
setDefaultOpen
(
dto
.
getVoiceConfig
().
getDefaultOpen
());
voiceConfig
.
setTimbreId
(
dto
.
getVoiceConfig
().
getTimbreId
());
}
else
{
voiceConfig
.
setDefaultOpen
(
CommonConstant
.
YOrN
.
N
);
voiceConfig
.
setTimbreId
(
StringUtils
.
EMPTY
);
}
entity
.
setUnitIds
(
dto
.
getUnitIds
());
entity
.
setUnitIds
(
dto
.
getUnitIds
());
entity
.
setCreator
(
dto
.
getCreator
());
entity
.
setCreator
(
dto
.
getCreator
());
entity
.
setCreatedTime
(
dto
.
getCreatedTime
());
entity
.
setCreatedTime
(
dto
.
getCreatedTime
());
...
...
src/main/java/cn/com/poc/agent_application/domain/AgentApplicationKnowledgeConfig.java
View file @
cbfb29ad
...
@@ -18,4 +18,18 @@ public class AgentApplicationKnowledgeConfig {
...
@@ -18,4 +18,18 @@ public class AgentApplicationKnowledgeConfig {
public
void
setKnowledgeIds
(
java
.
lang
.
Integer
[]
knowledgeIds
)
{
public
void
setKnowledgeIds
(
java
.
lang
.
Integer
[]
knowledgeIds
)
{
this
.
knowledgeIds
=
knowledgeIds
;
this
.
knowledgeIds
=
knowledgeIds
;
}
}
/**
* is_document_parsing
* 是否开启文档解析 1、Y 是 2、N 否
*/
private
java
.
lang
.
String
isDocumentParsing
;
public
java
.
lang
.
String
getIsDocumentParsing
()
{
return
this
.
isDocumentParsing
;
}
public
void
setIsDocumentParsing
(
java
.
lang
.
String
isDocumentParsing
)
{
this
.
isDocumentParsing
=
isDocumentParsing
;
}
}
}
src/main/java/cn/com/poc/agent_application/domain/AgentApplicationVoiceConfig.java
0 → 100644
View file @
cbfb29ad
package
cn
.
com
.
poc
.
agent_application
.
domain
;
public
class
AgentApplicationVoiceConfig
{
/**
* 是否默认开启 Y-是 N-否
*/
private
String
defaultOpen
;
/**
* 音色ID
*/
private
String
timbreId
;
public
String
getDefaultOpen
()
{
return
defaultOpen
;
}
public
void
setDefaultOpen
(
String
defaultOpen
)
{
this
.
defaultOpen
=
defaultOpen
;
}
public
String
getTimbreId
()
{
return
timbreId
;
}
public
void
setTimbreId
(
String
timbreId
)
{
this
.
timbreId
=
timbreId
;
}
}
src/main/java/cn/com/poc/agent_application/dto/AgentApplicationInfoDto.java
View file @
cbfb29ad
package
cn
.
com
.
poc
.
agent_application
.
dto
;
package
cn
.
com
.
poc
.
agent_application
.
dto
;
import
cn.com.poc.agent_application.domain.AgentApplicationBaseInfo
;
import
cn.com.poc.agent_application.domain.*
;
import
cn.com.poc.agent_application.domain.AgentApplicationCommConfig
;
import
cn.com.poc.agent_application.domain.AgentApplicationCommModelConfig
;
import
cn.com.poc.agent_application.domain.AgentApplicationKnowledgeConfig
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
...
@@ -21,6 +18,8 @@ public class AgentApplicationInfoDto implements java.io.Serializable {
...
@@ -21,6 +18,8 @@ public class AgentApplicationInfoDto implements java.io.Serializable {
private
AgentApplicationCommModelConfig
commModelConfig
;
private
AgentApplicationCommModelConfig
commModelConfig
;
private
AgentApplicationVoiceConfig
voiceConfig
;
public
AgentApplicationBaseInfo
getBaseInfo
()
{
public
AgentApplicationBaseInfo
getBaseInfo
()
{
return
baseInfo
;
return
baseInfo
;
}
}
...
@@ -53,6 +52,14 @@ public class AgentApplicationInfoDto implements java.io.Serializable {
...
@@ -53,6 +52,14 @@ public class AgentApplicationInfoDto implements java.io.Serializable {
this
.
commModelConfig
=
commModelConfig
;
this
.
commModelConfig
=
commModelConfig
;
}
}
public
AgentApplicationVoiceConfig
getVoiceConfig
()
{
return
voiceConfig
;
}
public
void
setVoiceConfig
(
AgentApplicationVoiceConfig
voiceConfig
)
{
this
.
voiceConfig
=
voiceConfig
;
}
/**
/**
* unit_ids
* unit_ids
* 组件ID
* 组件ID
...
@@ -113,7 +120,7 @@ public class AgentApplicationInfoDto implements java.io.Serializable {
...
@@ -113,7 +120,7 @@ public class AgentApplicationInfoDto implements java.io.Serializable {
/**
/**
* isCollect
* isCollect
* 当前用户是否收藏 1、Y 是 2、N 否
* 当前用户是否收藏 1、Y 是 2、N 否
*
*
/
*/
private
String
isCollect
;
private
String
isCollect
;
public
String
getIsCollect
()
{
public
String
getIsCollect
()
{
...
@@ -124,29 +131,31 @@ public class AgentApplicationInfoDto implements java.io.Serializable {
...
@@ -124,29 +131,31 @@ public class AgentApplicationInfoDto implements java.io.Serializable {
this
.
isCollect
=
isCollect
;
this
.
isCollect
=
isCollect
;
}
}
/** agent_publish_id
/**
*发布应用的ID
* agent_publish_id
* 发布应用的ID
*/
*/
private
java
.
lang
.
Integer
agentPublishId
;
private
java
.
lang
.
Integer
agentPublishId
;
public
java
.
lang
.
Integer
getAgentPublishId
(){
public
java
.
lang
.
Integer
getAgentPublishId
()
{
return
this
.
agentPublishId
;
return
this
.
agentPublishId
;
}
}
public
void
setAgentPublishId
(
java
.
lang
.
Integer
agentPublishId
){
public
void
setAgentPublishId
(
java
.
lang
.
Integer
agentPublishId
)
{
this
.
agentPublishId
=
agentPublishId
;
this
.
agentPublishId
=
agentPublishId
;
}
}
/** is_sale
/**
*是否上架应用 1、Y 是 2、N 否
* is_sale
* 是否上架应用 1、Y 是 2、N 否
*/
*/
private
java
.
lang
.
String
isSale
;
private
java
.
lang
.
String
isSale
;
public
java
.
lang
.
String
getIsSale
(){
public
java
.
lang
.
String
getIsSale
()
{
return
this
.
isSale
;
return
this
.
isSale
;
}
}
public
void
setIsSale
(
java
.
lang
.
String
isSale
){
public
void
setIsSale
(
java
.
lang
.
String
isSale
)
{
this
.
isSale
=
isSale
;
this
.
isSale
=
isSale
;
}
}
...
...
src/main/java/cn/com/poc/agent_application/dto/AgentApplicationPreviewDto.java
View file @
cbfb29ad
...
@@ -19,6 +19,16 @@ public class AgentApplicationPreviewDto implements Serializable {
...
@@ -19,6 +19,16 @@ public class AgentApplicationPreviewDto implements Serializable {
private
List
<
Message
>
messages
;
private
List
<
Message
>
messages
;
private
List
<
String
>
fileUrls
;
public
List
<
String
>
getFileUrls
()
{
return
fileUrls
;
}
public
void
setFileUrls
(
List
<
String
>
fileUrls
)
{
this
.
fileUrls
=
fileUrls
;
}
public
Float
getTopP
()
{
public
Float
getTopP
()
{
return
topP
;
return
topP
;
}
}
...
...
src/main/java/cn/com/poc/agent_application/entity/BizAgentApplicationInfoEntity.java
View file @
cbfb29ad
package
cn
.
com
.
poc
.
agent_application
.
entity
;
package
cn
.
com
.
poc
.
agent_application
.
entity
;
import
cn.com.poc.agent_application.domain.AgentApplicationVoiceConfig
;
import
javax.persistence.Column
;
import
javax.persistence.Column
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.List
;
...
@@ -315,6 +317,35 @@ public class BizAgentApplicationInfoEntity {
...
@@ -315,6 +317,35 @@ public class BizAgentApplicationInfoEntity {
this
.
isLongMemory
=
isLongMemory
;
this
.
isLongMemory
=
isLongMemory
;
}
}
/**
* is_document_parsing
* 是否开启文档解析 1、Y 是 2、N 否
*/
private
java
.
lang
.
String
isDocumentParsing
;
public
java
.
lang
.
String
getIsDocumentParsing
()
{
return
this
.
isDocumentParsing
;
}
public
void
setIsDocumentParsing
(
java
.
lang
.
String
isDocumentParsing
)
{
this
.
isDocumentParsing
=
isDocumentParsing
;
}
/**
* voice_config
* 声音配置 defaultOpen- 是否默认开启 timbreId-音色
*/
private
VoiceConfig
voiceConfig
;
public
VoiceConfig
getVoiceConfig
()
{
return
voiceConfig
;
}
public
void
setVoiceConfig
(
VoiceConfig
voiceConfig
)
{
this
.
voiceConfig
=
voiceConfig
;
}
/**
/**
* is_deleted
* is_deleted
...
...
src/main/java/cn/com/poc/agent_application/entity/BizAgentApplicationPublishEntity.java
View file @
cbfb29ad
package
cn
.
com
.
poc
.
agent_application
.
entity
;
package
cn
.
com
.
poc
.
agent_application
.
entity
;
import
javax.persistence.Column
;
import
java.util.List
;
import
java.util.List
;
public
class
BizAgentApplicationPublishEntity
{
public
class
BizAgentApplicationPublishEntity
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
/** id
/**
*自增ID
* id
* 自增ID
*/
*/
private
java
.
lang
.
Integer
id
;
private
java
.
lang
.
Integer
id
;
public
java
.
lang
.
Integer
getId
(){
public
java
.
lang
.
Integer
getId
()
{
return
this
.
id
;
return
this
.
id
;
}
}
public
void
setId
(
java
.
lang
.
Integer
id
){
public
void
setId
(
java
.
lang
.
Integer
id
)
{
this
.
id
=
id
;
this
.
id
=
id
;
}
}
/** member_id
*创建应用的用户ID
/**
* member_id
* 创建应用的用户ID
*/
*/
private
java
.
lang
.
Integer
memberId
;
private
java
.
lang
.
Integer
memberId
;
public
java
.
lang
.
Integer
getMemberId
(){
public
java
.
lang
.
Integer
getMemberId
()
{
return
this
.
memberId
;
return
this
.
memberId
;
}
}
public
void
setMemberId
(
java
.
lang
.
Integer
memberId
){
public
void
setMemberId
(
java
.
lang
.
Integer
memberId
)
{
this
.
memberId
=
memberId
;
this
.
memberId
=
memberId
;
}
}
/** agent_id
*agent应用ID
/**
* agent_id
* agent应用ID
*/
*/
private
java
.
lang
.
String
agentId
;
private
java
.
lang
.
String
agentId
;
public
java
.
lang
.
String
getAgentId
(){
public
java
.
lang
.
String
getAgentId
()
{
return
this
.
agentId
;
return
this
.
agentId
;
}
}
public
void
setAgentId
(
java
.
lang
.
String
agentId
){
public
void
setAgentId
(
java
.
lang
.
String
agentId
)
{
this
.
agentId
=
agentId
;
this
.
agentId
=
agentId
;
}
}
/** agent_avatar
*应用头像ICON地址
/**
* agent_avatar
* 应用头像ICON地址
*/
*/
private
java
.
lang
.
String
agentAvatar
;
private
java
.
lang
.
String
agentAvatar
;
public
java
.
lang
.
String
getAgentAvatar
(){
public
java
.
lang
.
String
getAgentAvatar
()
{
return
this
.
agentAvatar
;
return
this
.
agentAvatar
;
}
}
public
void
setAgentAvatar
(
java
.
lang
.
String
agentAvatar
){
public
void
setAgentAvatar
(
java
.
lang
.
String
agentAvatar
)
{
this
.
agentAvatar
=
agentAvatar
;
this
.
agentAvatar
=
agentAvatar
;
}
}
/** agent_title
*应用标题
/**
* agent_title
* 应用标题
*/
*/
private
java
.
lang
.
String
agentTitle
;
private
java
.
lang
.
String
agentTitle
;
public
java
.
lang
.
String
getAgentTitle
(){
public
java
.
lang
.
String
getAgentTitle
()
{
return
this
.
agentTitle
;
return
this
.
agentTitle
;
}
}
public
void
setAgentTitle
(
java
.
lang
.
String
agentTitle
){
public
void
setAgentTitle
(
java
.
lang
.
String
agentTitle
)
{
this
.
agentTitle
=
agentTitle
;
this
.
agentTitle
=
agentTitle
;
}
}
/** agent_desc
*应用描述
/**
* agent_desc
* 应用描述
*/
*/
private
java
.
lang
.
String
agentDesc
;
private
java
.
lang
.
String
agentDesc
;
public
java
.
lang
.
String
getAgentDesc
(){
public
java
.
lang
.
String
getAgentDesc
()
{
return
this
.
agentDesc
;
return
this
.
agentDesc
;
}
}
public
void
setAgentDesc
(
java
.
lang
.
String
agentDesc
){
public
void
setAgentDesc
(
java
.
lang
.
String
agentDesc
)
{
this
.
agentDesc
=
agentDesc
;
this
.
agentDesc
=
agentDesc
;
}
}
/** agent_system
*角色指令
/**
* agent_system
* 角色指令
*/
*/
private
java
.
lang
.
String
agentSystem
;
private
java
.
lang
.
String
agentSystem
;
public
java
.
lang
.
String
getAgentSystem
(){
public
java
.
lang
.
String
getAgentSystem
()
{
return
this
.
agentSystem
;
return
this
.
agentSystem
;
}
}
public
void
setAgentSystem
(
java
.
lang
.
String
agentSystem
){
public
void
setAgentSystem
(
java
.
lang
.
String
agentSystem
)
{
this
.
agentSystem
=
agentSystem
;
this
.
agentSystem
=
agentSystem
;
}
}
/** agent_publish_status
*应用发布状态 草稿-draft 发布-publish
/**
* agent_publish_status
* 应用发布状态 草稿-draft 发布-publish
*/
*/
private
java
.
lang
.
String
agentPublishStatus
;
private
java
.
lang
.
String
agentPublishStatus
;
public
java
.
lang
.
String
getAgentPublishStatus
(){
public
java
.
lang
.
String
getAgentPublishStatus
()
{
return
this
.
agentPublishStatus
;
return
this
.
agentPublishStatus
;
}
}
public
void
setAgentPublishStatus
(
java
.
lang
.
String
agentPublishStatus
){
public
void
setAgentPublishStatus
(
java
.
lang
.
String
agentPublishStatus
)
{
this
.
agentPublishStatus
=
agentPublishStatus
;
this
.
agentPublishStatus
=
agentPublishStatus
;
}
}
/** publish_time
*发布时间
/**
* publish_time
* 发布时间
*/
*/
private
java
.
util
.
Date
publishTime
;
private
java
.
util
.
Date
publishTime
;
public
java
.
util
.
Date
getPublishTime
(){
public
java
.
util
.
Date
getPublishTime
()
{
return
this
.
publishTime
;
return
this
.
publishTime
;
}
}
public
void
setPublishTime
(
java
.
util
.
Date
publishTime
){
public
void
setPublishTime
(
java
.
util
.
Date
publishTime
)
{
this
.
publishTime
=
publishTime
;
this
.
publishTime
=
publishTime
;
}
}
/** preamble
*开场白
/**
* preamble
* 开场白
*/
*/
private
java
.
lang
.
String
preamble
;
private
java
.
lang
.
String
preamble
;
public
java
.
lang
.
String
getPreamble
(){
public
java
.
lang
.
String
getPreamble
()
{
return
this
.
preamble
;
return
this
.
preamble
;
}
}
public
void
setPreamble
(
java
.
lang
.
String
preamble
){
public
void
setPreamble
(
java
.
lang
.
String
preamble
)
{
this
.
preamble
=
preamble
;
this
.
preamble
=
preamble
;
}
}
/** variable_structure
/**
*变量结构
* variable_structure
* 变量结构
*/
*/
private
List
<
Variable
>
variableStructure
;
private
List
<
Variable
>
variableStructure
;
public
List
<
Variable
>
getVariableStructure
(){
public
List
<
Variable
>
getVariableStructure
()
{
return
this
.
variableStructure
;
return
this
.
variableStructure
;
}
}
public
void
setVariableStructure
(
List
<
Variable
>
variableStructure
){
public
void
setVariableStructure
(
List
<
Variable
>
variableStructure
)
{
this
.
variableStructure
=
variableStructure
;
this
.
variableStructure
=
variableStructure
;
}
}
/** featured_questions
/**
*推荐问
* featured_questions
* 推荐问
*/
*/
private
java
.
lang
.
String
[]
featuredQuestions
;
private
java
.
lang
.
String
[]
featuredQuestions
;
public
java
.
lang
.
String
[]
getFeaturedQuestions
(){
public
java
.
lang
.
String
[]
getFeaturedQuestions
()
{
return
this
.
featuredQuestions
;
return
this
.
featuredQuestions
;
}
}
public
void
setFeaturedQuestions
(
java
.
lang
.
String
[]
featuredQuestions
){
public
void
setFeaturedQuestions
(
java
.
lang
.
String
[]
featuredQuestions
)
{
this
.
featuredQuestions
=
featuredQuestions
;
this
.
featuredQuestions
=
featuredQuestions
;
}
}
/** communication_turn
*对话上下文保存轮次 0-100
/**
* communication_turn
* 对话上下文保存轮次 0-100
*/
*/
private
java
.
lang
.
Integer
communicationTurn
;
private
java
.
lang
.
Integer
communicationTurn
;
public
java
.
lang
.
Integer
getCommunicationTurn
(){
public
java
.
lang
.
Integer
getCommunicationTurn
()
{
return
this
.
communicationTurn
;
return
this
.
communicationTurn
;
}
}
public
void
setCommunicationTurn
(
java
.
lang
.
Integer
communicationTurn
){
public
void
setCommunicationTurn
(
java
.
lang
.
Integer
communicationTurn
)
{
this
.
communicationTurn
=
communicationTurn
;
this
.
communicationTurn
=
communicationTurn
;
}
}
/** continuous_question_status
*追问状态 默认-default 自定义-customizable 关闭-close
/**
* continuous_question_status
* 追问状态 默认-default 自定义-customizable 关闭-close
*/
*/
private
java
.
lang
.
String
continuousQuestionStatus
;
private
java
.
lang
.
String
continuousQuestionStatus
;
public
java
.
lang
.
String
getContinuousQuestionStatus
(){
public
java
.
lang
.
String
getContinuousQuestionStatus
()
{
return
this
.
continuousQuestionStatus
;
return
this
.
continuousQuestionStatus
;
}
}
public
void
setContinuousQuestionStatus
(
java
.
lang
.
String
continuousQuestionStatus
){
public
void
setContinuousQuestionStatus
(
java
.
lang
.
String
continuousQuestionStatus
)
{
this
.
continuousQuestionStatus
=
continuousQuestionStatus
;
this
.
continuousQuestionStatus
=
continuousQuestionStatus
;
}
}
/** continuous_question_system
*追问prompt
/**
* continuous_question_system
* 追问prompt
*/
*/
private
java
.
lang
.
String
continuousQuestionSystem
;
private
java
.
lang
.
String
continuousQuestionSystem
;
public
java
.
lang
.
String
getContinuousQuestionSystem
(){
public
java
.
lang
.
String
getContinuousQuestionSystem
()
{
return
this
.
continuousQuestionSystem
;
return
this
.
continuousQuestionSystem
;
}
}
public
void
setContinuousQuestionSystem
(
java
.
lang
.
String
continuousQuestionSystem
){
public
void
setContinuousQuestionSystem
(
java
.
lang
.
String
continuousQuestionSystem
)
{
this
.
continuousQuestionSystem
=
continuousQuestionSystem
;
this
.
continuousQuestionSystem
=
continuousQuestionSystem
;
}
}
/** continuous_question_turn
*追问轮次 1-5
/**
* continuous_question_turn
* 追问轮次 1-5
*/
*/
private
java
.
lang
.
Integer
continuousQuestionTurn
;
private
java
.
lang
.
Integer
continuousQuestionTurn
;
public
java
.
lang
.
Integer
getContinuousQuestionTurn
(){
public
java
.
lang
.
Integer
getContinuousQuestionTurn
()
{
return
this
.
continuousQuestionTurn
;
return
this
.
continuousQuestionTurn
;
}
}
public
void
setContinuousQuestionTurn
(
java
.
lang
.
Integer
continuousQuestionTurn
){
public
void
setContinuousQuestionTurn
(
java
.
lang
.
Integer
continuousQuestionTurn
)
{
this
.
continuousQuestionTurn
=
continuousQuestionTurn
;
this
.
continuousQuestionTurn
=
continuousQuestionTurn
;
}
}
/** knowledge_ids
*知识库ID
/**
* knowledge_ids
* 知识库ID
*/
*/
private
java
.
lang
.
Integer
[]
knowledgeIds
;
private
java
.
lang
.
Integer
[]
knowledgeIds
;
public
java
.
lang
.
Integer
[]
getKnowledgeIds
(){
public
java
.
lang
.
Integer
[]
getKnowledgeIds
()
{
return
this
.
knowledgeIds
;
return
this
.
knowledgeIds
;
}
}
public
void
setKnowledgeIds
(
java
.
lang
.
Integer
[]
knowledgeIds
){
public
void
setKnowledgeIds
(
java
.
lang
.
Integer
[]
knowledgeIds
)
{
this
.
knowledgeIds
=
knowledgeIds
;
this
.
knowledgeIds
=
knowledgeIds
;
}
}
/** large_model
*问答模型
/**
* large_model
* 问答模型
*/
*/
private
java
.
lang
.
String
largeModel
;
private
java
.
lang
.
String
largeModel
;
public
java
.
lang
.
String
getLargeModel
(){
public
java
.
lang
.
String
getLargeModel
()
{
return
this
.
largeModel
;
return
this
.
largeModel
;
}
}
public
void
setLargeModel
(
java
.
lang
.
String
largeModel
){
public
void
setLargeModel
(
java
.
lang
.
String
largeModel
)
{
this
.
largeModel
=
largeModel
;
this
.
largeModel
=
largeModel
;
}
}
/** top_p
*对话模型 多样性 [0-1.00]
/**
* top_p
* 对话模型 多样性 [0-1.00]
*/
*/
private
java
.
lang
.
Float
topP
;
private
java
.
lang
.
Float
topP
;
public
java
.
lang
.
Float
getTopP
(){
public
java
.
lang
.
Float
getTopP
()
{
return
this
.
topP
;
return
this
.
topP
;
}
}
public
void
setTopP
(
java
.
lang
.
Float
topP
){
public
void
setTopP
(
java
.
lang
.
Float
topP
)
{
this
.
topP
=
topP
;
this
.
topP
=
topP
;
}
}
/**
/*
* temperature
* temperature
*对话模型 温度 [0-1.00]
*
对话模型 温度 [0-1.00]
*/
*/
private
java
.
lang
.
Float
temperature
;
private
java
.
lang
.
Float
temperature
;
public
java
.
lang
.
Float
getTemperature
(){
public
java
.
lang
.
Float
getTemperature
()
{
return
this
.
temperature
;
return
this
.
temperature
;
}
}
public
void
setTemperature
(
java
.
lang
.
Float
temperature
){
public
void
setTemperature
(
java
.
lang
.
Float
temperature
)
{
this
.
temperature
=
temperature
;
this
.
temperature
=
temperature
;
}
}
/** unit_ids
/**
*组件ID
* unit_ids
* 组件ID
*/
*/
private
java
.
lang
.
String
[]
unitIds
;
private
java
.
lang
.
String
[]
unitIds
;
public
java
.
lang
.
String
[]
getUnitIds
(){
public
java
.
lang
.
String
[]
getUnitIds
()
{
return
this
.
unitIds
;
return
this
.
unitIds
;
}
}
public
void
setUnitIds
(
java
.
lang
.
String
[]
unitIds
){
public
void
setUnitIds
(
java
.
lang
.
String
[]
unitIds
)
{
this
.
unitIds
=
unitIds
;
this
.
unitIds
=
unitIds
;
}
}
/** is_long_memory
/**
*是否开启长期记忆 1、Y 是 2、N 否
* is_long_memory
* 是否开启长期记忆 1、Y 是 2、N 否
*/
*/
private
java
.
lang
.
String
isLongMemory
;
private
java
.
lang
.
String
isLongMemory
;
public
java
.
lang
.
String
getIsLongMemory
(){
public
java
.
lang
.
String
getIsLongMemory
()
{
return
this
.
isLongMemory
;
return
this
.
isLongMemory
;
}
}
public
void
setIsLongMemory
(
java
.
lang
.
String
isLongMemory
){
public
void
setIsLongMemory
(
java
.
lang
.
String
isLongMemory
)
{
this
.
isLongMemory
=
isLongMemory
;
this
.
isLongMemory
=
isLongMemory
;
}
}
/**
* is_document_parsing
* 是否开启文档解析 1、Y 是 2、N 否
*/
private
java
.
lang
.
String
isDocumentParsing
;
public
java
.
lang
.
String
getIsDocumentParsing
()
{
return
this
.
isDocumentParsing
;
}
public
void
setIsDocumentParsing
(
java
.
lang
.
String
isDocumentParsing
)
{
this
.
isDocumentParsing
=
isDocumentParsing
;
}
/**
* voice_config
*/
private
VoiceConfig
voiceConfig
;
public
VoiceConfig
getVoiceConfig
()
{
return
voiceConfig
;
}
public
void
setVoiceConfig
(
VoiceConfig
voiceConfig
)
{
this
.
voiceConfig
=
voiceConfig
;
}
/** is_deleted
/**
*是否删除 1、Y 是 2、N 否
* is_deleted
* 是否删除 1、Y 是 2、N 否
*/
*/
private
java
.
lang
.
String
isDeleted
;
private
java
.
lang
.
String
isDeleted
;
public
java
.
lang
.
String
getIsDeleted
(){
public
java
.
lang
.
String
getIsDeleted
()
{
return
this
.
isDeleted
;
return
this
.
isDeleted
;
}
}
public
void
setIsDeleted
(
java
.
lang
.
String
isDeleted
){
public
void
setIsDeleted
(
java
.
lang
.
String
isDeleted
)
{
this
.
isDeleted
=
isDeleted
;
this
.
isDeleted
=
isDeleted
;
}
}
/** CREATOR
*创建人
/**
* CREATOR
* 创建人
*/
*/
private
java
.
lang
.
String
creator
;
private
java
.
lang
.
String
creator
;
public
java
.
lang
.
String
getCreator
(){
public
java
.
lang
.
String
getCreator
()
{
return
this
.
creator
;
return
this
.
creator
;
}
}
public
void
setCreator
(
java
.
lang
.
String
creator
){
public
void
setCreator
(
java
.
lang
.
String
creator
)
{
this
.
creator
=
creator
;
this
.
creator
=
creator
;
}
}
/** CREATED_TIME
*创建时间
/**
* CREATED_TIME
* 创建时间
*/
*/
private
java
.
util
.
Date
createdTime
;
private
java
.
util
.
Date
createdTime
;
public
java
.
util
.
Date
getCreatedTime
(){
public
java
.
util
.
Date
getCreatedTime
()
{
return
this
.
createdTime
;
return
this
.
createdTime
;
}
}
public
void
setCreatedTime
(
java
.
util
.
Date
createdTime
){
public
void
setCreatedTime
(
java
.
util
.
Date
createdTime
)
{
this
.
createdTime
=
createdTime
;
this
.
createdTime
=
createdTime
;
}
}
/** MODIFIER
*修改人
/**
* MODIFIER
* 修改人
*/
*/
private
java
.
lang
.
String
modifier
;
private
java
.
lang
.
String
modifier
;
public
java
.
lang
.
String
getModifier
(){
public
java
.
lang
.
String
getModifier
()
{
return
this
.
modifier
;
return
this
.
modifier
;
}
}
public
void
setModifier
(
java
.
lang
.
String
modifier
){
public
void
setModifier
(
java
.
lang
.
String
modifier
)
{
this
.
modifier
=
modifier
;
this
.
modifier
=
modifier
;
}
}
/** MODIFIED_TIME
*修改时间
/**
* MODIFIED_TIME
* 修改时间
*/
*/
private
java
.
util
.
Date
modifiedTime
;
private
java
.
util
.
Date
modifiedTime
;
public
java
.
util
.
Date
getModifiedTime
(){
public
java
.
util
.
Date
getModifiedTime
()
{
return
this
.
modifiedTime
;
return
this
.
modifiedTime
;
}
}
public
void
setModifiedTime
(
java
.
util
.
Date
modifiedTime
){
public
void
setModifiedTime
(
java
.
util
.
Date
modifiedTime
)
{
this
.
modifiedTime
=
modifiedTime
;
this
.
modifiedTime
=
modifiedTime
;
}
}
/** SYS_VERSION
*乐观锁,版本号
*/
private
java
.
lang
.
Integer
sysVersion
;
public
java
.
lang
.
Integer
getSysVersion
(){
return
this
.
sysVersion
;
}
public
void
setSysVersion
(
java
.
lang
.
Integer
sysVersion
){
this
.
sysVersion
=
sysVersion
;
}
}
}
\ No newline at end of file
src/main/java/cn/com/poc/agent_application/entity/CreateAgentTitleAndDescEntity.java
View file @
cbfb29ad
...
@@ -2,8 +2,14 @@ package cn.com.poc.agent_application.entity;
...
@@ -2,8 +2,14 @@ package cn.com.poc.agent_application.entity;
public
class
CreateAgentTitleAndDescEntity
{
public
class
CreateAgentTitleAndDescEntity
{
/**
* 应用名称
*/
private
String
agentTitle
;
private
String
agentTitle
;
/**
* 应用描述
*/
private
String
agentDesc
;
private
String
agentDesc
;
public
String
getAgentTitle
()
{
public
String
getAgentTitle
()
{
...
...
src/main/java/cn/com/poc/agent_application/entity/VoiceConfig.java
0 → 100644
View file @
cbfb29ad
package
cn
.
com
.
poc
.
agent_application
.
entity
;
public
class
VoiceConfig
{
/**
* 是否默认开启 Y-是 N-否
*/
private
String
defaultOpen
;
/**
* 音色ID
*/
private
String
timbreId
;
public
String
getDefaultOpen
()
{
return
defaultOpen
;
}
public
void
setDefaultOpen
(
String
defaultOpen
)
{
this
.
defaultOpen
=
defaultOpen
;
}
public
String
getTimbreId
()
{
return
timbreId
;
}
public
void
setTimbreId
(
String
timbreId
)
{
this
.
timbreId
=
timbreId
;
}
}
src/main/java/cn/com/poc/agent_application/model/BizAgentApplicationInfoModel.java
View file @
cbfb29ad
package
cn
.
com
.
poc
.
agent_application
.
model
;
package
cn
.
com
.
poc
.
agent_application
.
model
;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
cn.com.yict.framemax.data.model.BaseModelClass
;
import
cn.com.yict.framemax.data.model.BaseModelClass
;
import
javax.persistence.Column
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.Entity
;
import
javax.persistence.Table
;
import
javax.persistence.Table
;
import
javax.persistence.Id
;
import
javax.persistence.Id
;
import
org.hibernate.annotations.DynamicInsert
;
import
org.hibernate.annotations.DynamicInsert
;
import
org.hibernate.annotations.DynamicUpdate
;
import
org.hibernate.annotations.DynamicUpdate
;
import
javax.persistence.Version
;
import
javax.persistence.Version
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.GenerationType
;
import
javax.persistence.GenerationType
;
...
@@ -23,456 +27,515 @@ import javax.persistence.GenerationType;
...
@@ -23,456 +27,515 @@ import javax.persistence.GenerationType;
public
class
BizAgentApplicationInfoModel
extends
BaseModelClass
implements
Serializable
{
public
class
BizAgentApplicationInfoModel
extends
BaseModelClass
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
/** id
/**
*自增ID
* id
*/
* 自增ID
*/
private
java
.
lang
.
Integer
id
;
private
java
.
lang
.
Integer
id
;
@Column
(
name
=
"id"
,
length
=
10
)
@Column
(
name
=
"id"
,
length
=
10
)
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
AUTO
)
@Id
public
java
.
lang
.
Integer
getId
(){
@GeneratedValue
(
strategy
=
GenerationType
.
AUTO
)
public
java
.
lang
.
Integer
getId
()
{
return
this
.
id
;
return
this
.
id
;
}
}
public
void
setId
(
java
.
lang
.
Integer
id
){
public
void
setId
(
java
.
lang
.
Integer
id
)
{
this
.
id
=
id
;
this
.
id
=
id
;
super
.
addValidField
(
"id"
);
super
.
addValidField
(
"id"
);
}
}
/** member_id
/**
*创建应用的用户ID
* member_id
*/
* 创建应用的用户ID
*/
private
java
.
lang
.
Integer
memberId
;
private
java
.
lang
.
Integer
memberId
;
@Column
(
name
=
"member_id"
,
length
=
10
)
@Column
(
name
=
"member_id"
,
length
=
10
)
public
java
.
lang
.
Integer
getMemberId
(){
public
java
.
lang
.
Integer
getMemberId
()
{
return
this
.
memberId
;
return
this
.
memberId
;
}
}
public
void
setMemberId
(
java
.
lang
.
Integer
memberId
){
public
void
setMemberId
(
java
.
lang
.
Integer
memberId
)
{
this
.
memberId
=
memberId
;
this
.
memberId
=
memberId
;
super
.
addValidField
(
"memberId"
);
super
.
addValidField
(
"memberId"
);
}
}
/** agent_id
/**
*agent应用ID
* agent_id
*/
* agent应用ID
*/
private
java
.
lang
.
String
agentId
;
private
java
.
lang
.
String
agentId
;
@Column
(
name
=
"agent_id"
,
length
=
200
)
@Column
(
name
=
"agent_id"
,
length
=
200
)
public
java
.
lang
.
String
getAgentId
(){
public
java
.
lang
.
String
getAgentId
()
{
return
this
.
agentId
;
return
this
.
agentId
;
}
}
public
void
setAgentId
(
java
.
lang
.
String
agentId
){
public
void
setAgentId
(
java
.
lang
.
String
agentId
)
{
this
.
agentId
=
agentId
;
this
.
agentId
=
agentId
;
super
.
addValidField
(
"agentId"
);
super
.
addValidField
(
"agentId"
);
}
}
/** agent_avatar
/**
*应用头像ICON地址
* agent_avatar
*/
* 应用头像ICON地址
*/
private
java
.
lang
.
String
agentAvatar
;
private
java
.
lang
.
String
agentAvatar
;
@Column
(
name
=
"agent_avatar"
,
length
=
200
)
@Column
(
name
=
"agent_avatar"
,
length
=
200
)
public
java
.
lang
.
String
getAgentAvatar
(){
public
java
.
lang
.
String
getAgentAvatar
()
{
return
this
.
agentAvatar
;
return
this
.
agentAvatar
;
}
}
public
void
setAgentAvatar
(
java
.
lang
.
String
agentAvatar
){
public
void
setAgentAvatar
(
java
.
lang
.
String
agentAvatar
)
{
this
.
agentAvatar
=
agentAvatar
;
this
.
agentAvatar
=
agentAvatar
;
super
.
addValidField
(
"agentAvatar"
);
super
.
addValidField
(
"agentAvatar"
);
}
}
/** agent_title
/**
*应用标题
* agent_title
*/
* 应用标题
*/
private
java
.
lang
.
String
agentTitle
;
private
java
.
lang
.
String
agentTitle
;
@Column
(
name
=
"agent_title"
,
length
=
50
)
@Column
(
name
=
"agent_title"
,
length
=
50
)
public
java
.
lang
.
String
getAgentTitle
(){
public
java
.
lang
.
String
getAgentTitle
()
{
return
this
.
agentTitle
;
return
this
.
agentTitle
;
}
}
public
void
setAgentTitle
(
java
.
lang
.
String
agentTitle
){
public
void
setAgentTitle
(
java
.
lang
.
String
agentTitle
)
{
this
.
agentTitle
=
agentTitle
;
this
.
agentTitle
=
agentTitle
;
super
.
addValidField
(
"agentTitle"
);
super
.
addValidField
(
"agentTitle"
);
}
}
/** agent_desc
/**
*应用描述
* agent_desc
*/
* 应用描述
*/
private
java
.
lang
.
String
agentDesc
;
private
java
.
lang
.
String
agentDesc
;
@Column
(
name
=
"agent_desc"
,
length
=
100
)
@Column
(
name
=
"agent_desc"
,
length
=
100
)
public
java
.
lang
.
String
getAgentDesc
(){
public
java
.
lang
.
String
getAgentDesc
()
{
return
this
.
agentDesc
;
return
this
.
agentDesc
;
}
}
public
void
setAgentDesc
(
java
.
lang
.
String
agentDesc
){
public
void
setAgentDesc
(
java
.
lang
.
String
agentDesc
)
{
this
.
agentDesc
=
agentDesc
;
this
.
agentDesc
=
agentDesc
;
super
.
addValidField
(
"agentDesc"
);
super
.
addValidField
(
"agentDesc"
);
}
}
/** agent_system
/**
*角色指令
* agent_system
*/
* 角色指令
*/
private
java
.
lang
.
String
agentSystem
;
private
java
.
lang
.
String
agentSystem
;
@Column
(
name
=
"agent_system"
,
length
=
2147483647
)
@Column
(
name
=
"agent_system"
,
length
=
2147483647
)
public
java
.
lang
.
String
getAgentSystem
(){
public
java
.
lang
.
String
getAgentSystem
()
{
return
this
.
agentSystem
;
return
this
.
agentSystem
;
}
}
public
void
setAgentSystem
(
java
.
lang
.
String
agentSystem
){
public
void
setAgentSystem
(
java
.
lang
.
String
agentSystem
)
{
this
.
agentSystem
=
agentSystem
;
this
.
agentSystem
=
agentSystem
;
super
.
addValidField
(
"agentSystem"
);
super
.
addValidField
(
"agentSystem"
);
}
}
/** agent_publish_status
/**
*应用发布状态 草稿-draft 发布-publish
* agent_publish_status
*/
* 应用发布状态 草稿-draft 发布-publish
*/
private
java
.
lang
.
String
agentPublishStatus
;
private
java
.
lang
.
String
agentPublishStatus
;
@Column
(
name
=
"agent_publish_status"
,
length
=
10
)
@Column
(
name
=
"agent_publish_status"
,
length
=
10
)
public
java
.
lang
.
String
getAgentPublishStatus
(){
public
java
.
lang
.
String
getAgentPublishStatus
()
{
return
this
.
agentPublishStatus
;
return
this
.
agentPublishStatus
;
}
}
public
void
setAgentPublishStatus
(
java
.
lang
.
String
agentPublishStatus
){
public
void
setAgentPublishStatus
(
java
.
lang
.
String
agentPublishStatus
)
{
this
.
agentPublishStatus
=
agentPublishStatus
;
this
.
agentPublishStatus
=
agentPublishStatus
;
super
.
addValidField
(
"agentPublishStatus"
);
super
.
addValidField
(
"agentPublishStatus"
);
}
}
/** publish_time
/**
*发布时间
* publish_time
*/
* 发布时间
*/
private
java
.
util
.
Date
publishTime
;
private
java
.
util
.
Date
publishTime
;
@Column
(
name
=
"publish_time"
,
length
=
19
)
@Column
(
name
=
"publish_time"
,
length
=
19
)
public
java
.
util
.
Date
getPublishTime
(){
public
java
.
util
.
Date
getPublishTime
()
{
return
this
.
publishTime
;
return
this
.
publishTime
;
}
}
public
void
setPublishTime
(
java
.
util
.
Date
publishTime
){
public
void
setPublishTime
(
java
.
util
.
Date
publishTime
)
{
this
.
publishTime
=
publishTime
;
this
.
publishTime
=
publishTime
;
super
.
addValidField
(
"publishTime"
);
super
.
addValidField
(
"publishTime"
);
}
}
/** preamble
/**
*开场白
* preamble
*/
* 开场白
*/
private
java
.
lang
.
String
preamble
;
private
java
.
lang
.
String
preamble
;
@Column
(
name
=
"preamble"
,
length
=
2147483647
)
@Column
(
name
=
"preamble"
,
length
=
2147483647
)
public
java
.
lang
.
String
getPreamble
(){
public
java
.
lang
.
String
getPreamble
()
{
return
this
.
preamble
;
return
this
.
preamble
;
}
}
public
void
setPreamble
(
java
.
lang
.
String
preamble
){
public
void
setPreamble
(
java
.
lang
.
String
preamble
)
{
this
.
preamble
=
preamble
;
this
.
preamble
=
preamble
;
super
.
addValidField
(
"preamble"
);
super
.
addValidField
(
"preamble"
);
}
}
/** featured_questions
/**
*推荐问
* featured_questions
*/
* 推荐问
*/
private
java
.
lang
.
String
featuredQuestions
;
private
java
.
lang
.
String
featuredQuestions
;
@Column
(
name
=
"featured_questions"
,
length
=
1073741824
)
@Column
(
name
=
"featured_questions"
,
length
=
1073741824
)
public
java
.
lang
.
String
getFeaturedQuestions
(){
public
java
.
lang
.
String
getFeaturedQuestions
()
{
return
this
.
featuredQuestions
;
return
this
.
featuredQuestions
;
}
}
public
void
setFeaturedQuestions
(
java
.
lang
.
String
featuredQuestions
){
public
void
setFeaturedQuestions
(
java
.
lang
.
String
featuredQuestions
)
{
this
.
featuredQuestions
=
featuredQuestions
;
this
.
featuredQuestions
=
featuredQuestions
;
super
.
addValidField
(
"featuredQuestions"
);
super
.
addValidField
(
"featuredQuestions"
);
}
}
/** communication_turn
/**
*对话上下文保存轮次 0-100
* communication_turn
*/
* 对话上下文保存轮次 0-100
*/
private
java
.
lang
.
Integer
communicationTurn
;
private
java
.
lang
.
Integer
communicationTurn
;
@Column
(
name
=
"communication_turn"
,
length
=
10
)
@Column
(
name
=
"communication_turn"
,
length
=
10
)
public
java
.
lang
.
Integer
getCommunicationTurn
(){
public
java
.
lang
.
Integer
getCommunicationTurn
()
{
return
this
.
communicationTurn
;
return
this
.
communicationTurn
;
}
}
public
void
setCommunicationTurn
(
java
.
lang
.
Integer
communicationTurn
){
public
void
setCommunicationTurn
(
java
.
lang
.
Integer
communicationTurn
)
{
this
.
communicationTurn
=
communicationTurn
;
this
.
communicationTurn
=
communicationTurn
;
super
.
addValidField
(
"communicationTurn"
);
super
.
addValidField
(
"communicationTurn"
);
}
}
/** continuous_question_status
/**
*追问状态 默认-default 自定义-customizable 关闭-close
* continuous_question_status
*/
* 追问状态 默认-default 自定义-customizable 关闭-close
*/
private
java
.
lang
.
String
continuousQuestionStatus
;
private
java
.
lang
.
String
continuousQuestionStatus
;
@Column
(
name
=
"continuous_question_status"
,
length
=
15
)
@Column
(
name
=
"continuous_question_status"
,
length
=
15
)
public
java
.
lang
.
String
getContinuousQuestionStatus
(){
public
java
.
lang
.
String
getContinuousQuestionStatus
()
{
return
this
.
continuousQuestionStatus
;
return
this
.
continuousQuestionStatus
;
}
}
public
void
setContinuousQuestionStatus
(
java
.
lang
.
String
continuousQuestionStatus
){
public
void
setContinuousQuestionStatus
(
java
.
lang
.
String
continuousQuestionStatus
)
{
this
.
continuousQuestionStatus
=
continuousQuestionStatus
;
this
.
continuousQuestionStatus
=
continuousQuestionStatus
;
super
.
addValidField
(
"continuousQuestionStatus"
);
super
.
addValidField
(
"continuousQuestionStatus"
);
}
}
/** continuous_question_system
/**
*追问prompt
* continuous_question_system
*/
* 追问prompt
*/
private
java
.
lang
.
String
continuousQuestionSystem
;
private
java
.
lang
.
String
continuousQuestionSystem
;
@Column
(
name
=
"continuous_question_system"
,
length
=
2147483647
)
@Column
(
name
=
"continuous_question_system"
,
length
=
2147483647
)
public
java
.
lang
.
String
getContinuousQuestionSystem
(){
public
java
.
lang
.
String
getContinuousQuestionSystem
()
{
return
this
.
continuousQuestionSystem
;
return
this
.
continuousQuestionSystem
;
}
}
public
void
setContinuousQuestionSystem
(
java
.
lang
.
String
continuousQuestionSystem
){
public
void
setContinuousQuestionSystem
(
java
.
lang
.
String
continuousQuestionSystem
)
{
this
.
continuousQuestionSystem
=
continuousQuestionSystem
;
this
.
continuousQuestionSystem
=
continuousQuestionSystem
;
super
.
addValidField
(
"continuousQuestionSystem"
);
super
.
addValidField
(
"continuousQuestionSystem"
);
}
}
/** continuous_question_turn
/**
*追问轮次 1-5
* continuous_question_turn
*/
* 追问轮次 1-5
*/
private
java
.
lang
.
Integer
continuousQuestionTurn
;
private
java
.
lang
.
Integer
continuousQuestionTurn
;
@Column
(
name
=
"continuous_question_turn"
,
length
=
10
)
@Column
(
name
=
"continuous_question_turn"
,
length
=
10
)
public
java
.
lang
.
Integer
getContinuousQuestionTurn
(){
public
java
.
lang
.
Integer
getContinuousQuestionTurn
()
{
return
this
.
continuousQuestionTurn
;
return
this
.
continuousQuestionTurn
;
}
}
public
void
setContinuousQuestionTurn
(
java
.
lang
.
Integer
continuousQuestionTurn
){
public
void
setContinuousQuestionTurn
(
java
.
lang
.
Integer
continuousQuestionTurn
)
{
this
.
continuousQuestionTurn
=
continuousQuestionTurn
;
this
.
continuousQuestionTurn
=
continuousQuestionTurn
;
super
.
addValidField
(
"continuousQuestionTurn"
);
super
.
addValidField
(
"continuousQuestionTurn"
);
}
}
/** knowledge_ids
/**
*知识库ID
* knowledge_ids
*/
* 知识库ID
*/
private
java
.
lang
.
String
knowledgeIds
;
private
java
.
lang
.
String
knowledgeIds
;
@Column
(
name
=
"knowledge_ids"
,
length
=
1073741824
)
@Column
(
name
=
"knowledge_ids"
,
length
=
1073741824
)
public
java
.
lang
.
String
getKnowledgeIds
(){
public
java
.
lang
.
String
getKnowledgeIds
()
{
return
this
.
knowledgeIds
;
return
this
.
knowledgeIds
;
}
}
public
void
setKnowledgeIds
(
java
.
lang
.
String
knowledgeIds
){
public
void
setKnowledgeIds
(
java
.
lang
.
String
knowledgeIds
)
{
this
.
knowledgeIds
=
knowledgeIds
;
this
.
knowledgeIds
=
knowledgeIds
;
super
.
addValidField
(
"knowledgeIds"
);
super
.
addValidField
(
"knowledgeIds"
);
}
}
/** large_model
/**
*问答模型
* large_model
*/
* 问答模型
*/
private
java
.
lang
.
String
largeModel
;
private
java
.
lang
.
String
largeModel
;
@Column
(
name
=
"large_model"
,
length
=
25
)
@Column
(
name
=
"large_model"
,
length
=
25
)
public
java
.
lang
.
String
getLargeModel
(){
public
java
.
lang
.
String
getLargeModel
()
{
return
this
.
largeModel
;
return
this
.
largeModel
;
}
}
public
void
setLargeModel
(
java
.
lang
.
String
largeModel
){
public
void
setLargeModel
(
java
.
lang
.
String
largeModel
)
{
this
.
largeModel
=
largeModel
;
this
.
largeModel
=
largeModel
;
super
.
addValidField
(
"largeModel"
);
super
.
addValidField
(
"largeModel"
);
}
}
/** top_p
/**
*对话模型 多样性 [0-1.00]
* top_p
*/
* 对话模型 多样性 [0-1.00]
*/
private
java
.
lang
.
Float
topP
;
private
java
.
lang
.
Float
topP
;
@Column
(
name
=
"top_p"
,
length
=
12
)
@Column
(
name
=
"top_p"
,
length
=
12
)
public
java
.
lang
.
Float
getTopP
(){
public
java
.
lang
.
Float
getTopP
()
{
return
this
.
topP
;
return
this
.
topP
;
}
}
public
void
setTopP
(
java
.
lang
.
Float
topP
){
public
void
setTopP
(
java
.
lang
.
Float
topP
)
{
this
.
topP
=
topP
;
this
.
topP
=
topP
;
super
.
addValidField
(
"topP"
);
super
.
addValidField
(
"topP"
);
}
}
/**
/*
* temperature
* temperature
*对话模型 温度 [0-1.00]
*
对话模型 温度 [0-1.00]
*/
*/
private
java
.
lang
.
Float
temperature
;
private
java
.
lang
.
Float
temperature
;
@Column
(
name
=
"temperature"
,
length
=
12
)
@Column
(
name
=
"temperature"
,
length
=
12
)
public
java
.
lang
.
Float
getTemperature
(){
public
java
.
lang
.
Float
getTemperature
()
{
return
this
.
temperature
;
return
this
.
temperature
;
}
}
public
void
setTemperature
(
java
.
lang
.
Float
temperature
){
public
void
setTemperature
(
java
.
lang
.
Float
temperature
)
{
this
.
temperature
=
temperature
;
this
.
temperature
=
temperature
;
super
.
addValidField
(
"temperature"
);
super
.
addValidField
(
"temperature"
);
}
}
/**
* unit_ids
/** unit_ids
* 组件ID
*组件ID
*/
*/
private
java
.
lang
.
String
unitIds
;
private
java
.
lang
.
String
unitIds
;
@Column
(
name
=
"unit_ids"
,
length
=
1073741824
)
@Column
(
name
=
"unit_ids"
,
length
=
1073741824
)
public
java
.
lang
.
String
getUnitIds
(){
public
java
.
lang
.
String
getUnitIds
()
{
return
this
.
unitIds
;
return
this
.
unitIds
;
}
}
public
void
setUnitIds
(
java
.
lang
.
String
unitIds
){
public
void
setUnitIds
(
java
.
lang
.
String
unitIds
)
{
this
.
unitIds
=
unitIds
;
this
.
unitIds
=
unitIds
;
super
.
addValidField
(
"unitIds"
);
super
.
addValidField
(
"unitIds"
);
}
}
/** variable_structure
/**
*变量结构
* variable_structure
* 变量结构
*/
*/
private
java
.
lang
.
String
variableStructure
;
private
java
.
lang
.
String
variableStructure
;
@Column
(
name
=
"variable_structure"
,
length
=
2147483647
)
@Column
(
name
=
"variable_structure"
,
length
=
2147483647
)
public
java
.
lang
.
String
getVariableStructure
(){
public
java
.
lang
.
String
getVariableStructure
()
{
return
this
.
variableStructure
;
return
this
.
variableStructure
;
}
}
public
void
setVariableStructure
(
java
.
lang
.
String
variableStructure
){
public
void
setVariableStructure
(
java
.
lang
.
String
variableStructure
)
{
this
.
variableStructure
=
variableStructure
;
this
.
variableStructure
=
variableStructure
;
super
.
addValidField
(
"variableStructure"
);
super
.
addValidField
(
"variableStructure"
);
}
}
/** is_long_memory
/**
*是否开启长期记忆 1、Y 是 2、N 否
* is_long_memory
* 是否开启长期记忆 1、Y 是 2、N 否
*/
*/
private
java
.
lang
.
String
isLongMemory
;
private
java
.
lang
.
String
isLongMemory
;
@Column
(
name
=
"is_long_memory"
,
length
=
1
)
@Column
(
name
=
"is_long_memory"
,
length
=
1
)
public
java
.
lang
.
String
getIsLongMemory
(){
public
java
.
lang
.
String
getIsLongMemory
()
{
return
this
.
isLongMemory
;
return
this
.
isLongMemory
;
}
}
public
void
setIsLongMemory
(
java
.
lang
.
String
isLongMemory
){
public
void
setIsLongMemory
(
java
.
lang
.
String
isLongMemory
)
{
this
.
isLongMemory
=
isLongMemory
;
this
.
isLongMemory
=
isLongMemory
;
super
.
addValidField
(
"isLongMemory"
);
super
.
addValidField
(
"isLongMemory"
);
}
}
/** is_deleted
*是否删除 1、Y 是 2、N 否
/**
*/
* is_document_parsing
* 是否开启文档解析 1、Y 是 2、N 否
*/
private
java
.
lang
.
String
isDocumentParsing
;
@Column
(
name
=
"is_document_parsing"
,
length
=
1
)
public
java
.
lang
.
String
getIsDocumentParsing
()
{
return
this
.
isDocumentParsing
;
}
public
void
setIsDocumentParsing
(
java
.
lang
.
String
isDocumentParsing
)
{
this
.
isDocumentParsing
=
isDocumentParsing
;
super
.
addValidField
(
"isDocumentParsing"
);
}
/**
* voice_config
* 声音配置 defaultOpen-是否默认开启 timbreId-音色
*/
private
java
.
lang
.
String
voiceConfig
;
@Column
(
name
=
"voice_config"
,
length
=
2147483647
)
public
java
.
lang
.
String
getVoiceConfig
()
{
return
this
.
voiceConfig
;
}
public
void
setVoiceConfig
(
String
voiceConfig
)
{
this
.
voiceConfig
=
voiceConfig
;
super
.
addValidField
(
"voiceConfig"
);
}
/**
* is_deleted
* 是否删除 1、Y 是 2、N 否
*/
private
java
.
lang
.
String
isDeleted
;
private
java
.
lang
.
String
isDeleted
;
@Column
(
name
=
"is_deleted"
,
length
=
1
)
@Column
(
name
=
"is_deleted"
,
length
=
1
)
public
java
.
lang
.
String
getIsDeleted
(){
public
java
.
lang
.
String
getIsDeleted
()
{
return
this
.
isDeleted
;
return
this
.
isDeleted
;
}
}
public
void
setIsDeleted
(
java
.
lang
.
String
isDeleted
){
public
void
setIsDeleted
(
java
.
lang
.
String
isDeleted
)
{
this
.
isDeleted
=
isDeleted
;
this
.
isDeleted
=
isDeleted
;
super
.
addValidField
(
"isDeleted"
);
super
.
addValidField
(
"isDeleted"
);
}
}
/** CREATOR
/**
*创建人
* CREATOR
*/
* 创建人
*/
private
java
.
lang
.
String
creator
;
private
java
.
lang
.
String
creator
;
@Column
(
name
=
"CREATOR"
,
length
=
225
)
@Column
(
name
=
"CREATOR"
,
length
=
225
)
public
java
.
lang
.
String
getCreator
(){
public
java
.
lang
.
String
getCreator
()
{
return
this
.
creator
;
return
this
.
creator
;
}
}
public
void
setCreator
(
java
.
lang
.
String
creator
){
public
void
setCreator
(
java
.
lang
.
String
creator
)
{
this
.
creator
=
creator
;
this
.
creator
=
creator
;
super
.
addValidField
(
"creator"
);
super
.
addValidField
(
"creator"
);
}
}
/** CREATED_TIME
/**
*创建时间
* CREATED_TIME
*/
* 创建时间
*/
private
java
.
util
.
Date
createdTime
;
private
java
.
util
.
Date
createdTime
;
@Column
(
name
=
"CREATED_TIME"
,
length
=
19
)
@Column
(
name
=
"CREATED_TIME"
,
length
=
19
)
public
java
.
util
.
Date
getCreatedTime
(){
public
java
.
util
.
Date
getCreatedTime
()
{
return
this
.
createdTime
;
return
this
.
createdTime
;
}
}
public
void
setCreatedTime
(
java
.
util
.
Date
createdTime
){
public
void
setCreatedTime
(
java
.
util
.
Date
createdTime
)
{
this
.
createdTime
=
createdTime
;
this
.
createdTime
=
createdTime
;
super
.
addValidField
(
"createdTime"
);
super
.
addValidField
(
"createdTime"
);
}
}
/** MODIFIER
/**
*修改人
* MODIFIER
*/
* 修改人
*/
private
java
.
lang
.
String
modifier
;
private
java
.
lang
.
String
modifier
;
@Column
(
name
=
"MODIFIER"
,
length
=
225
)
@Column
(
name
=
"MODIFIER"
,
length
=
225
)
public
java
.
lang
.
String
getModifier
(){
public
java
.
lang
.
String
getModifier
()
{
return
this
.
modifier
;
return
this
.
modifier
;
}
}
public
void
setModifier
(
java
.
lang
.
String
modifier
){
public
void
setModifier
(
java
.
lang
.
String
modifier
)
{
this
.
modifier
=
modifier
;
this
.
modifier
=
modifier
;
super
.
addValidField
(
"modifier"
);
super
.
addValidField
(
"modifier"
);
}
}
/** MODIFIED_TIME
/**
*修改时间
* MODIFIED_TIME
*/
* 修改时间
*/
private
java
.
util
.
Date
modifiedTime
;
private
java
.
util
.
Date
modifiedTime
;
@Column
(
name
=
"MODIFIED_TIME"
,
length
=
19
)
@Column
(
name
=
"MODIFIED_TIME"
,
length
=
19
)
public
java
.
util
.
Date
getModifiedTime
(){
public
java
.
util
.
Date
getModifiedTime
()
{
return
this
.
modifiedTime
;
return
this
.
modifiedTime
;
}
}
public
void
setModifiedTime
(
java
.
util
.
Date
modifiedTime
){
public
void
setModifiedTime
(
java
.
util
.
Date
modifiedTime
)
{
this
.
modifiedTime
=
modifiedTime
;
this
.
modifiedTime
=
modifiedTime
;
super
.
addValidField
(
"modifiedTime"
);
super
.
addValidField
(
"modifiedTime"
);
}
}
/** SYS_VERSION
/**
*乐观锁,版本号
* SYS_VERSION
*/
* 乐观锁,版本号
*/
private
java
.
lang
.
Integer
sysVersion
;
private
java
.
lang
.
Integer
sysVersion
;
@Column
(
name
=
"SYS_VERSION"
,
length
=
10
)
@Column
(
name
=
"SYS_VERSION"
,
length
=
10
)
@Version
@Version
public
java
.
lang
.
Integer
getSysVersion
(){
public
java
.
lang
.
Integer
getSysVersion
()
{
return
this
.
sysVersion
;
return
this
.
sysVersion
;
}
}
public
void
setSysVersion
(
java
.
lang
.
Integer
sysVersion
){
public
void
setSysVersion
(
java
.
lang
.
Integer
sysVersion
)
{
this
.
sysVersion
=
sysVersion
;
this
.
sysVersion
=
sysVersion
;
super
.
addValidField
(
"sysVersion"
);
super
.
addValidField
(
"sysVersion"
);
}
}
}
}
\ No newline at end of file
src/main/java/cn/com/poc/agent_application/model/BizAgentApplicationPublishModel.java
View file @
cbfb29ad
package
cn
.
com
.
poc
.
agent_application
.
model
;
package
cn
.
com
.
poc
.
agent_application
.
model
;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
cn.com.yict.framemax.data.model.BaseModelClass
;
import
cn.com.yict.framemax.data.model.BaseModelClass
;
import
javax.persistence.Column
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.Entity
;
import
javax.persistence.Table
;
import
javax.persistence.Table
;
import
javax.persistence.Id
;
import
javax.persistence.Id
;
import
org.hibernate.annotations.DynamicInsert
;
import
org.hibernate.annotations.DynamicInsert
;
import
org.hibernate.annotations.DynamicUpdate
;
import
org.hibernate.annotations.DynamicUpdate
;
import
javax.persistence.Version
;
import
javax.persistence.Version
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.GenerationType
;
import
javax.persistence.GenerationType
;
...
@@ -23,422 +27,477 @@ import javax.persistence.GenerationType;
...
@@ -23,422 +27,477 @@ import javax.persistence.GenerationType;
public
class
BizAgentApplicationPublishModel
extends
BaseModelClass
implements
Serializable
{
public
class
BizAgentApplicationPublishModel
extends
BaseModelClass
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
/** id
/**
*自增ID
* id
*/
* 自增ID
*/
private
java
.
lang
.
Integer
id
;
private
java
.
lang
.
Integer
id
;
@Column
(
name
=
"id"
,
length
=
10
)
@Column
(
name
=
"id"
,
length
=
10
)
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
AUTO
)
@Id
public
java
.
lang
.
Integer
getId
(){
@GeneratedValue
(
strategy
=
GenerationType
.
AUTO
)
public
java
.
lang
.
Integer
getId
()
{
return
this
.
id
;
return
this
.
id
;
}
}
public
void
setId
(
java
.
lang
.
Integer
id
){
public
void
setId
(
java
.
lang
.
Integer
id
)
{
this
.
id
=
id
;
this
.
id
=
id
;
super
.
addValidField
(
"id"
);
super
.
addValidField
(
"id"
);
}
}
/** member_id
/**
*创建应用的用户ID
* member_id
*/
* 创建应用的用户ID
*/
private
java
.
lang
.
Integer
memberId
;
private
java
.
lang
.
Integer
memberId
;
@Column
(
name
=
"member_id"
,
length
=
10
)
@Column
(
name
=
"member_id"
,
length
=
10
)
public
java
.
lang
.
Integer
getMemberId
(){
public
java
.
lang
.
Integer
getMemberId
()
{
return
this
.
memberId
;
return
this
.
memberId
;
}
}
public
void
setMemberId
(
java
.
lang
.
Integer
memberId
){
public
void
setMemberId
(
java
.
lang
.
Integer
memberId
)
{
this
.
memberId
=
memberId
;
this
.
memberId
=
memberId
;
super
.
addValidField
(
"memberId"
);
super
.
addValidField
(
"memberId"
);
}
}
/** agent_id
/**
*agent应用ID
* agent_id
*/
* agent应用ID
*/
private
java
.
lang
.
String
agentId
;
private
java
.
lang
.
String
agentId
;
@Column
(
name
=
"agent_id"
,
length
=
200
)
@Column
(
name
=
"agent_id"
,
length
=
200
)
public
java
.
lang
.
String
getAgentId
(){
public
java
.
lang
.
String
getAgentId
()
{
return
this
.
agentId
;
return
this
.
agentId
;
}
}
public
void
setAgentId
(
java
.
lang
.
String
agentId
){
public
void
setAgentId
(
java
.
lang
.
String
agentId
)
{
this
.
agentId
=
agentId
;
this
.
agentId
=
agentId
;
super
.
addValidField
(
"agentId"
);
super
.
addValidField
(
"agentId"
);
}
}
/** agent_avatar
/**
*应用头像ICON地址
* agent_avatar
*/
* 应用头像ICON地址
*/
private
java
.
lang
.
String
agentAvatar
;
private
java
.
lang
.
String
agentAvatar
;
@Column
(
name
=
"agent_avatar"
,
length
=
200
)
@Column
(
name
=
"agent_avatar"
,
length
=
200
)
public
java
.
lang
.
String
getAgentAvatar
(){
public
java
.
lang
.
String
getAgentAvatar
()
{
return
this
.
agentAvatar
;
return
this
.
agentAvatar
;
}
}
public
void
setAgentAvatar
(
java
.
lang
.
String
agentAvatar
){
public
void
setAgentAvatar
(
java
.
lang
.
String
agentAvatar
)
{
this
.
agentAvatar
=
agentAvatar
;
this
.
agentAvatar
=
agentAvatar
;
super
.
addValidField
(
"agentAvatar"
);
super
.
addValidField
(
"agentAvatar"
);
}
}
/** agent_title
/**
*应用标题
* agent_title
*/
* 应用标题
*/
private
java
.
lang
.
String
agentTitle
;
private
java
.
lang
.
String
agentTitle
;
@Column
(
name
=
"agent_title"
,
length
=
50
)
@Column
(
name
=
"agent_title"
,
length
=
50
)
public
java
.
lang
.
String
getAgentTitle
(){
public
java
.
lang
.
String
getAgentTitle
()
{
return
this
.
agentTitle
;
return
this
.
agentTitle
;
}
}
public
void
setAgentTitle
(
java
.
lang
.
String
agentTitle
){
public
void
setAgentTitle
(
java
.
lang
.
String
agentTitle
)
{
this
.
agentTitle
=
agentTitle
;
this
.
agentTitle
=
agentTitle
;
super
.
addValidField
(
"agentTitle"
);
super
.
addValidField
(
"agentTitle"
);
}
}
/** agent_desc
/**
*应用描述
* agent_desc
*/
* 应用描述
*/
private
java
.
lang
.
String
agentDesc
;
private
java
.
lang
.
String
agentDesc
;
@Column
(
name
=
"agent_desc"
,
length
=
100
)
@Column
(
name
=
"agent_desc"
,
length
=
100
)
public
java
.
lang
.
String
getAgentDesc
(){
public
java
.
lang
.
String
getAgentDesc
()
{
return
this
.
agentDesc
;
return
this
.
agentDesc
;
}
}
public
void
setAgentDesc
(
java
.
lang
.
String
agentDesc
){
public
void
setAgentDesc
(
java
.
lang
.
String
agentDesc
)
{
this
.
agentDesc
=
agentDesc
;
this
.
agentDesc
=
agentDesc
;
super
.
addValidField
(
"agentDesc"
);
super
.
addValidField
(
"agentDesc"
);
}
}
/** agent_system
/**
*角色指令
* agent_system
*/
* 角色指令
*/
private
java
.
lang
.
String
agentSystem
;
private
java
.
lang
.
String
agentSystem
;
@Column
(
name
=
"agent_system"
,
length
=
2147483647
)
@Column
(
name
=
"agent_system"
,
length
=
2147483647
)
public
java
.
lang
.
String
getAgentSystem
(){
public
java
.
lang
.
String
getAgentSystem
()
{
return
this
.
agentSystem
;
return
this
.
agentSystem
;
}
}
public
void
setAgentSystem
(
java
.
lang
.
String
agentSystem
){
public
void
setAgentSystem
(
java
.
lang
.
String
agentSystem
)
{
this
.
agentSystem
=
agentSystem
;
this
.
agentSystem
=
agentSystem
;
super
.
addValidField
(
"agentSystem"
);
super
.
addValidField
(
"agentSystem"
);
}
}
/** preamble
/**
*开场白
* preamble
*/
* 开场白
*/
private
java
.
lang
.
String
preamble
;
private
java
.
lang
.
String
preamble
;
@Column
(
name
=
"preamble"
,
length
=
2147483647
)
@Column
(
name
=
"preamble"
,
length
=
2147483647
)
public
java
.
lang
.
String
getPreamble
(){
public
java
.
lang
.
String
getPreamble
()
{
return
this
.
preamble
;
return
this
.
preamble
;
}
}
public
void
setPreamble
(
java
.
lang
.
String
preamble
){
public
void
setPreamble
(
java
.
lang
.
String
preamble
)
{
this
.
preamble
=
preamble
;
this
.
preamble
=
preamble
;
super
.
addValidField
(
"preamble"
);
super
.
addValidField
(
"preamble"
);
}
}
/** variable_structure
/**
*变量结构
* variable_structure
* 变量结构
*/
*/
private
java
.
lang
.
String
variableStructure
;
private
java
.
lang
.
String
variableStructure
;
@Column
(
name
=
"variable_structure"
,
length
=
2147483647
)
@Column
(
name
=
"variable_structure"
,
length
=
2147483647
)
public
java
.
lang
.
String
getVariableStructure
(){
public
java
.
lang
.
String
getVariableStructure
()
{
return
this
.
variableStructure
;
return
this
.
variableStructure
;
}
}
public
void
setVariableStructure
(
java
.
lang
.
String
variableStructure
){
public
void
setVariableStructure
(
java
.
lang
.
String
variableStructure
)
{
this
.
variableStructure
=
variableStructure
;
this
.
variableStructure
=
variableStructure
;
super
.
addValidField
(
"variableStructure"
);
super
.
addValidField
(
"variableStructure"
);
}
}
/** featured_questions
/**
*推荐问
* featured_questions
*/
* 推荐问
*/
private
java
.
lang
.
String
featuredQuestions
;
private
java
.
lang
.
String
featuredQuestions
;
@Column
(
name
=
"featured_questions"
,
length
=
1073741824
)
@Column
(
name
=
"featured_questions"
,
length
=
1073741824
)
public
java
.
lang
.
String
getFeaturedQuestions
(){
public
java
.
lang
.
String
getFeaturedQuestions
()
{
return
this
.
featuredQuestions
;
return
this
.
featuredQuestions
;
}
}
public
void
setFeaturedQuestions
(
java
.
lang
.
String
featuredQuestions
){
public
void
setFeaturedQuestions
(
java
.
lang
.
String
featuredQuestions
)
{
this
.
featuredQuestions
=
featuredQuestions
;
this
.
featuredQuestions
=
featuredQuestions
;
super
.
addValidField
(
"featuredQuestions"
);
super
.
addValidField
(
"featuredQuestions"
);
}
}
/** communication_turn
/**
*对话上下文保存轮次 0-100
* communication_turn
*/
* 对话上下文保存轮次 0-100
*/
private
java
.
lang
.
Integer
communicationTurn
;
private
java
.
lang
.
Integer
communicationTurn
;
@Column
(
name
=
"communication_turn"
,
length
=
10
)
@Column
(
name
=
"communication_turn"
,
length
=
10
)
public
java
.
lang
.
Integer
getCommunicationTurn
(){
public
java
.
lang
.
Integer
getCommunicationTurn
()
{
return
this
.
communicationTurn
;
return
this
.
communicationTurn
;
}
}
public
void
setCommunicationTurn
(
java
.
lang
.
Integer
communicationTurn
){
public
void
setCommunicationTurn
(
java
.
lang
.
Integer
communicationTurn
)
{
this
.
communicationTurn
=
communicationTurn
;
this
.
communicationTurn
=
communicationTurn
;
super
.
addValidField
(
"communicationTurn"
);
super
.
addValidField
(
"communicationTurn"
);
}
}
/** continuous_question_status
/**
*追问状态 默认-default 自定义-customizable 关闭-close
* continuous_question_status
*/
* 追问状态 默认-default 自定义-customizable 关闭-close
*/
private
java
.
lang
.
String
continuousQuestionStatus
;
private
java
.
lang
.
String
continuousQuestionStatus
;
@Column
(
name
=
"continuous_question_status"
,
length
=
15
)
@Column
(
name
=
"continuous_question_status"
,
length
=
15
)
public
java
.
lang
.
String
getContinuousQuestionStatus
(){
public
java
.
lang
.
String
getContinuousQuestionStatus
()
{
return
this
.
continuousQuestionStatus
;
return
this
.
continuousQuestionStatus
;
}
}
public
void
setContinuousQuestionStatus
(
java
.
lang
.
String
continuousQuestionStatus
){
public
void
setContinuousQuestionStatus
(
java
.
lang
.
String
continuousQuestionStatus
)
{
this
.
continuousQuestionStatus
=
continuousQuestionStatus
;
this
.
continuousQuestionStatus
=
continuousQuestionStatus
;
super
.
addValidField
(
"continuousQuestionStatus"
);
super
.
addValidField
(
"continuousQuestionStatus"
);
}
}
/** continuous_question_system
/**
*追问prompt
* continuous_question_system
*/
* 追问prompt
*/
private
java
.
lang
.
String
continuousQuestionSystem
;
private
java
.
lang
.
String
continuousQuestionSystem
;
@Column
(
name
=
"continuous_question_system"
,
length
=
2147483647
)
@Column
(
name
=
"continuous_question_system"
,
length
=
2147483647
)
public
java
.
lang
.
String
getContinuousQuestionSystem
(){
public
java
.
lang
.
String
getContinuousQuestionSystem
()
{
return
this
.
continuousQuestionSystem
;
return
this
.
continuousQuestionSystem
;
}
}
public
void
setContinuousQuestionSystem
(
java
.
lang
.
String
continuousQuestionSystem
){
public
void
setContinuousQuestionSystem
(
java
.
lang
.
String
continuousQuestionSystem
)
{
this
.
continuousQuestionSystem
=
continuousQuestionSystem
;
this
.
continuousQuestionSystem
=
continuousQuestionSystem
;
super
.
addValidField
(
"continuousQuestionSystem"
);
super
.
addValidField
(
"continuousQuestionSystem"
);
}
}
/** continuous_question_turn
/**
*追问轮次 1-5
* continuous_question_turn
*/
* 追问轮次 1-5
*/
private
java
.
lang
.
Integer
continuousQuestionTurn
;
private
java
.
lang
.
Integer
continuousQuestionTurn
;
@Column
(
name
=
"continuous_question_turn"
,
length
=
10
)
@Column
(
name
=
"continuous_question_turn"
,
length
=
10
)
public
java
.
lang
.
Integer
getContinuousQuestionTurn
(){
public
java
.
lang
.
Integer
getContinuousQuestionTurn
()
{
return
this
.
continuousQuestionTurn
;
return
this
.
continuousQuestionTurn
;
}
}
public
void
setContinuousQuestionTurn
(
java
.
lang
.
Integer
continuousQuestionTurn
){
public
void
setContinuousQuestionTurn
(
java
.
lang
.
Integer
continuousQuestionTurn
)
{
this
.
continuousQuestionTurn
=
continuousQuestionTurn
;
this
.
continuousQuestionTurn
=
continuousQuestionTurn
;
super
.
addValidField
(
"continuousQuestionTurn"
);
super
.
addValidField
(
"continuousQuestionTurn"
);
}
}
/** knowledge_ids
/**
*知识库ID
* knowledge_ids
*/
* 知识库ID
*/
private
java
.
lang
.
String
knowledgeIds
;
private
java
.
lang
.
String
knowledgeIds
;
@Column
(
name
=
"knowledge_ids"
,
length
=
1073741824
)
@Column
(
name
=
"knowledge_ids"
,
length
=
1073741824
)
public
java
.
lang
.
String
getKnowledgeIds
(){
public
java
.
lang
.
String
getKnowledgeIds
()
{
return
this
.
knowledgeIds
;
return
this
.
knowledgeIds
;
}
}
public
void
setKnowledgeIds
(
java
.
lang
.
String
knowledgeIds
){
public
void
setKnowledgeIds
(
java
.
lang
.
String
knowledgeIds
)
{
this
.
knowledgeIds
=
knowledgeIds
;
this
.
knowledgeIds
=
knowledgeIds
;
super
.
addValidField
(
"knowledgeIds"
);
super
.
addValidField
(
"knowledgeIds"
);
}
}
/** large_model
/**
*问答模型
* large_model
*/
* 问答模型
*/
private
java
.
lang
.
String
largeModel
;
private
java
.
lang
.
String
largeModel
;
@Column
(
name
=
"large_model"
,
length
=
25
)
@Column
(
name
=
"large_model"
,
length
=
25
)
public
java
.
lang
.
String
getLargeModel
(){
public
java
.
lang
.
String
getLargeModel
()
{
return
this
.
largeModel
;
return
this
.
largeModel
;
}
}
public
void
setLargeModel
(
java
.
lang
.
String
largeModel
){
public
void
setLargeModel
(
java
.
lang
.
String
largeModel
)
{
this
.
largeModel
=
largeModel
;
this
.
largeModel
=
largeModel
;
super
.
addValidField
(
"largeModel"
);
super
.
addValidField
(
"largeModel"
);
}
}
/** top_p
/**
*对话模型 多样性 [0-1.00]
* top_p
*/
* 对话模型 多样性 [0-1.00]
*/
private
java
.
lang
.
Float
topP
;
private
java
.
lang
.
Float
topP
;
@Column
(
name
=
"top_p"
,
length
=
12
)
@Column
(
name
=
"top_p"
,
length
=
12
)
public
java
.
lang
.
Float
getTopP
(){
public
java
.
lang
.
Float
getTopP
()
{
return
this
.
topP
;
return
this
.
topP
;
}
}
public
void
setTopP
(
java
.
lang
.
Float
topP
){
public
void
setTopP
(
java
.
lang
.
Float
topP
)
{
this
.
topP
=
topP
;
this
.
topP
=
topP
;
super
.
addValidField
(
"topP"
);
super
.
addValidField
(
"topP"
);
}
}
/** temperature
/**
*对话模型 温度 [0-1.00]
* temperature
* 对话模型 温度 [0-1.00]
*/
*/
private
java
.
lang
.
Float
temperature
;
private
java
.
lang
.
Float
temperature
;
@Column
(
name
=
"temperature"
,
length
=
12
)
@Column
(
name
=
"temperature"
,
length
=
12
)
public
java
.
lang
.
Float
getTemperature
(){
public
java
.
lang
.
Float
getTemperature
()
{
return
this
.
temperature
;
return
this
.
temperature
;
}
}
public
void
setTemperature
(
java
.
lang
.
Float
temperature
){
public
void
setTemperature
(
java
.
lang
.
Float
temperature
)
{
this
.
temperature
=
temperature
;
this
.
temperature
=
temperature
;
super
.
addValidField
(
"temperature"
);
super
.
addValidField
(
"temperature"
);
}
}
/**
/*
* unit_ids
* unit_ids
*
组件ID
*
组件ID
*/
*/
private
java
.
lang
.
String
unitIds
;
private
java
.
lang
.
String
unitIds
;
@Column
(
name
=
"unit_ids"
,
length
=
1073741824
)
@Column
(
name
=
"unit_ids"
,
length
=
1073741824
)
public
java
.
lang
.
String
getUnitIds
(){
public
java
.
lang
.
String
getUnitIds
()
{
return
this
.
unitIds
;
return
this
.
unitIds
;
}
}
public
void
setUnitIds
(
java
.
lang
.
String
unitIds
){
public
void
setUnitIds
(
java
.
lang
.
String
unitIds
)
{
this
.
unitIds
=
unitIds
;
this
.
unitIds
=
unitIds
;
super
.
addValidField
(
"unitIds"
);
super
.
addValidField
(
"unitIds"
);
}
}
/** is_long_memory
/**
*是否开启长期记忆 1、Y 是 2、N 否
* is_long_memory
* 是否开启长期记忆 1、Y 是 2、N 否
*/
*/
private
java
.
lang
.
String
isLongMemory
;
private
java
.
lang
.
String
isLongMemory
;
@Column
(
name
=
"is_long_memory"
,
length
=
1
)
@Column
(
name
=
"is_long_memory"
,
length
=
1
)
public
java
.
lang
.
String
getIsLongMemory
(){
public
java
.
lang
.
String
getIsLongMemory
()
{
return
this
.
isLongMemory
;
return
this
.
isLongMemory
;
}
}
public
void
setIsLongMemory
(
java
.
lang
.
String
isLongMemory
){
public
void
setIsLongMemory
(
java
.
lang
.
String
isLongMemory
)
{
this
.
isLongMemory
=
isLongMemory
;
this
.
isLongMemory
=
isLongMemory
;
super
.
addValidField
(
"isLongMemory"
);
super
.
addValidField
(
"isLongMemory"
);
}
}
/** is_deleted
private
java
.
lang
.
String
isDocumentParsing
;
*是否删除 1、Y 是 2、N 否
*/
@Column
(
name
=
"is_document_parsing"
,
length
=
1
)
public
java
.
lang
.
String
getIsDocumentParsing
()
{
return
this
.
isDocumentParsing
;
}
public
void
setIsDocumentParsing
(
java
.
lang
.
String
isDocumentParsing
)
{
this
.
isDocumentParsing
=
isDocumentParsing
;
super
.
addValidField
(
"isDocumentParsing"
);
}
/**
* voice_config
* 声音配置 default_open-是否默认开启 timbre_id-音色
*/
private
java
.
lang
.
String
voiceConfig
;
@Column
(
name
=
"voice_config"
,
length
=
2147483647
)
public
java
.
lang
.
String
getVoiceConfig
()
{
return
this
.
voiceConfig
;
}
public
void
setVoiceConfig
(
String
voiceConfig
)
{
this
.
voiceConfig
=
voiceConfig
;
super
.
addValidField
(
"voiceConfig"
);
}
/**
* is_deleted
* 是否删除 1、Y 是 2、N 否
*/
private
java
.
lang
.
String
isDeleted
;
private
java
.
lang
.
String
isDeleted
;
@Column
(
name
=
"is_deleted"
,
length
=
1
)
@Column
(
name
=
"is_deleted"
,
length
=
1
)
public
java
.
lang
.
String
getIsDeleted
(){
public
java
.
lang
.
String
getIsDeleted
()
{
return
this
.
isDeleted
;
return
this
.
isDeleted
;
}
}
public
void
setIsDeleted
(
java
.
lang
.
String
isDeleted
){
public
void
setIsDeleted
(
java
.
lang
.
String
isDeleted
)
{
this
.
isDeleted
=
isDeleted
;
this
.
isDeleted
=
isDeleted
;
super
.
addValidField
(
"isDeleted"
);
super
.
addValidField
(
"isDeleted"
);
}
}
/** CREATOR
/**
*创建人
* CREATOR
*/
* 创建人
*/
private
java
.
lang
.
String
creator
;
private
java
.
lang
.
String
creator
;
@Column
(
name
=
"CREATOR"
,
length
=
225
)
@Column
(
name
=
"CREATOR"
,
length
=
225
)
public
java
.
lang
.
String
getCreator
(){
public
java
.
lang
.
String
getCreator
()
{
return
this
.
creator
;
return
this
.
creator
;
}
}
public
void
setCreator
(
java
.
lang
.
String
creator
){
public
void
setCreator
(
java
.
lang
.
String
creator
)
{
this
.
creator
=
creator
;
this
.
creator
=
creator
;
super
.
addValidField
(
"creator"
);
super
.
addValidField
(
"creator"
);
}
}
/** CREATED_TIME
/**
*创建时间
* CREATED_TIME
*/
* 创建时间
*/
private
java
.
util
.
Date
createdTime
;
private
java
.
util
.
Date
createdTime
;
@Column
(
name
=
"CREATED_TIME"
,
length
=
19
)
@Column
(
name
=
"CREATED_TIME"
,
length
=
19
)
public
java
.
util
.
Date
getCreatedTime
(){
public
java
.
util
.
Date
getCreatedTime
()
{
return
this
.
createdTime
;
return
this
.
createdTime
;
}
}
public
void
setCreatedTime
(
java
.
util
.
Date
createdTime
){
public
void
setCreatedTime
(
java
.
util
.
Date
createdTime
)
{
this
.
createdTime
=
createdTime
;
this
.
createdTime
=
createdTime
;
super
.
addValidField
(
"createdTime"
);
super
.
addValidField
(
"createdTime"
);
}
}
/** MODIFIER
/**
*修改人
* MODIFIER
*/
* 修改人
*/
private
java
.
lang
.
String
modifier
;
private
java
.
lang
.
String
modifier
;
@Column
(
name
=
"MODIFIER"
,
length
=
225
)
@Column
(
name
=
"MODIFIER"
,
length
=
225
)
public
java
.
lang
.
String
getModifier
(){
public
java
.
lang
.
String
getModifier
()
{
return
this
.
modifier
;
return
this
.
modifier
;
}
}
public
void
setModifier
(
java
.
lang
.
String
modifier
){
public
void
setModifier
(
java
.
lang
.
String
modifier
)
{
this
.
modifier
=
modifier
;
this
.
modifier
=
modifier
;
super
.
addValidField
(
"modifier"
);
super
.
addValidField
(
"modifier"
);
}
}
/** MODIFIED_TIME
/**
*修改时间
* MODIFIED_TIME
*/
* 修改时间
*/
private
java
.
util
.
Date
modifiedTime
;
private
java
.
util
.
Date
modifiedTime
;
@Column
(
name
=
"MODIFIED_TIME"
,
length
=
19
)
@Column
(
name
=
"MODIFIED_TIME"
,
length
=
19
)
public
java
.
util
.
Date
getModifiedTime
(){
public
java
.
util
.
Date
getModifiedTime
()
{
return
this
.
modifiedTime
;
return
this
.
modifiedTime
;
}
}
public
void
setModifiedTime
(
java
.
util
.
Date
modifiedTime
){
public
void
setModifiedTime
(
java
.
util
.
Date
modifiedTime
)
{
this
.
modifiedTime
=
modifiedTime
;
this
.
modifiedTime
=
modifiedTime
;
super
.
addValidField
(
"modifiedTime"
);
super
.
addValidField
(
"modifiedTime"
);
}
}
/** SYS_VERSION
/**
*乐观锁,版本号
* SYS_VERSION
*/
* 乐观锁,版本号
*/
private
java
.
lang
.
Integer
sysVersion
;
private
java
.
lang
.
Integer
sysVersion
;
@Column
(
name
=
"SYS_VERSION"
,
length
=
10
)
@Column
(
name
=
"SYS_VERSION"
,
length
=
10
)
@Version
@Version
public
java
.
lang
.
Integer
getSysVersion
(){
public
java
.
lang
.
Integer
getSysVersion
()
{
return
this
.
sysVersion
;
return
this
.
sysVersion
;
}
}
public
void
setSysVersion
(
java
.
lang
.
Integer
sysVersion
){
public
void
setSysVersion
(
java
.
lang
.
Integer
sysVersion
)
{
this
.
sysVersion
=
sysVersion
;
this
.
sysVersion
=
sysVersion
;
super
.
addValidField
(
"sysVersion"
);
super
.
addValidField
(
"sysVersion"
);
}
}
}
}
\ No newline at end of file
src/main/java/cn/com/poc/agent_application/query/AgentApplicationInfoQuery.sql
View file @
cbfb29ad
...
@@ -21,6 +21,8 @@ select distinct
...
@@ -21,6 +21,8 @@ select distinct
unit_ids
,
unit_ids
,
variable_structure
,
variable_structure
,
is_long_memory
,
is_long_memory
,
is_document_parsing
,
voice_config
,
is_deleted
,
is_deleted
,
CREATOR
,
CREATOR
,
CREATED_TIME
,
CREATED_TIME
,
...
...
src/main/java/cn/com/poc/agent_application/query/AgentApplicationInfoQueryItem.java
View file @
cbfb29ad
...
@@ -285,18 +285,18 @@ public class AgentApplicationInfoQueryItem extends BaseItemClass implements Seri
...
@@ -285,18 +285,18 @@ public class AgentApplicationInfoQueryItem extends BaseItemClass implements Seri
}
}
/**
/*
* temperature
* temperature
*对话模型 温度 [0-1.00]
*
对话模型 温度 [0-1.00]
*/
*/
private
java
.
lang
.
Float
temperature
;
private
java
.
lang
.
Float
temperature
;
@Column
(
name
=
"temperature"
)
@Column
(
name
=
"temperature"
)
public
java
.
lang
.
Float
getTemperature
(){
public
java
.
lang
.
Float
getTemperature
()
{
return
this
.
temperature
;
return
this
.
temperature
;
}
}
public
void
setTemperature
(
java
.
lang
.
Float
temperature
){
public
void
setTemperature
(
java
.
lang
.
Float
temperature
)
{
this
.
temperature
=
temperature
;
this
.
temperature
=
temperature
;
}
}
...
@@ -347,6 +347,36 @@ public class AgentApplicationInfoQueryItem extends BaseItemClass implements Seri
...
@@ -347,6 +347,36 @@ public class AgentApplicationInfoQueryItem extends BaseItemClass implements Seri
this
.
isLongMemory
=
isLongMemory
;
this
.
isLongMemory
=
isLongMemory
;
}
}
/**
* is_document_parsing
* 是否开启文档解析 1、Y 是 2、N 否
*/
private
java
.
lang
.
String
isDocumentParsing
;
@Column
(
name
=
"is_document_parsing"
,
length
=
1
)
public
java
.
lang
.
String
getIsDocumentParsing
()
{
return
this
.
isDocumentParsing
;
}
public
void
setIsDocumentParsing
(
java
.
lang
.
String
isDocumentParsing
)
{
this
.
isDocumentParsing
=
isDocumentParsing
;
}
/**
* voice_config
*/
private
java
.
lang
.
String
voiceConfig
;
@Column
(
name
=
"voice_config"
)
public
java
.
lang
.
String
getVoiceConfig
()
{
return
this
.
voiceConfig
;
}
public
void
setVoiceConfig
(
java
.
lang
.
String
voiceConfig
)
{
this
.
voiceConfig
=
voiceConfig
;
}
/**
/**
* is_deleted
* is_deleted
* is_deleted
* is_deleted
...
...
src/main/java/cn/com/poc/agent_application/rest/BizAgentApplicationPublishRest.java
View file @
cbfb29ad
...
@@ -18,8 +18,6 @@ public interface BizAgentApplicationPublishRest extends BaseRest {
...
@@ -18,8 +18,6 @@ public interface BizAgentApplicationPublishRest extends BaseRest {
BizAgentApplicationPublishDto
save
(
@RequestBody
BizAgentApplicationPublishDto
dto
)
throws
Exception
;
BizAgentApplicationPublishDto
save
(
@RequestBody
BizAgentApplicationPublishDto
dto
)
throws
Exception
;
BizAgentApplicationPublishDto
update
(
@RequestBody
BizAgentApplicationPublishDto
dto
)
throws
Exception
;
void
deletedById
(
@RequestParam
java
.
lang
.
Integer
id
)
throws
Exception
;
void
deletedById
(
@RequestParam
java
.
lang
.
Integer
id
)
throws
Exception
;
}
}
\ No newline at end of file
src/main/java/cn/com/poc/agent_application/rest/impl/AgentApplicationInfoRestImpl.java
View file @
cbfb29ad
...
@@ -7,22 +7,21 @@ import cn.com.poc.agent_application.entity.*;
...
@@ -7,22 +7,21 @@ import cn.com.poc.agent_application.entity.*;
import
cn.com.poc.agent_application.query.AgentApplicationInfoQueryCondition
;
import
cn.com.poc.agent_application.query.AgentApplicationInfoQueryCondition
;
import
cn.com.poc.agent_application.rest.AgentApplicationInfoRest
;
import
cn.com.poc.agent_application.rest.AgentApplicationInfoRest
;
import
cn.com.poc.agent_application.service.*
;
import
cn.com.poc.agent_application.service.*
;
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.service.RedisService
;
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.common.utils.
DocumentLoad
;
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.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.SetLongMemoryConstants
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.long_memory.LongMemory
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.value_memory.GetValueMemory
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.memory_variable_writer.MemoryVariableWriter
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.value_memory.SetValueMemoryConstants
;
import
cn.com.yict.framemax.core.i18n.I18nMessageException
;
import
cn.com.yict.framemax.core.i18n.I18nMessageException
;
import
cn.com.yict.framemax.data.model.PagingInfo
;
import
cn.com.yict.framemax.data.model.PagingInfo
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.collection.ListUtil
;
import
cn.hutool.core.collection.ListUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.MapUtils
;
import
org.apache.commons.collections4.MapUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
@@ -31,9 +30,13 @@ import org.springframework.util.Assert;
...
@@ -31,9 +30,13 @@ import org.springframework.util.Assert;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.PrintWriter
;
import
java.io.PrintWriter
;
import
java.util.*
;
import
java.util.ArrayList
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
@Component
@Component
...
@@ -54,9 +57,6 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
...
@@ -54,9 +57,6 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
@Resource
@Resource
private
KnowledgeService
knowledgeService
;
private
KnowledgeService
knowledgeService
;
@Resource
private
RedisService
redisService
;
@Resource
@Resource
private
BizMemberAgentApplicationCollectService
bizMemberAgentApplicationCollectService
;
private
BizMemberAgentApplicationCollectService
bizMemberAgentApplicationCollectService
;
...
@@ -206,44 +206,20 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
...
@@ -206,44 +206,20 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
Assert
.
notEmpty
(
dto
.
getMessages
());
Assert
.
notEmpty
(
dto
.
getMessages
());
try
{
try
{
String
agentId
=
dto
.
getAgentId
();
String
agentId
=
dto
.
getAgentId
();
String
dialogueId
=
dto
.
getAgentId
();
List
<
String
>
fileUrls
=
dto
.
getFileUrls
();
BizAgentApplicationInfoEntity
infoEntity
=
bizAgentApplicationInfoService
.
getByAgentId
(
agentId
);
BizAgentApplicationInfoEntity
infoEntity
=
bizAgentApplicationInfoService
.
getByAgentId
(
agentId
);
if
(
infoEntity
==
null
)
{
if
(
infoEntity
==
null
)
{
throw
new
I18nMessageException
(
"exception/application.does.not.exist"
);
throw
new
I18nMessageException
(
"exception/application.does.not.exist"
);
}
}
// 判断文件是否为空,如果不为空
AgentApplicationTools
.
checkDialogueContentIsEmpty
(
fileUrls
);
//获取知识库配置
//获取知识库配置
List
<
Integer
>
kdIds
=
knowledgeService
.
getKdIdsByKnowledgeInfoIds
(
infoEntity
.
getKnowledgeIds
());
List
<
Integer
>
kdIds
=
knowledgeService
.
getKdIdsByKnowledgeInfoIds
(
infoEntity
.
getKnowledgeIds
());
//配置对话function
//配置对话function
List
<
Tool
>
tools
=
new
ArrayList
<>();
List
<
Tool
>
tools
=
AgentApplicationTools
.
buildFunctionConfig
(
infoEntity
.
getVariableStructure
(),
infoEntity
.
getIsLongMemory
(),
dialogueId
,
agentId
,
infoEntity
.
getUnitIds
(),
infoEntity
.
getIsDocumentParsing
());
//开启对话变量
if
(
CollectionUtils
.
isNotEmpty
(
infoEntity
.
getVariableStructure
()))
{
String
functionName
=
LargeModelFunctionEnum
.
set_value_memory
.
name
();
String
llmConfig
=
LargeModelFunctionEnum
.
valueOf
(
functionName
).
getFunction
().
getVariableStructureLLMConfig
(
infoEntity
.
getVariableStructure
()).
get
(
0
);
Tool
tool
=
JsonUtils
.
deSerialize
(
llmConfig
,
Tool
.
class
);
tools
.
add
(
tool
);
//初始化变量函数
Map
<
Object
,
Object
>
map
=
GetValueMemory
.
get
(
agentId
);
List
<
Variable
>
variableStructure
=
infoEntity
.
getVariableStructure
();
if
(
MapUtils
.
isEmpty
(
map
))
{
for
(
Variable
variable
:
variableStructure
)
{
String
key
=
variable
.
getKey
();
String
variableDefault
=
variable
.
getVariableDefault
();
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"contentName"
,
key
);
jsonObject
.
put
(
"contentValue"
,
variableDefault
);
LargeModelFunctionEnum
.
valueOf
(
functionName
).
getFunction
().
doFunction
(
jsonObject
.
toJSONString
(),
agentId
);
}
}
}
//开启长期记忆
if
(
CommonConstant
.
YOrN
.
Y
.
equals
(
infoEntity
.
getIsLongMemory
()))
{
String
functionName
=
LargeModelFunctionEnum
.
set_long_memory
.
name
();
String
llmConfig
=
LargeModelFunctionEnum
.
valueOf
(
functionName
).
getFunction
().
getLLMConfig
().
get
(
0
);
Tool
tool
=
JsonUtils
.
deSerialize
(
llmConfig
,
Tool
.
class
);
tools
.
add
(
tool
);
}
//对话大模型配置
//对话大模型配置
String
model
=
StringUtils
.
isNotBlank
(
dto
.
getModelNickName
())
?
dto
.
getModelNickName
()
:
infoEntity
.
getLargeModel
();
String
model
=
StringUtils
.
isNotBlank
(
dto
.
getModelNickName
())
?
dto
.
getModelNickName
()
:
infoEntity
.
getLargeModel
();
...
@@ -252,11 +228,10 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
...
@@ -252,11 +228,10 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
String
agentSystem
=
StringUtils
.
isBlank
(
dto
.
getAgentSystem
())
?
infoEntity
.
getAgentSystem
()
:
dto
.
getAgentSystem
();
String
agentSystem
=
StringUtils
.
isBlank
(
dto
.
getAgentSystem
())
?
infoEntity
.
getAgentSystem
()
:
dto
.
getAgentSystem
();
//调用应用服务
//调用应用服务
agentApplicationInfoService
.
callAgentApplication
(
agentId
,
model
,
infoEntity
.
getUnitIds
()
agentApplicationInfoService
.
callAgentApplication
(
agentId
,
dialogueId
,
model
,
,
agentSystem
,
kdIds
.
toArray
(
new
Integer
[
0
]),
infoEntity
.
getCommunicationTurn
(),
topP
,
temperature
agentSystem
,
kdIds
.
toArray
(
new
Integer
[
0
]),
infoEntity
.
getCommunicationTurn
(),
topP
,
,
dto
.
getMessages
(),
tools
,
httpServletResponse
);
temperature
,
dto
.
getMessages
(),
tools
,
dto
.
getFileUrls
(),
httpServletResponse
);
}
catch
(
}
catch
(
Exception
e
)
{
Exception
e
)
{
httpServletResponse
.
setContentType
(
"text/event-stream"
);
httpServletResponse
.
setContentType
(
"text/event-stream"
);
PrintWriter
writer
=
httpServletResponse
.
getWriter
();
PrintWriter
writer
=
httpServletResponse
.
getWriter
();
writer
.
write
(
"data: {\"code\":-1,\"message\":\""
+
e
.
getLocalizedMessage
()
+
"\"} \n\n"
);
writer
.
write
(
"data: {\"code\":-1,\"message\":\""
+
e
.
getLocalizedMessage
()
+
"\"} \n\n"
);
...
@@ -344,11 +319,11 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
...
@@ -344,11 +319,11 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
@Override
@Override
public
List
<
AgentApplicationValueMemoryDto
>
getVariableList
(
String
agentId
)
{
public
List
<
AgentApplicationValueMemoryDto
>
getVariableList
(
String
agentId
)
{
Map
<
Object
,
Object
>
map
=
GetValueMemory
.
get
(
agentId
);
List
<
AgentApplicationValueMemoryDto
>
result
=
new
ArrayList
<>();
List
<
AgentApplicationValueMemoryDto
>
result
=
new
ArrayList
<>();
BizAgentApplicationInfoEntity
infoEntity
=
bizAgentApplicationInfoService
.
getByAgentId
(
agentId
);
Map
<
Object
,
Object
>
map
=
MemoryVariableWriter
.
get
(
agentId
+
":"
+
agentId
);
List
<
Variable
>
variableStructure
=
infoEntity
.
getVariableStructure
();
if
(
MapUtils
.
isEmpty
(
map
))
{
if
(
MapUtils
.
isEmpty
(
map
))
{
BizAgentApplicationInfoEntity
infoEntity
=
bizAgentApplicationInfoService
.
getByAgentId
(
agentId
);
List
<
Variable
>
variableStructure
=
infoEntity
.
getVariableStructure
();
if
(
CollectionUtils
.
isEmpty
(
variableStructure
))
{
if
(
CollectionUtils
.
isEmpty
(
variableStructure
))
{
return
result
;
return
result
;
}
}
...
@@ -359,11 +334,10 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
...
@@ -359,11 +334,10 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
result
.
add
(
valueMemoryDto
);
result
.
add
(
valueMemoryDto
);
}
}
}
else
{
}
else
{
Set
<
Object
>
keySet
=
map
.
keySet
();
for
(
Variable
variable
:
variableStructure
)
{
for
(
Object
key
:
keySet
)
{
AgentApplicationValueMemoryDto
valueMemoryDto
=
new
AgentApplicationValueMemoryDto
();
AgentApplicationValueMemoryDto
valueMemoryDto
=
new
AgentApplicationValueMemoryDto
();
valueMemoryDto
.
setKey
(
key
.
toString
());
valueMemoryDto
.
setKey
(
variable
.
getKey
());
valueMemoryDto
.
setValue
(
map
.
get
(
key
).
toString
());
valueMemoryDto
.
setValue
(
map
.
containsKey
(
variable
.
getKey
())
?
map
.
get
(
variable
.
getKey
()).
toString
()
:
variable
.
getVariableDefault
());
result
.
add
(
valueMemoryDto
);
result
.
add
(
valueMemoryDto
);
}
}
}
}
...
@@ -373,32 +347,24 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
...
@@ -373,32 +347,24 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
@Override
@Override
public
List
<
AgentLongMemoryDto
>
getLongMemoryList
(
String
agentId
)
{
public
List
<
AgentLongMemoryDto
>
getLongMemoryList
(
String
agentId
)
{
Assert
.
notNull
(
agentId
);
Assert
.
notNull
(
agentId
);
List
<
AgentLongMemoryDto
>
result
=
new
ArrayList
<>();
List
<
AgentLongMemoryEntity
>
longMemoryEntities
=
LongMemory
.
get
(
AgentApplicationTools
.
identifier
(
agentId
,
agentId
));
String
contentKey
=
SetLongMemoryConstants
.
REDIS_PREFIX
+
agentId
+
":"
+
BlContext
.
getCurrentUserNotException
().
getUserId
().
toString
();
return
longMemoryEntities
.
stream
().
map
(
value
->
{
Map
<
Object
,
Object
>
map
=
redisService
.
hmget
(
contentKey
);
AgentLongMemoryDto
agentLongMemoryDto
=
new
AgentLongMemoryDto
();
Set
<
Object
>
keySet
=
map
.
keySet
();
BeanUtil
.
copyProperties
(
value
,
agentLongMemoryDto
);
return
agentLongMemoryDto
;
for
(
Object
mapKey
:
keySet
)
{
}).
sorted
(
Comparator
.
comparing
(
AgentLongMemoryDto:
:
getTimestamp
).
reversed
()).
collect
(
Collectors
.
toList
());
AgentLongMemoryDto
entity
=
new
AgentLongMemoryDto
();
entity
.
setContent
(
map
.
get
(
mapKey
).
toString
());
entity
.
setTimestamp
(
mapKey
.
toString
());
result
.
add
(
entity
);
}
return
result
.
stream
().
sorted
(
Comparator
.
comparing
(
AgentLongMemoryDto:
:
getTimestamp
).
reversed
()).
collect
(
Collectors
.
toList
());
}
}
@Override
@Override
public
void
deleteLongMemoryByKey
(
String
agentId
,
String
timestamp
)
{
public
void
deleteLongMemoryByKey
(
String
agentId
,
String
timestamp
)
{
Assert
.
notNull
(
agentId
);
Assert
.
notNull
(
agentId
);
Assert
.
notNull
(
timestamp
);
Assert
.
notNull
(
timestamp
);
String
contentKey
=
SetLongMemoryConstants
.
REDIS_PREFIX
+
agentId
+
":"
+
BlContext
.
getCurrentUserNotException
().
getUserId
().
toString
();
LongMemory
.
delByKey
(
agentId
,
timestamp
);
redisService
.
hdel
(
contentKey
,
timestamp
);
}
}
@Override
@Override
public
void
deleteLongMemory
(
String
agentId
)
{
public
void
deleteLongMemory
(
String
agentId
)
{
Assert
.
notNull
(
agentId
);
Assert
.
notNull
(
agentId
);
String
contentKey
=
SetLongMemoryConstants
.
REDIS_PREFIX
+
agentId
+
":"
+
BlContext
.
getCurrentUserNotException
().
getUserId
().
toString
();
LongMemory
.
clean
(
agentId
);
redisService
.
del
(
contentKey
);
}
}
}
}
\ No newline at end of file
src/main/java/cn/com/poc/agent_application/rest/impl/BizAgentApplicationPublishRestImpl.java
View file @
cbfb29ad
...
@@ -38,12 +38,6 @@ public class BizAgentApplicationPublishRestImpl implements BizAgentApplicationPu
...
@@ -38,12 +38,6 @@ public class BizAgentApplicationPublishRestImpl implements BizAgentApplicationPu
return
BizAgentApplicationPublishConvert
.
entityToDto
(
bizAgentApplicationPublishService
.
save
(
entity
));
return
BizAgentApplicationPublishConvert
.
entityToDto
(
bizAgentApplicationPublishService
.
save
(
entity
));
}
}
public
BizAgentApplicationPublishDto
update
(
BizAgentApplicationPublishDto
dto
)
throws
Exception
{
Assert
.
notNull
(
dto
);
BizAgentApplicationPublishEntity
entity
=
BizAgentApplicationPublishConvert
.
dtoToEntity
(
dto
);
return
BizAgentApplicationPublishConvert
.
entityToDto
(
bizAgentApplicationPublishService
.
update
(
entity
));
}
public
void
deletedById
(
java
.
lang
.
Integer
id
)
throws
Exception
{
public
void
deletedById
(
java
.
lang
.
Integer
id
)
throws
Exception
{
Assert
.
notNull
(
id
);
Assert
.
notNull
(
id
);
bizAgentApplicationPublishService
.
deletedById
(
id
);
bizAgentApplicationPublishService
.
deletedById
(
id
);
...
...
src/main/java/cn/com/poc/agent_application/schedule/AgentApplicationMallSchedule.java
View file @
cbfb29ad
...
@@ -37,7 +37,7 @@ public class AgentApplicationMallSchedule {
...
@@ -37,7 +37,7 @@ public class AgentApplicationMallSchedule {
* 【用于更新DB的应用热度】
* 【用于更新DB的应用热度】
* 定时规则:每分钟触发一次
* 定时规则:每分钟触发一次
*/
*/
@Scheduled
(
cron
=
"0
*
* * * ?"
)
@Scheduled
(
cron
=
"0
0/5
* * * ?"
)
public
void
updateAgentPopularity
()
throws
Exception
{
public
void
updateAgentPopularity
()
throws
Exception
{
// 查询应用市场表
// 查询应用市场表
List
<
BizAgentApplicationMallEntity
>
mallEntities
=
bizAgentApplicationMallService
.
getList
();
List
<
BizAgentApplicationMallEntity
>
mallEntities
=
bizAgentApplicationMallService
.
getList
();
...
...
src/main/java/cn/com/poc/agent_application/service/BizAgentApplicationPublishService.java
View file @
cbfb29ad
...
@@ -12,7 +12,7 @@ public interface BizAgentApplicationPublishService extends BaseService {
...
@@ -12,7 +12,7 @@ public interface BizAgentApplicationPublishService extends BaseService {
BizAgentApplicationPublishEntity
get
(
java
.
lang
.
Integer
id
)
throws
Exception
;
BizAgentApplicationPublishEntity
get
(
java
.
lang
.
Integer
id
)
throws
Exception
;
BizAgentApplicationPublishEntity
getByAgentId
(
String
agentId
)
throws
Exception
;
BizAgentApplicationPublishEntity
getByAgentId
(
String
agentId
);
List
<
BizAgentApplicationPublishEntity
>
findByExample
(
BizAgentApplicationPublishEntity
example
,
PagingInfo
pagingInfo
)
throws
Exception
;
List
<
BizAgentApplicationPublishEntity
>
findByExample
(
BizAgentApplicationPublishEntity
example
,
PagingInfo
pagingInfo
)
throws
Exception
;
...
...
src/main/java/cn/com/poc/agent_application/service/impl/BizAgentApplicationInfoServiceImpl.java
View file @
cbfb29ad
...
@@ -213,7 +213,15 @@ public class BizAgentApplicationInfoServiceImpl extends BaseServiceImpl
...
@@ -213,7 +213,15 @@ public class BizAgentApplicationInfoServiceImpl extends BaseServiceImpl
if
(
entity
.
getTemperature
()
!=
null
)
{
if
(
entity
.
getTemperature
()
!=
null
)
{
Assert
.
isTrue
(
entity
.
getTemperature
()
>
0
&&
entity
.
getTemperature
()
<=
1.0
,
"temperature is error,must greater than 0, less than or equal to 1.9"
);
Assert
.
isTrue
(
entity
.
getTemperature
()
>
0
&&
entity
.
getTemperature
()
<=
1.0
,
"temperature is error,must greater than 0, less than or equal to 1.9"
);
}
}
model
.
setIsLongMemory
(
entity
.
getIsLongMemory
());
if
(
entity
.
getVoiceConfig
()
!=
null
)
{
model
.
setVoiceConfig
(
JsonUtils
.
serialize
(
entity
.
getVoiceConfig
()));
}
if
(
StringUtils
.
isNotBlank
(
entity
.
getIsDocumentParsing
()))
{
model
.
setIsDocumentParsing
(
entity
.
getIsDocumentParsing
());
}
if
(
StringUtils
.
isNotBlank
(
entity
.
getIsLongMemory
()))
{
model
.
setIsLongMemory
(
entity
.
getIsLongMemory
());
}
model
.
setTemperature
(
entity
.
getTemperature
());
model
.
setTemperature
(
entity
.
getTemperature
());
model
.
setTopP
(
entity
.
getTopP
());
model
.
setTopP
(
entity
.
getTopP
());
model
.
setContinuousQuestionStatus
(
entity
.
getContinuousQuestionStatus
());
model
.
setContinuousQuestionStatus
(
entity
.
getContinuousQuestionStatus
());
...
...
src/main/java/cn/com/poc/agent_application/service/impl/BizAgentApplicationPublishServiceImpl.java
View file @
cbfb29ad
...
@@ -50,7 +50,7 @@ public class BizAgentApplicationPublishServiceImpl extends BaseServiceImpl
...
@@ -50,7 +50,7 @@ public class BizAgentApplicationPublishServiceImpl extends BaseServiceImpl
}
}
@Override
@Override
public
BizAgentApplicationPublishEntity
getByAgentId
(
String
agentId
)
throws
Exception
{
public
BizAgentApplicationPublishEntity
getByAgentId
(
String
agentId
)
{
Assert
.
notNull
(
agentId
);
Assert
.
notNull
(
agentId
);
BizAgentApplicationPublishModel
model
=
new
BizAgentApplicationPublishModel
();
BizAgentApplicationPublishModel
model
=
new
BizAgentApplicationPublishModel
();
model
.
setAgentId
(
agentId
);
model
.
setAgentId
(
agentId
);
...
@@ -89,15 +89,17 @@ public class BizAgentApplicationPublishServiceImpl extends BaseServiceImpl
...
@@ -89,15 +89,17 @@ public class BizAgentApplicationPublishServiceImpl extends BaseServiceImpl
Assert
.
notNull
(
entity
);
Assert
.
notNull
(
entity
);
Assert
.
notNull
(
entity
.
getId
(),
"update pk can not be null"
);
Assert
.
notNull
(
entity
.
getId
(),
"update pk can not be null"
);
BizAgentApplicationPublishModel
model
=
this
.
repository
.
get
(
entity
.
getId
());
BizAgentApplicationPublishModel
model
=
this
.
repository
.
get
(
entity
.
getId
());
model
.
setAgentId
(
entity
.
getAgentId
());
if
(
model
==
null
)
{
model
.
setIsDeleted
(
CommonConstant
.
IsDeleted
.
N
);
throw
new
I18nMessageException
(
"exception/publication.failed"
);
List
<
BizAgentApplicationPublishModel
>
models
=
this
.
repository
.
findByExample
(
model
);
}
if
(
CollectionUtils
.
isEmpty
(
models
))
{
BizAgentApplicationPublishModel
updateModel
=
BizAgentApplicationPublishConvert
.
entityToModel
(
entity
);
throw
new
I18nMessageException
(
"exception/data.does.not.exist"
);
updateModel
.
setIsDeleted
(
CommonConstant
.
IsDeleted
.
N
);
}
updateModel
.
setCreator
(
model
.
getCreator
());
model
=
models
.
get
(
0
);
updateModel
.
setCreatedTime
(
model
.
getCreatedTime
());
paramVerificationAndConvert
(
entity
,
model
);
updateModel
.
setModifier
(
null
);
BizAgentApplicationPublishModel
saveModel
=
this
.
repository
.
save
(
model
);
updateModel
.
setModifiedTime
(
null
);
updateModel
.
setSysVersion
(
model
.
getSysVersion
());
BizAgentApplicationPublishModel
saveModel
=
this
.
repository
.
save
(
updateModel
);
return
BizAgentApplicationPublishConvert
.
modelToEntity
(
saveModel
);
return
BizAgentApplicationPublishConvert
.
modelToEntity
(
saveModel
);
}
}
...
@@ -186,5 +188,6 @@ public class BizAgentApplicationPublishServiceImpl extends BaseServiceImpl
...
@@ -186,5 +188,6 @@ public class BizAgentApplicationPublishServiceImpl extends BaseServiceImpl
if
(
ArrayUtils
.
isNotEmpty
(
entity
.
getUnitIds
()))
{
if
(
ArrayUtils
.
isNotEmpty
(
entity
.
getUnitIds
()))
{
model
.
setUnitIds
(
JsonUtils
.
serialize
(
entity
.
getUnitIds
()));
model
.
setUnitIds
(
JsonUtils
.
serialize
(
entity
.
getUnitIds
()));
}
}
model
.
setIsDocumentParsing
(
entity
.
getIsDocumentParsing
());
}
}
}
}
\ No newline at end of file
src/main/java/cn/com/poc/agent_application/utils/AgentApplicationTools.java
0 → 100644
View file @
cbfb29ad
package
cn
.
com
.
poc
.
agent_application
.
utils
;
import
cn.com.poc.agent_application.entity.Variable
;
import
cn.com.poc.common.constant.CommonConstant
;
import
cn.com.poc.common.utils.DocumentLoad
;
import
cn.com.poc.common.utils.JsonUtils
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.dialogue.Tool
;
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.yict.framemax.core.i18n.I18nMessageException
;
import
com.alibaba.fastjson.JSONObject
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.MapUtils
;
import
org.apache.commons.lang.ArrayUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author alex.yao
* @description agent应用配置工具类
*/
public
class
AgentApplicationTools
{
/**
* 构造Agent应用 函数配置
*
* @param variableStructures 记忆变量
* @param isLongMemory 是否开启长期记忆
* @param identifier 标识符
* @param agentId 应用id
* @param unitIds 插件id
* @param isDocumentParsing 是否开启文档解析
* @return
*/
public
static
List
<
Tool
>
buildFunctionConfig
(
List
<
Variable
>
variableStructures
,
String
isLongMemory
,
String
identifier
,
String
agentId
,
String
[]
unitIds
,
String
isDocumentParsing
)
{
List
<
Tool
>
tools
=
new
ArrayList
<>();
//开启对话变量
if
(
CollectionUtils
.
isNotEmpty
(
variableStructures
))
{
String
functionName
=
LargeModelFunctionEnum
.
memory_variable_writer
.
name
();
String
llmConfig
=
LargeModelFunctionEnum
.
valueOf
(
functionName
).
getFunction
().
getLLMConfig
(
variableStructures
).
get
(
0
);
Tool
tool
=
JsonUtils
.
deSerialize
(
llmConfig
,
Tool
.
class
);
tools
.
add
(
tool
);
//初始化变量函数
Map
<
Object
,
Object
>
map
=
MemoryVariableWriter
.
get
(
identifier
(
identifier
,
agentId
));
if
(
MapUtils
.
isEmpty
(
map
))
{
List
<
Variable
>
variableStructure
=
variableStructures
;
for
(
Variable
variable
:
variableStructure
)
{
String
key
=
variable
.
getKey
();
String
variableDefault
=
variable
.
getVariableDefault
();
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"key"
,
key
);
jsonObject
.
put
(
"value"
,
variableDefault
);
LargeModelFunctionEnum
.
valueOf
(
functionName
).
getFunction
().
doFunction
(
jsonObject
.
toJSONString
(),
identifier
(
identifier
,
agentId
));
}
}
}
//开启长期记忆
if
(
CommonConstant
.
YOrN
.
Y
.
equals
(
isLongMemory
))
{
String
functionName
=
LargeModelFunctionEnum
.
set_long_memory
.
name
();
String
llmConfig
=
LargeModelFunctionEnum
.
valueOf
(
functionName
).
getFunction
().
getLLMConfig
().
get
(
0
);
Tool
tool
=
JsonUtils
.
deSerialize
(
llmConfig
,
Tool
.
class
);
tools
.
add
(
tool
);
}
//开启文档解析-文档理解
if
(
CommonConstant
.
YOrN
.
Y
.
equals
(
isDocumentParsing
))
{
String
functionName
=
LargeModelFunctionEnum
.
document_understanding
.
name
();
String
llmConfig
=
LargeModelFunctionEnum
.
valueOf
(
functionName
).
getFunction
().
getLLMConfig
().
get
(
0
);
Tool
tool
=
JsonUtils
.
deSerialize
(
llmConfig
,
Tool
.
class
);
tools
.
add
(
tool
);
}
//初始化插件函数
if
(
ArrayUtils
.
isNotEmpty
(
unitIds
))
{
for
(
String
unitId
:
unitIds
)
{
LargeModelFunctionEnum
modelFunctionEnum
=
LargeModelFunctionEnum
.
getFunction
(
unitId
);
if
(
modelFunctionEnum
==
null
)
{
continue
;
}
String
llmConfig
=
modelFunctionEnum
.
getFunction
().
getLLMConfig
().
get
(
0
);
Tool
tool
=
JsonUtils
.
deSerialize
(
llmConfig
,
Tool
.
class
);
tools
.
add
(
tool
);
}
}
return
tools
;
}
/**
* 创建会话唯一标识符
*
* @param dialogueId 对话ID
* @param agentId 应用ID
* @return
*/
public
static
String
identifier
(
String
dialogueId
,
String
agentId
)
{
return
dialogueId
+
":"
+
agentId
;
}
/**
* 检查对话文件内容是否为空
*
* @throws I18nMessageException 文件内容为空时抛出异常
*/
public
static
void
checkDialogueContentIsEmpty
(
List
<
String
>
fileUrls
)
{
// 判断文件是否为空,如果不为空
if
(
CollectionUtils
.
isNotEmpty
(
fileUrls
))
{
for
(
String
fileUrl
:
fileUrls
)
{
File
file
=
DocumentLoad
.
downloadURLDocument
(
fileUrl
);
String
documentContent
=
DocumentLoad
.
documentToText
(
file
);
if
(
StringUtils
.
isBlank
(
documentContent
))
{
throw
new
I18nMessageException
(
"exception/file.content.empty"
);
}
}
}
}
}
src/main/java/cn/com/poc/common/annotation/RedisLimit.java
View file @
cbfb29ad
...
@@ -7,7 +7,7 @@ import java.lang.annotation.*;
...
@@ -7,7 +7,7 @@ import java.lang.annotation.*;
/**
/**
* 限流
* 限流
*/
*/
@Target
(
ElementType
.
METHOD
)
@Target
(
{
ElementType
.
METHOD
,
ElementType
.
TYPE
}
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Component
@Component
@Documented
@Documented
...
@@ -77,7 +77,8 @@ public @interface RedisLimit {
...
@@ -77,7 +77,8 @@ public @interface RedisLimit {
*/
*/
MONTH_OF_YEAR
;
MONTH_OF_YEAR
;
LimitTimeUnit
(){}
LimitTimeUnit
()
{
}
}
}
}
}
src/main/java/cn/com/poc/common/utils/DocumentLoad.java
View file @
cbfb29ad
...
@@ -2,6 +2,7 @@ package cn.com.poc.common.utils;
...
@@ -2,6 +2,7 @@ package cn.com.poc.common.utils;
import
cn.com.yict.framemax.core.i18n.I18nMessageException
;
import
cn.com.yict.framemax.core.i18n.I18nMessageException
;
import
cn.hutool.core.io.FileUtil
;
import
cn.hutool.core.io.FileUtil
;
import
io.github.furstenheim.*
;
import
org.apache.pdfbox.io.RandomAccessBufferedFileInputStream
;
import
org.apache.pdfbox.io.RandomAccessBufferedFileInputStream
;
import
org.apache.pdfbox.pdfparser.PDFParser
;
import
org.apache.pdfbox.pdfparser.PDFParser
;
import
org.apache.pdfbox.pdmodel.PDDocument
;
import
org.apache.pdfbox.pdmodel.PDDocument
;
...
@@ -12,10 +13,48 @@ import org.apache.poi.xwpf.usermodel.XWPFDocument;
...
@@ -12,10 +13,48 @@ import org.apache.poi.xwpf.usermodel.XWPFDocument;
import
org.springframework.util.Assert
;
import
org.springframework.util.Assert
;
import
java.io.*
;
import
java.io.*
;
import
java.net.URL
;
import
java.net.URLConnection
;
import
java.nio.file.Files
;
import
java.nio.file.Files
;
public
class
DocumentLoad
{
public
class
DocumentLoad
{
final
static
OptionsBuilder
optionsBuilder
=
OptionsBuilder
.
anOptions
();
final
static
Options
options
=
optionsBuilder
.
withBr
(
"-"
)
.
withLinkStyle
(
LinkStyle
.
REFERENCED
)
.
withLinkReferenceStyle
(
LinkReferenceStyle
.
SHORTCUT
)
.
build
();
final
static
CopyDown
converter
=
new
CopyDown
(
options
);
/**
* Html To Markdown
*/
public
static
String
htmlToMarkdown
(
String
url
)
{
try
{
// 创建 资源符对象 连接
URLConnection
conn
=
new
URL
(
url
).
openConnection
();
// 获取输入流
InputStream
inputStream
=
conn
.
getInputStream
();
// 缓冲区,读取输入流内容,64KB
char
[]
buffer
=
new
char
[
1024
*
64
];
int
len
;
StringBuilder
sb
=
new
StringBuilder
();
// 转换为字符流
InputStreamReader
isr
=
new
InputStreamReader
(
inputStream
);
// 循环读取
while
((
len
=
isr
.
read
(
buffer
))
!=
-
1
)
{
sb
.
append
(
buffer
,
0
,
len
);
}
// 关闭资源
inputStream
.
close
();
isr
.
close
();
String
htmlStr
=
sb
.
toString
();
return
converter
.
convert
(
htmlStr
);
}
catch
(
IOException
e
)
{
throw
new
I18nMessageException
(
e
.
getMessage
());
}
}
/**
/**
* 读取文档
* 读取文档
*
*
...
@@ -92,4 +131,31 @@ public class DocumentLoad {
...
@@ -92,4 +131,31 @@ public class DocumentLoad {
doc
.
close
();
doc
.
close
();
return
stringBuilder
.
toString
();
return
stringBuilder
.
toString
();
}
}
public
static
File
downloadURLDocument
(
String
path
)
{
// 下载网络文件
int
bytesum
=
0
;
int
byteread
=
0
;
try
{
URL
url
=
new
URL
(
path
);
URLConnection
conn
=
url
.
openConnection
();
String
[]
split
=
url
.
getFile
().
split
(
"\\."
);
String
suffix
=
split
[
split
.
length
-
1
];
File
tempFile
=
File
.
createTempFile
(
UUIDTool
.
getUUID
(),
"."
+
suffix
);
FileOutputStream
fs
=
new
FileOutputStream
(
tempFile
);
InputStream
inStream
=
conn
.
getInputStream
();
byte
[]
buffer
=
new
byte
[
1024
];
while
((
byteread
=
inStream
.
read
(
buffer
))
!=
-
1
)
{
bytesum
+=
byteread
;
fs
.
write
(
buffer
,
0
,
byteread
);
}
fs
.
close
();
return
tempFile
;
}
catch
(
IOException
e
)
{
throw
new
I18nMessageException
(
"exception/file.load.error"
);
}
}
}
}
src/main/java/cn/com/poc/common/utils/PcmToWav.java
0 → 100644
View file @
cbfb29ad
package
cn
.
com
.
poc
.
common
.
utils
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.nio.file.Path
;
public
class
PcmToWav
{
/**
* @param src 待转换文件路径
* @param target 目标文件路径
* @throws IOException 抛出异常
*/
public
static
Path
convertAudioFiles
(
String
src
)
throws
IOException
{
FileInputStream
fis
=
new
FileInputStream
(
src
);
File
tempAudioFile
=
File
.
createTempFile
(
UUIDTool
.
getUUID
(),
"wav"
);
FileOutputStream
fos
=
new
FileOutputStream
(
tempAudioFile
);
//计算长度
byte
[]
buf
=
new
byte
[
1024
*
4
];
int
size
=
fis
.
read
(
buf
);
int
PCMSize
=
0
;
while
(
size
!=
-
1
)
{
PCMSize
+=
size
;
size
=
fis
.
read
(
buf
);
}
fis
.
close
();
//填入参数,比特率等等。这里用的是16位单声道 8000 hz
WaveHeader
header
=
new
WaveHeader
();
//长度字段 = 内容的大小(PCMSize) + 头部字段的大小(不包括前面4字节的标识符RIFF以及fileLength本身的4字节)
header
.
fileLength
=
PCMSize
+
(
44
-
8
);
header
.
FmtHdrLeth
=
16
;
header
.
BitsPerSample
=
16
;
header
.
Channels
=
1
;
header
.
FormatTag
=
0x0001
;
header
.
SamplesPerSec
=
16000
;
header
.
BlockAlign
=
(
short
)
(
header
.
Channels
*
header
.
BitsPerSample
/
16
);
header
.
AvgBytesPerSec
=
header
.
BlockAlign
*
header
.
SamplesPerSec
;
header
.
DataHdrLeth
=
PCMSize
;
byte
[]
h
=
header
.
getHeader
();
assert
h
.
length
==
44
;
//WAV标准,头部应该是44字节
fos
.
write
(
h
,
0
,
h
.
length
);
fis
=
new
FileInputStream
(
src
);
size
=
fis
.
read
(
buf
);
while
(
size
!=
-
1
)
{
fos
.
write
(
buf
,
0
,
size
);
size
=
fis
.
read
(
buf
);
}
fis
.
close
();
fos
.
close
();
return
tempAudioFile
.
toPath
();
}
}
src/main/java/cn/com/poc/common/utils/SQLUtils.java
View file @
cbfb29ad
...
@@ -18,6 +18,14 @@ import java.util.stream.Collectors;
...
@@ -18,6 +18,14 @@ import java.util.stream.Collectors;
**/
**/
public
class
SQLUtils
{
public
class
SQLUtils
{
/**
* 获取批量插入sql和参数
*
* @param modelClass
* @param models
* @return
* @throws Exception
*/
public
static
BatchInsertResult
getInsertSql
(
Class
<?
extends
BaseModelClass
>
modelClass
,
List
<?
extends
BaseModelClass
>
models
)
throws
Exception
{
public
static
BatchInsertResult
getInsertSql
(
Class
<?
extends
BaseModelClass
>
modelClass
,
List
<?
extends
BaseModelClass
>
models
)
throws
Exception
{
//获取表名
//获取表名
Table
table
=
modelClass
.
getAnnotation
(
Table
.
class
);
Table
table
=
modelClass
.
getAnnotation
(
Table
.
class
);
...
@@ -39,7 +47,7 @@ public class SQLUtils {
...
@@ -39,7 +47,7 @@ public class SQLUtils {
tableFieldList
.
add
(
column
.
name
());
tableFieldList
.
add
(
column
.
name
());
modelGetMethodList
.
add
(
method
.
getName
());
modelGetMethodList
.
add
(
method
.
getName
());
}
}
BatchInsertResult
result
=
new
BatchInsertResult
();
//构造insert sql
//构造insert sql
String
fieldStr
=
tableFieldList
.
stream
().
collect
(
Collectors
.
joining
(
","
));
String
fieldStr
=
tableFieldList
.
stream
().
collect
(
Collectors
.
joining
(
","
));
StringBuilder
insertSQL
=
new
StringBuilder
();
StringBuilder
insertSQL
=
new
StringBuilder
();
...
@@ -52,22 +60,23 @@ public class SQLUtils {
...
@@ -52,22 +60,23 @@ public class SQLUtils {
}
}
insertSQL
.
append
(
")"
);
insertSQL
.
append
(
")"
);
result
.
setInsertSQL
(
insertSQL
.
toString
());
//构造实体
//构造实体
List
<
Object
[]>
toInserteParams
=
new
ArrayList
<>(
models
.
size
());
if
(
models
!=
null
)
{
for
(
BaseModelClass
model
:
models
)
{
List
<
Object
[]>
toInserteParams
=
new
ArrayList
<>(
models
.
size
());
Object
[]
array
=
new
Object
[
modelGetMethodList
.
size
()];
for
(
BaseModelClass
model
:
models
)
{
int
i
=
0
;
Object
[]
array
=
new
Object
[
modelGetMethodList
.
size
()];
for
(
String
getMethod
:
modelGetMethodList
)
{
int
i
=
0
;
Method
method
=
modelClass
.
getMethod
(
getMethod
);
for
(
String
getMethod
:
modelGetMethodList
)
{
array
[
i
]
=
method
.
invoke
(
model
);
Method
method
=
modelClass
.
getMethod
(
getMethod
);
i
++;
array
[
i
]
=
method
.
invoke
(
model
);
i
++;
}
toInserteParams
.
add
(
array
);
}
}
toInserteParams
.
add
(
array
);
result
.
setInsertParams
(
toInserteParams
);
}
}
BatchInsertResult
result
=
new
BatchInsertResult
();
result
.
setInsertSQL
(
insertSQL
.
toString
());
result
.
setInsertParams
(
toInserteParams
);
return
result
;
return
result
;
}
}
...
...
src/main/java/cn/com/poc/common/utils/WaveHeader.java
0 → 100644
View file @
cbfb29ad
package
cn
.
com
.
poc
.
common
.
utils
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
public
class
WaveHeader
{
public
final
char
fileID
[]
=
{
'R'
,
'I'
,
'F'
,
'F'
};
public
int
fileLength
;
public
char
wavTag
[]
=
{
'W'
,
'A'
,
'V'
,
'E'
};
public
char
FmtHdrID
[]
=
{
'f'
,
'm'
,
't'
,
' '
};
public
int
FmtHdrLeth
;
public
short
FormatTag
;
public
short
Channels
;
public
int
SamplesPerSec
;
public
int
AvgBytesPerSec
;
public
short
BlockAlign
;
public
short
BitsPerSample
;
public
char
DataHdrID
[]
=
{
'd'
,
'a'
,
't'
,
'a'
};
public
int
DataHdrLeth
;
public
byte
[]
getHeader
()
throws
IOException
{
ByteArrayOutputStream
bos
=
new
ByteArrayOutputStream
();
WriteChar
(
bos
,
fileID
);
WriteInt
(
bos
,
fileLength
);
WriteChar
(
bos
,
wavTag
);
WriteChar
(
bos
,
FmtHdrID
);
WriteInt
(
bos
,
FmtHdrLeth
);
WriteShort
(
bos
,
FormatTag
);
WriteShort
(
bos
,
Channels
);
WriteInt
(
bos
,
SamplesPerSec
);
WriteInt
(
bos
,
AvgBytesPerSec
);
WriteShort
(
bos
,
BlockAlign
);
WriteShort
(
bos
,
BitsPerSample
);
WriteChar
(
bos
,
DataHdrID
);
WriteInt
(
bos
,
DataHdrLeth
);
bos
.
flush
();
byte
[]
r
=
bos
.
toByteArray
();
bos
.
close
();
return
r
;
}
private
void
WriteShort
(
ByteArrayOutputStream
bos
,
int
s
)
throws
IOException
{
byte
[]
mybyte
=
new
byte
[
2
];
mybyte
[
1
]
=
(
byte
)
((
s
<<
16
)
>>
24
);
mybyte
[
0
]
=
(
byte
)
((
s
<<
24
)
>>
24
);
bos
.
write
(
mybyte
);
}
private
void
WriteInt
(
ByteArrayOutputStream
bos
,
int
n
)
throws
IOException
{
byte
[]
buf
=
new
byte
[
4
];
buf
[
3
]
=
(
byte
)
(
n
>>
24
);
buf
[
2
]
=
(
byte
)
((
n
<<
8
)
>>
24
);
buf
[
1
]
=
(
byte
)
((
n
<<
16
)
>>
24
);
buf
[
0
]
=
(
byte
)
((
n
<<
24
)
>>
24
);
bos
.
write
(
buf
);
}
private
void
WriteChar
(
ByteArrayOutputStream
bos
,
char
[]
id
)
{
for
(
char
c
:
id
)
{
bos
.
write
(
c
);
}
}
}
src/main/java/cn/com/poc/expose/aggregate/AgentApplicationService.java
View file @
cbfb29ad
...
@@ -2,6 +2,7 @@ package cn.com.poc.expose.aggregate;
...
@@ -2,6 +2,7 @@ package cn.com.poc.expose.aggregate;
import
cn.com.poc.agent_application.query.MemberCollectQueryItem
;
import
cn.com.poc.agent_application.query.MemberCollectQueryItem
;
import
cn.com.yict.framemax.data.model.PagingInfo
;
import
cn.com.yict.framemax.data.model.PagingInfo
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.List
;
import
java.util.List
;
...
@@ -10,8 +11,13 @@ public interface AgentApplicationService {
...
@@ -10,8 +11,13 @@ public interface AgentApplicationService {
/**
/**
* 调用 已发布Agent应用
* 调用 已发布Agent应用
*
* @param agentId 应用ID
* @param dialogsId 对话ID
* @param input 用户输入
* @param fileUrls 文件URL
*/
*/
void
callAgentApplication
(
String
agentId
,
String
dialogsId
,
String
input
,
HttpServletResponse
httpServletResponse
)
throws
Exception
;
void
callAgentApplication
(
String
agentId
,
String
dialogsId
,
String
input
,
List
<
String
>
fileUrls
,
HttpServletResponse
httpServletResponse
)
throws
Exception
;
/**
/**
* 追问AI生成
* 追问AI生成
...
@@ -24,7 +30,7 @@ public interface AgentApplicationService {
...
@@ -24,7 +30,7 @@ public interface AgentApplicationService {
/**
/**
* [首页] 获取推荐问
* [首页] 获取推荐问
*
*
* @param xlang 语言 zh-cn 中文简体 en 英文 zh-tw 中文繁体
* @param xlang
语言 zh-cn 中文简体 en 英文 zh-tw 中文繁体
* @param memberId 用户ID
* @param memberId 用户ID
*/
*/
List
<
String
>
getRecommendQuestions
(
String
xlang
,
Long
memberId
)
throws
InterruptedException
;
List
<
String
>
getRecommendQuestions
(
String
xlang
,
Long
memberId
)
throws
InterruptedException
;
...
@@ -41,4 +47,21 @@ public interface AgentApplicationService {
...
@@ -41,4 +47,21 @@ public interface AgentApplicationService {
*/
*/
List
<
MemberCollectQueryItem
>
getCollectedApplications
(
Long
memberId
,
PagingInfo
pagingInfo
);
List
<
MemberCollectQueryItem
>
getCollectedApplications
(
Long
memberId
,
PagingInfo
pagingInfo
);
/**
* 获取用户在当前应用的自动播放配置
*
* @param memberId 用户ID
* @param agentId 应用ID
*/
String
autoPlayByAgentId
(
Long
memberId
,
String
agentId
);
/**
* 设置用户在当前应用的自动播放配置
*
* @param memberId 用户ID
* @param agentId 应用ID
* @param autoPlay 自动播放配置 Y/N
*/
String
enableAutoPlay
(
Long
memberId
,
String
agentId
,
String
autoPlay
);
}
}
src/main/java/cn/com/poc/expose/aggregate/impl/AgentApplicationServiceImpl.java
View file @
cbfb29ad
...
@@ -6,37 +6,36 @@ import cn.com.poc.agent_application.constant.AgentApplicationGCConfigConstants;
...
@@ -6,37 +6,36 @@ import cn.com.poc.agent_application.constant.AgentApplicationGCConfigConstants;
import
cn.com.poc.agent_application.entity.BizAgentApplicationDialoguesRecordEntity
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationDialoguesRecordEntity
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationGcConfigEntity
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationGcConfigEntity
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationPublishEntity
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationPublishEntity
;
import
cn.com.poc.agent_application.entity.V
ariable
;
import
cn.com.poc.agent_application.entity.V
oiceConfig
;
import
cn.com.poc.agent_application.query.MemberCollectQueryCondition
;
import
cn.com.poc.agent_application.query.MemberCollectQueryCondition
;
import
cn.com.poc.agent_application.query.MemberCollectQueryItem
;
import
cn.com.poc.agent_application.query.MemberCollectQueryItem
;
import
cn.com.poc.agent_application.service.BizAgentApplicationDialoguesRecordService
;
import
cn.com.poc.agent_application.service.BizAgentApplicationDialoguesRecordService
;
import
cn.com.poc.agent_application.service.BizAgentApplicationGcConfigService
;
import
cn.com.poc.agent_application.service.BizAgentApplicationGcConfigService
;
import
cn.com.poc.agent_application.service.BizAgentApplicationPublishService
;
import
cn.com.poc.agent_application.service.BizAgentApplicationPublishService
;
import
cn.com.poc.agent_application.service.BizMemberAgentApplicationCollectService
;
import
cn.com.poc.agent_application.service.BizMemberAgentApplicationCollectService
;
import
cn.com.poc.agent_application.utils.AgentApplicationTools
;
import
cn.com.poc.common.constant.CommonConstant
;
import
cn.com.poc.common.constant.CommonConstant
;
import
cn.com.poc.common.constant.XLangConstant
;
import
cn.com.poc.common.constant.XLangConstant
;
import
cn.com.poc.common.service.RedisService
;
import
cn.com.poc.common.service.RedisService
;
import
cn.com.poc.common.utils.BlContext
;
import
cn.com.poc.common.utils.BlContext
;
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.expose.aggregate.AgentApplicationService
;
import
cn.com.poc.expose.aggregate.AgentApplicationService
;
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.constants.LLMRoleEnum
;
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.constants.LLMRoleEnum
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.largemodel.LargeModelDemandResult
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.largemodel.LargeModelDemandResult
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.largemodel.LargeModelResponse
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.largemodel.LargeModelResponse
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.LargeModelFunctionEnum
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.value_memory.GetValueMemory
;
import
cn.com.poc.thirdparty.service.LLMService
;
import
cn.com.poc.thirdparty.service.LLMService
;
import
cn.com.yict.framemax.core.exception.BusinessException
;
import
cn.com.yict.framemax.core.i18n.I18nMessageException
;
import
cn.com.yict.framemax.core.i18n.I18nMessageException
;
import
cn.com.yict.framemax.data.model.PagingInfo
;
import
cn.com.yict.framemax.data.model.PagingInfo
;
import
com.alibaba.fastjson.JSONObject
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.github.houbb.opencc4j.util.ZhConverterUtil
;
import
com.github.houbb.opencc4j.util.ZhConverterUtil
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.MapUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -44,8 +43,12 @@ import org.springframework.stereotype.Service;
...
@@ -44,8 +43,12 @@ import org.springframework.stereotype.Service;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.File
;
import
java.security.SecureRandom
;
import
java.security.SecureRandom
;
import
java.util.*
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
@Service
@Service
...
@@ -53,6 +56,9 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
...
@@ -53,6 +56,9 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
final
private
Logger
logger
=
LoggerFactory
.
getLogger
(
AgentApplicationService
.
class
);
final
private
Logger
logger
=
LoggerFactory
.
getLogger
(
AgentApplicationService
.
class
);
/**
* 推荐问Key
*/
final
private
String
AGENT_APPLICATION_RECOMMEND_QUESTIONS
=
"AGENT_APPLICATION_RECOMMEND_QUESTIONS:"
;
final
private
String
AGENT_APPLICATION_RECOMMEND_QUESTIONS
=
"AGENT_APPLICATION_RECOMMEND_QUESTIONS:"
;
/**
/**
...
@@ -60,6 +66,11 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
...
@@ -60,6 +66,11 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
*/
*/
final
private
String
MEMBER_RECOMMEND_QUESTIONS_LAST
=
AGENT_APPLICATION_RECOMMEND_QUESTIONS
+
"MEMBER_LAST:"
;
final
private
String
MEMBER_RECOMMEND_QUESTIONS_LAST
=
AGENT_APPLICATION_RECOMMEND_QUESTIONS
+
"MEMBER_LAST:"
;
/**
* 应用自动播放Key
*/
final
private
String
AGENT_APPLICATION_AUTO_PLAY
=
"AGENT_APPLICATION_AUTO_PLAY:"
;
@Resource
@Resource
private
BizMemberAgentApplicationCollectService
bizMemberAgentApplicationCollectService
;
private
BizMemberAgentApplicationCollectService
bizMemberAgentApplicationCollectService
;
...
@@ -86,7 +97,7 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
...
@@ -86,7 +97,7 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
private
RedisService
redisService
;
private
RedisService
redisService
;
@Override
@Override
public
void
callAgentApplication
(
String
agentId
,
String
dialogsId
,
String
input
,
HttpServletResponse
httpServletResponse
)
{
public
void
callAgentApplication
(
String
agentId
,
String
dialogsId
,
String
input
,
List
<
String
>
fileUrls
,
HttpServletResponse
httpServletResponse
)
{
UserBaseEntity
userBaseEntity
=
BlContext
.
getCurrentUserNotException
();
UserBaseEntity
userBaseEntity
=
BlContext
.
getCurrentUserNotException
();
if
(
userBaseEntity
==
null
)
{
if
(
userBaseEntity
==
null
)
{
...
@@ -100,21 +111,20 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
...
@@ -100,21 +111,20 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
throw
new
I18nMessageException
(
"exception/app.not.found"
);
throw
new
I18nMessageException
(
"exception/app.not.found"
);
}
}
// 判断文件是否为空,如果不为空
AgentApplicationTools
.
checkDialogueContentIsEmpty
(
fileUrls
);
if
(
StringUtils
.
isBlank
(
dialogsId
))
{
if
(
StringUtils
.
isBlank
(
dialogsId
))
{
// 用于针对只有单Agent应用分享使用的场景,dialogsId为空
// 用于针对只有单Agent应用分享使用的场景,dialogsId为空
dialogsId
=
agentId
+
"
_
"
+
userBaseEntity
.
getUserId
();
dialogsId
=
agentId
+
"
-
"
+
userBaseEntity
.
getUserId
();
}
}
//获取知识库配置
//获取知识库配置
List
<
Integer
>
kdIdList
=
knowledgeService
.
getKdIdsByKnowledgeInfoIds
(
infoEntity
.
getKnowledgeIds
());
List
<
Integer
>
kdIdList
=
knowledgeService
.
getKdIdsByKnowledgeInfoIds
(
infoEntity
.
getKnowledgeIds
());
// 构造对话参数
// 构造对话参数
List
<
Message
>
messages
=
buildMessages
(
dialogsId
,
agentId
,
userBaseEntity
.
getUserId
(),
input
);
List
<
Message
>
messages
=
buildMessages
(
dialogsId
,
agentId
,
userBaseEntity
.
getUserId
(),
input
);
//配置对话function
List
<
Tool
>
tools
=
buildMemoryConfig
(
infoEntity
,
dialogsId
);
// 保存用户输入记录
// 保存用户输入记录
Long
inputTimestamp
=
System
.
currentTimeMillis
();
Long
inputTimestamp
=
System
.
currentTimeMillis
();
BizAgentApplicationDialoguesRecordEntity
inputRecord
=
new
BizAgentApplicationDialoguesRecordEntity
();
BizAgentApplicationDialoguesRecordEntity
inputRecord
=
new
BizAgentApplicationDialoguesRecordEntity
();
...
@@ -126,8 +136,11 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
...
@@ -126,8 +136,11 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
inputRecord
.
setTimestamp
(
inputTimestamp
);
inputRecord
.
setTimestamp
(
inputTimestamp
);
bizAgentApplicationDialoguesRecordService
.
save
(
inputRecord
);
bizAgentApplicationDialoguesRecordService
.
save
(
inputRecord
);
//配置对话function
List
<
Tool
>
tools
=
AgentApplicationTools
.
buildFunctionConfig
(
infoEntity
.
getVariableStructure
(),
infoEntity
.
getIsLongMemory
(),
dialogsId
,
agentId
,
infoEntity
.
getUnitIds
(),
infoEntity
.
getIsDocumentParsing
());
//
记录输出时间戳
//记录输出时间戳
BizAgentApplicationDialoguesRecordEntity
outputRecord
=
new
BizAgentApplicationDialoguesRecordEntity
();
BizAgentApplicationDialoguesRecordEntity
outputRecord
=
new
BizAgentApplicationDialoguesRecordEntity
();
outputRecord
.
setRole
(
AgentApplicationDialoguesRecordConstants
.
ROLE
.
ASSISTANT
);
outputRecord
.
setRole
(
AgentApplicationDialoguesRecordConstants
.
ROLE
.
ASSISTANT
);
outputRecord
.
setAgentId
(
infoEntity
.
getAgentId
());
outputRecord
.
setAgentId
(
infoEntity
.
getAgentId
());
...
@@ -136,15 +149,15 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
...
@@ -136,15 +149,15 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
outputRecord
.
setTimestamp
(
System
.
currentTimeMillis
());
outputRecord
.
setTimestamp
(
System
.
currentTimeMillis
());
//对话
//对话
String
output
=
agentApplicationInfoService
.
callAgentApplication
(
dialogsId
,
infoEntity
.
getLargeModel
(),
String
output
=
agentApplicationInfoService
.
callAgentApplication
(
agentId
,
dialogsId
,
infoEntity
.
getLargeModel
(),
infoEntity
.
get
UnitIds
(),
infoEntity
.
get
AgentSystem
(),
kdIdList
.
toArray
(
new
Integer
[
0
]),
infoEntity
.
getCommunicationTurn
(),
infoEntity
.
getAgentSystem
(),
kdIdList
.
toArray
(
new
Integer
[
0
]),
infoEntity
.
getCommunicationTurn
(),
infoEntity
.
getTopP
(),
infoEntity
.
getTemperature
(),
messages
,
tools
,
httpServletResponse
);
infoEntity
.
getTopP
(),
infoEntity
.
getTemperature
(),
messages
,
tools
,
fileUrls
,
httpServletResponse
);
//保存对话记录
//保存对话记录
outputRecord
.
setContent
(
output
);
outputRecord
.
setContent
(
output
);
bizAgentApplicationDialoguesRecordService
.
save
(
outputRecord
);
bizAgentApplicationDialoguesRecordService
.
save
(
outputRecord
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
I18nMessage
Exception
(
e
.
getMessage
());
throw
new
Business
Exception
(
e
.
getMessage
());
}
}
}
}
...
@@ -255,6 +268,48 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
...
@@ -255,6 +268,48 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
createENQuestion
();
createENQuestion
();
}
}
@Override
public
List
<
MemberCollectQueryItem
>
getCollectedApplications
(
Long
memberId
,
PagingInfo
pagingInfo
)
{
MemberCollectQueryCondition
condition
=
new
MemberCollectQueryCondition
();
condition
.
setMemberId
(
memberId
);
condition
.
setIsCollect
(
CommonConstant
.
YOrN
.
Y
);
List
<
MemberCollectQueryItem
>
memberCollectQueryItems
=
bizMemberAgentApplicationCollectService
.
queryMemberCollect
(
condition
,
pagingInfo
);
return
memberCollectQueryItems
;
}
@Override
public
String
autoPlayByAgentId
(
Long
memberId
,
String
agentId
)
{
String
result
=
CommonConstant
.
YOrN
.
N
;
String
redisKey
=
AGENT_APPLICATION_AUTO_PLAY
+
memberId
+
":"
+
agentId
;
if
(
redisService
.
hasKey
(
redisKey
))
{
result
=
(
String
)
redisService
.
get
(
redisKey
);
}
else
{
BizAgentApplicationPublishEntity
publishEntity
=
bizAgentApplicationPublishService
.
getByAgentId
(
agentId
);
if
(
publishEntity
==
null
)
{
throw
new
I18nMessageException
(
"exception/application.does.not.exist"
);
}
VoiceConfig
voiceConfig
=
publishEntity
.
getVoiceConfig
();
if
(
voiceConfig
!=
null
)
{
String
isAutoPlay
=
voiceConfig
.
getDefaultOpen
();
result
=
isAutoPlay
;
}
redisService
.
set
(
redisKey
,
result
,
30
*
60
*
60
*
24
);
}
return
result
;
}
@Override
public
String
enableAutoPlay
(
Long
memberId
,
String
agentId
,
String
autoPlay
)
{
BizAgentApplicationPublishEntity
publishEntity
=
bizAgentApplicationPublishService
.
getByAgentId
(
agentId
);
if
(
publishEntity
==
null
)
{
throw
new
I18nMessageException
(
"exception/application.does.not.exist"
);
}
String
redisKey
=
AGENT_APPLICATION_AUTO_PLAY
+
memberId
+
":"
+
agentId
;
redisService
.
set
(
redisKey
,
autoPlay
,
30
*
60
*
60
*
24
);
return
autoPlay
;
}
private
void
createCNQuestion
()
{
private
void
createCNQuestion
()
{
Message
message
=
new
Message
();
Message
message
=
new
Message
();
message
.
setRole
(
LLMRoleEnum
.
USER
.
getRole
());
message
.
setRole
(
LLMRoleEnum
.
USER
.
getRole
());
...
@@ -308,15 +363,6 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
...
@@ -308,15 +363,6 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
redisService
.
lSet
(
AGENT_APPLICATION_RECOMMEND_QUESTIONS
+
"en"
,
questions
);
redisService
.
lSet
(
AGENT_APPLICATION_RECOMMEND_QUESTIONS
+
"en"
,
questions
);
}
}
@Override
public
List
<
MemberCollectQueryItem
>
getCollectedApplications
(
Long
memberId
,
PagingInfo
pagingInfo
)
{
MemberCollectQueryCondition
condition
=
new
MemberCollectQueryCondition
();
condition
.
setMemberId
(
memberId
);
condition
.
setIsCollect
(
CommonConstant
.
YOrN
.
Y
);
List
<
MemberCollectQueryItem
>
memberCollectQueryItems
=
bizMemberAgentApplicationCollectService
.
queryMemberCollect
(
condition
,
pagingInfo
);
return
memberCollectQueryItems
;
}
private
List
<
Message
>
buildMessages
(
String
dialogsId
,
String
agentId
,
Long
userId
,
String
input
)
throws
Exception
{
private
List
<
Message
>
buildMessages
(
String
dialogsId
,
String
agentId
,
Long
userId
,
String
input
)
throws
Exception
{
List
<
Message
>
messages
=
new
ArrayList
<>();
List
<
Message
>
messages
=
new
ArrayList
<>();
BizAgentApplicationDialoguesRecordEntity
recordEntity
=
new
BizAgentApplicationDialoguesRecordEntity
();
BizAgentApplicationDialoguesRecordEntity
recordEntity
=
new
BizAgentApplicationDialoguesRecordEntity
();
...
@@ -351,62 +397,4 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
...
@@ -351,62 +397,4 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
logger
.
info
(
"--------- Build Messages dialogsId:{},agentId:{},messages:{}--------------"
,
dialogsId
,
agentId
,
messages
);
logger
.
info
(
"--------- Build Messages dialogsId:{},agentId:{},messages:{}--------------"
,
dialogsId
,
agentId
,
messages
);
return
messages
;
return
messages
;
}
}
@Deprecated
private
void
saveDialoguesRecord
(
String
dialogsId
,
String
input
,
BizAgentApplicationPublishEntity
infoEntity
,
UserBaseEntity
userBaseEntity
,
Long
inputTimestamp
,
String
output
)
throws
Exception
{
// 回答时间戳
Long
outputTimestamp
=
System
.
currentTimeMillis
();
BizAgentApplicationDialoguesRecordEntity
inputRecord
=
new
BizAgentApplicationDialoguesRecordEntity
();
inputRecord
.
setAgentId
(
infoEntity
.
getAgentId
());
inputRecord
.
setMemberId
(
userBaseEntity
.
getUserId
());
inputRecord
.
setContent
(
input
);
inputRecord
.
setDialogsId
(
dialogsId
);
inputRecord
.
setRole
(
AgentApplicationDialoguesRecordConstants
.
ROLE
.
USER
);
inputRecord
.
setTimestamp
(
inputTimestamp
);
BizAgentApplicationDialoguesRecordEntity
outputRecord
=
new
BizAgentApplicationDialoguesRecordEntity
();
outputRecord
.
setRole
(
AgentApplicationDialoguesRecordConstants
.
ROLE
.
ASSISTANT
);
outputRecord
.
setAgentId
(
infoEntity
.
getAgentId
());
outputRecord
.
setDialogsId
(
dialogsId
);
outputRecord
.
setMemberId
(
userBaseEntity
.
getUserId
());
outputRecord
.
setContent
(
output
);
outputRecord
.
setTimestamp
(
outputTimestamp
);
bizAgentApplicationDialoguesRecordService
.
save
(
inputRecord
);
bizAgentApplicationDialoguesRecordService
.
save
(
outputRecord
);
}
private
List
<
Tool
>
buildMemoryConfig
(
BizAgentApplicationPublishEntity
infoEntity
,
String
identifier
)
{
List
<
Tool
>
tools
=
new
ArrayList
<>();
//开启对话变量
if
(
CollectionUtils
.
isNotEmpty
(
infoEntity
.
getVariableStructure
()))
{
String
functionName
=
LargeModelFunctionEnum
.
set_value_memory
.
name
();
String
llmConfig
=
LargeModelFunctionEnum
.
valueOf
(
functionName
).
getFunction
().
getVariableStructureLLMConfig
(
infoEntity
.
getVariableStructure
()).
get
(
0
);
Tool
tool
=
JsonUtils
.
deSerialize
(
llmConfig
,
Tool
.
class
);
tools
.
add
(
tool
);
//初始化变量函数
Map
<
Object
,
Object
>
map
=
GetValueMemory
.
get
(
identifier
);
if
(
MapUtils
.
isEmpty
(
map
))
{
List
<
Variable
>
variableStructure
=
infoEntity
.
getVariableStructure
();
for
(
Variable
variable
:
variableStructure
)
{
String
key
=
variable
.
getKey
();
String
variableDefault
=
variable
.
getVariableDefault
();
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"contentName"
,
key
);
jsonObject
.
put
(
"contentValue"
,
variableDefault
);
LargeModelFunctionEnum
.
valueOf
(
functionName
).
getFunction
().
doFunction
(
jsonObject
.
toJSONString
(),
identifier
);
}
}
}
//开启长期记忆
if
(
CommonConstant
.
YOrN
.
Y
.
equals
(
infoEntity
.
getIsLongMemory
()))
{
String
functionName
=
LargeModelFunctionEnum
.
set_long_memory
.
name
();
String
llmConfig
=
LargeModelFunctionEnum
.
valueOf
(
functionName
).
getFunction
().
getLLMConfig
().
get
(
0
);
Tool
tool
=
JsonUtils
.
deSerialize
(
llmConfig
,
Tool
.
class
);
tools
.
add
(
tool
);
}
return
tools
;
}
}
}
src/main/java/cn/com/poc/expose/dto/AgentApplicationDto.java
View file @
cbfb29ad
package
cn
.
com
.
poc
.
expose
.
dto
;
package
cn
.
com
.
poc
.
expose
.
dto
;
import
java.util.List
;
public
class
AgentApplicationDto
{
public
class
AgentApplicationDto
{
private
String
dialogsId
;
private
String
dialogsId
;
...
@@ -32,4 +34,13 @@ public class AgentApplicationDto {
...
@@ -32,4 +34,13 @@ public class AgentApplicationDto {
this
.
input
=
input
;
this
.
input
=
input
;
}
}
private
List
<
String
>
fileUrls
;
public
List
<
String
>
getFileUrls
()
{
return
fileUrls
;
}
public
void
setFileUrls
(
List
<
String
>
fileUrls
)
{
this
.
fileUrls
=
fileUrls
;
}
}
}
src/main/java/cn/com/poc/expose/dto/UserDialoguesDto.java
View file @
cbfb29ad
...
@@ -9,6 +9,12 @@ public class UserDialoguesDto implements Serializable {
...
@@ -9,6 +9,12 @@ public class UserDialoguesDto implements Serializable {
*/
*/
private
java
.
lang
.
String
dialogsId
;
private
java
.
lang
.
String
dialogsId
;
/**
* 应用ID
*/
private
java
.
lang
.
String
agentId
;
/**
/**
* 内容
* 内容
*/
*/
...
@@ -30,4 +36,12 @@ public class UserDialoguesDto implements Serializable {
...
@@ -30,4 +36,12 @@ public class UserDialoguesDto implements Serializable {
public
void
setContent
(
String
content
)
{
public
void
setContent
(
String
content
)
{
this
.
content
=
content
;
this
.
content
=
content
;
}
}
public
String
getAgentId
()
{
return
agentId
;
}
public
void
setAgentId
(
String
agentId
)
{
this
.
agentId
=
agentId
;
}
}
}
src/main/java/cn/com/poc/expose/rest/AgentApplicationRest.java
View file @
cbfb29ad
...
@@ -86,4 +86,18 @@ public interface AgentApplicationRest extends BaseRest {
...
@@ -86,4 +86,18 @@ public interface AgentApplicationRest extends BaseRest {
*/
*/
List
<
DialoguesContextDto
>
getDialogueContext
(
@RequestParam
String
dialogueId
)
throws
Exception
;
List
<
DialoguesContextDto
>
getDialogueContext
(
@RequestParam
String
dialogueId
)
throws
Exception
;
/**
* 获取用户在当前应用的自动播放配置
*
* @param agentId 应用ID
*/
String
autoPlayByAgentId
(
@RequestParam
String
agentId
);
/**
* 设置用户在当前应用的自动播放配置
*
* @param agentId 应用ID
* @param autoPlay 自动播放配置 Y/N
*/
String
enableAutoPlay
(
@RequestParam
String
agentId
,
@RequestParam
String
autoPlay
);
}
}
src/main/java/cn/com/poc/expose/rest/impl/AgentApplicationRestImpl.java
View file @
cbfb29ad
package
cn
.
com
.
poc
.
expose
.
rest
.
impl
;
package
cn
.
com
.
poc
.
expose
.
rest
.
impl
;
import
cn.com.poc.agent_application.aggregate.AgentApplicationInfoService
;
import
cn.com.poc.agent_application.aggregate.AgentApplicationInfoService
;
import
cn.com.poc.agent_application.aggregate.AgentApplicationMallService
;
import
cn.com.poc.agent_application.convert.AgentApplicationInfoConvert
;
import
cn.com.poc.agent_application.convert.AgentApplicationInfoConvert
;
import
cn.com.poc.agent_application.convert.BizAgentApplicationPublishConvert
;
import
cn.com.poc.agent_application.convert.BizAgentApplicationPublishConvert
;
import
cn.com.poc.agent_application.dto.AgentApplicationCreateContinueQuesDto
;
import
cn.com.poc.agent_application.dto.AgentApplicationCreateContinueQuesDto
;
...
@@ -104,7 +103,7 @@ public class AgentApplicationRestImpl implements AgentApplicationRest {
...
@@ -104,7 +103,7 @@ public class AgentApplicationRestImpl implements AgentApplicationRest {
Assert
.
notNull
(
dto
.
getAgentId
());
Assert
.
notNull
(
dto
.
getAgentId
());
Assert
.
notNull
(
dto
.
getDialogsId
());
Assert
.
notNull
(
dto
.
getDialogsId
());
try
{
try
{
agentApplicationService
.
callAgentApplication
(
dto
.
getAgentId
(),
dto
.
getDialogsId
(),
dto
.
getInput
(),
httpServletResponse
);
agentApplicationService
.
callAgentApplication
(
dto
.
getAgentId
(),
dto
.
getDialogsId
(),
dto
.
getInput
(),
dto
.
getFileUrls
(),
httpServletResponse
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
httpServletResponse
.
setContentType
(
"text/event-stream"
);
httpServletResponse
.
setContentType
(
"text/event-stream"
);
PrintWriter
writer
=
httpServletResponse
.
getWriter
();
PrintWriter
writer
=
httpServletResponse
.
getWriter
();
...
@@ -185,6 +184,7 @@ public class AgentApplicationRestImpl implements AgentApplicationRest {
...
@@ -185,6 +184,7 @@ public class AgentApplicationRestImpl implements AgentApplicationRest {
result
=
memberDialoguesQueryItems
.
stream
().
map
(
item
->
{
result
=
memberDialoguesQueryItems
.
stream
().
map
(
item
->
{
UserDialoguesDto
userDialoguesDto
=
new
UserDialoguesDto
();
UserDialoguesDto
userDialoguesDto
=
new
UserDialoguesDto
();
userDialoguesDto
.
setDialogsId
(
item
.
getDialogsId
());
userDialoguesDto
.
setDialogsId
(
item
.
getDialogsId
());
userDialoguesDto
.
setAgentId
(
item
.
getAgentId
());
String
content
=
item
.
getContent
().
length
()
>
20
?
item
.
getContent
().
substring
(
0
,
20
)
:
item
.
getContent
();
String
content
=
item
.
getContent
().
length
()
>
20
?
item
.
getContent
().
substring
(
0
,
20
)
:
item
.
getContent
();
userDialoguesDto
.
setContent
(
content
);
userDialoguesDto
.
setContent
(
content
);
return
userDialoguesDto
;
return
userDialoguesDto
;
...
@@ -231,4 +231,20 @@ public class AgentApplicationRestImpl implements AgentApplicationRest {
...
@@ -231,4 +231,20 @@ public class AgentApplicationRestImpl implements AgentApplicationRest {
}
}
return
null
;
return
null
;
}
}
@Override
public
String
autoPlayByAgentId
(
String
agentId
)
{
Assert
.
notBlank
(
agentId
);
UserBaseEntity
currentUser
=
BlContext
.
getCurrentUser
();
return
agentApplicationService
.
autoPlayByAgentId
(
currentUser
.
getUserId
(),
agentId
);
}
@Override
public
String
enableAutoPlay
(
String
agentId
,
String
autoPlay
)
{
Assert
.
notBlank
(
agentId
);
Assert
.
notBlank
(
autoPlay
);
Assert
.
isTrue
(
CommonConstant
.
YOrN
.
N
.
equals
(
autoPlay
)
||
CommonConstant
.
YOrN
.
Y
.
equals
(
autoPlay
));
UserBaseEntity
currentUser
=
BlContext
.
getCurrentUser
();
return
agentApplicationService
.
enableAutoPlay
(
currentUser
.
getUserId
(),
agentId
,
autoPlay
);
}
}
}
src/main/java/cn/com/poc/expose/websocket/SuperLinkWebSocketServer.java
0 → 100644
View file @
cbfb29ad
package
cn
.
com
.
poc
.
expose
.
websocket
;
import
cn.com.poc.expose.websocket.constant.WsHandlerMatcher
;
import
cn.com.poc.expose.websocket.handler.AbstractWsHandler
;
import
cn.com.poc.expose.websocket.holder.WSHandlerHolder
;
import
cn.com.yict.framemax.core.config.Config
;
import
cn.com.yict.framemax.core.exception.BusinessException
;
import
org.java_websocket.WebSocket
;
import
org.java_websocket.handshake.ClientHandshake
;
import
org.java_websocket.server.WebSocketServer
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.MDC
;
import
org.springframework.stereotype.Component
;
import
java.io.IOException
;
import
java.net.InetSocketAddress
;
import
java.util.Arrays
;
import
java.util.UUID
;
/**
* @author alex.yao
* @date 2023/12/7
**/
@Component
public
class
SuperLinkWebSocketServer
extends
WebSocketServer
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
SuperLinkWebSocketServer
.
class
);
private
boolean
serverStarted
=
false
;
private
final
String
LOG_KEY
=
"log_trace_id"
;
private
SuperLinkWebSocketServer
()
{
}
public
SuperLinkWebSocketServer
(
int
port
,
int
decodercount
)
{
super
(
new
InetSocketAddress
(
port
),
decodercount
);
}
@Override
public
void
onOpen
(
WebSocket
webSocket
,
ClientHandshake
clientHandshake
)
{
// auth(webSocket);
initWebSocketTraceId
();
String
path
=
webSocket
.
getResourceDescriptor
();
logger
.
warn
(
"websocket new connection open , address:{} ,path:{} "
,
webSocket
.
getRemoteSocketAddress
().
toString
(),
path
);
AbstractWsHandler
handlerClass
=
WsHandlerMatcher
.
getWsHandlerClass
(
path
);
if
(
handlerClass
!=
null
)
{
WSHandlerHolder
.
set
(
handlerClass
);
}
else
{
webSocket
.
send
(
"{\"code\":-1, \"message\":\"path mismatch\"}"
);
webSocket
.
close
();
}
}
private
void
auth
(
WebSocket
webSocket
)
{
String
hostName
=
webSocket
.
getRemoteSocketAddress
().
getHostName
();
logger
.
info
(
"connection hostname:{}"
,
hostName
);
String
[]
split
=
Config
.
get
(
"white.list.ip"
).
split
(
","
);
if
(
Arrays
.
stream
(
split
).
noneMatch
(
ip
->
ip
.
equals
(
hostName
)))
{
throw
new
BusinessException
(
"no authority"
);
}
}
@Override
public
void
onMessage
(
WebSocket
webSocket
,
String
s
)
{
logger
.
info
(
"{} connection send message:{}"
,
webSocket
.
getRemoteSocketAddress
().
toString
(),
s
.
length
()
<
1024
?
s
:
"response too long"
);
WSHandlerHolder
.
get
().
doHandler
(
webSocket
,
s
);
}
@Override
public
void
onClose
(
WebSocket
webSocket
,
int
i
,
String
s
,
boolean
b
)
{
logger
.
warn
(
"connection is close:{}"
,
webSocket
.
getRemoteSocketAddress
().
toString
()
+
webSocket
.
getResourceDescriptor
());
WSHandlerHolder
.
clear
();
}
@Override
public
void
onError
(
WebSocket
webSocket
,
Exception
e
)
{
logger
.
warn
(
"connection is error:{}"
,
webSocket
.
getRemoteSocketAddress
().
toString
()
+
webSocket
.
getResourceDescriptor
());
WSHandlerHolder
.
clear
();
}
@Override
public
void
onStart
()
{
logger
.
warn
(
"---------------------------------websocket start--------------------------------------"
);
}
@Override
public
void
start
()
{
serverStarted
=
true
;
super
.
start
();
}
@Override
public
void
stop
()
throws
IOException
,
InterruptedException
{
serverStarted
=
false
;
super
.
stop
();
}
@Override
public
void
stop
(
int
i
)
throws
InterruptedException
{
serverStarted
=
false
;
super
.
stop
(
i
);
}
public
boolean
isRun
()
{
return
this
.
serverStarted
;
}
private
void
initWebSocketTraceId
()
{
String
traceId
=
UUID
.
randomUUID
().
toString
().
replaceAll
(
"-"
,
""
);
MDC
.
put
(
LOG_KEY
,
traceId
);
}
}
src/main/java/cn/com/poc/expose/websocket/config/SuperLinkWebSocketConfig.java
0 → 100644
View file @
cbfb29ad
package
cn
.
com
.
poc
.
expose
.
websocket
.
config
;
import
cn.com.poc.expose.websocket.SuperLinkWebSocketServer
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
/**
* @author alex.yao
* @date 2023/12/7
**/
@Configuration
public
class
SuperLinkWebSocketConfig
{
@Bean
public
SuperLinkWebSocketServer
superLinkWebSocketServer
()
{
return
new
SuperLinkWebSocketServer
(
40088
,
Runtime
.
getRuntime
().
availableProcessors
()
*
10
);
}
}
src/main/java/cn/com/poc/expose/websocket/constant/WsHandlerMatcher.java
0 → 100644
View file @
cbfb29ad
package
cn
.
com
.
poc
.
expose
.
websocket
.
constant
;
import
cn.com.poc.common.utils.StringUtils
;
import
cn.com.poc.expose.websocket.handler.AbstractWsHandler
;
import
cn.com.poc.expose.websocket.handler.TextToSpeechTencentHandler
;
public
class
WsHandlerMatcher
{
final
private
static
String
TEXT_TO_SPEECH_TC
=
"/websocket/textToSpeechTC.ws"
;
public
static
AbstractWsHandler
getWsHandlerClass
(
String
path
)
{
if
(
StringUtils
.
isBlank
(
path
))
{
return
null
;
}
AbstractWsHandler
handler
=
null
;
switch
(
path
)
{
case
TEXT_TO_SPEECH_TC:
handler
=
new
TextToSpeechTencentHandler
();
break
;
}
return
handler
;
}
}
src/main/java/cn/com/poc/expose/websocket/dto/TextToSpeechTencentResponse.java
0 → 100644
View file @
cbfb29ad
package
cn
.
com
.
poc
.
expose
.
websocket
.
dto
;
public
class
TextToSpeechTencentResponse
{
private
String
codec
=
"mp3"
;
private
Integer
sampleRate
=
16000
;
private
Integer
voiceType
=
1001
;
private
Integer
volume
=
0
;
private
Float
speed
=
0
F
;
private
String
content
;
public
Float
getSpeed
()
{
return
speed
;
}
public
void
setSpeed
(
Float
speed
)
{
this
.
speed
=
speed
;
}
public
String
getContent
()
{
return
content
;
}
public
void
setContent
(
String
content
)
{
this
.
content
=
content
;
}
public
String
getCodec
()
{
return
codec
;
}
public
void
setCodec
(
String
codec
)
{
this
.
codec
=
codec
;
}
public
Integer
getSampleRate
()
{
return
sampleRate
;
}
public
void
setSampleRate
(
Integer
sampleRate
)
{
this
.
sampleRate
=
sampleRate
;
}
public
Integer
getVoiceType
()
{
return
voiceType
;
}
public
void
setVoiceType
(
Integer
voiceType
)
{
this
.
voiceType
=
voiceType
;
}
public
Integer
getVolume
()
{
return
volume
;
}
public
void
setVolume
(
Integer
volume
)
{
this
.
volume
=
volume
;
}
}
src/main/java/cn/com/poc/expose/websocket/exception/WebsocketException.java
0 → 100644
View file @
cbfb29ad
package
cn
.
com
.
poc
.
expose
.
websocket
.
exception
;
import
cn.com.yict.framemax.core.exception.ErrorCoded
;
import
org.slf4j.MDC
;
import
java.io.Serializable
;
/**
* @author alex.yao
* @date 2023/12/15
**/
public
class
WebsocketException
extends
RuntimeException
implements
ErrorCoded
{
private
static
final
long
serialVersionUID
=
2332618265610125980L
;
private
final
String
LOG_KEY
=
"log_trace_id"
;
private
Serializable
errorCode
=
-
1
;
private
String
traceId
;
public
WebsocketException
()
{
super
();
}
public
WebsocketException
(
Throwable
cause
)
{
super
(
cause
);
}
public
WebsocketException
(
String
message
)
{
super
(
message
);
this
.
traceId
=
MDC
.
get
(
LOG_KEY
);
}
public
WebsocketException
(
Serializable
code
,
String
message
)
{
super
(
message
);
this
.
errorCode
=
code
;
this
.
traceId
=
MDC
.
get
(
LOG_KEY
);
}
public
WebsocketException
(
String
message
,
String
traceId
)
{
super
(
message
);
this
.
traceId
=
traceId
;
}
public
WebsocketException
(
Serializable
code
,
String
message
,
String
traceId
)
{
super
(
message
);
this
.
errorCode
=
code
;
this
.
traceId
=
traceId
;
}
@Override
public
Serializable
getErrorCode
()
{
return
this
.
errorCode
;
}
@Override
public
String
getMessage
()
{
return
super
.
getMessage
();
}
@Override
public
String
toString
()
{
return
"{\"code\":"
+
"\""
+
errorCode
+
"\" ,\"message\":"
+
"\""
+
super
.
getMessage
()
+
"\" ,\"traceId\":"
+
"\""
+
traceId
+
"\"}"
;
}
}
src/main/java/cn/com/poc/expose/websocket/handler/AbstractWsHandler.java
0 → 100644
View file @
cbfb29ad
package
cn
.
com
.
poc
.
expose
.
websocket
.
handler
;
import
org.java_websocket.WebSocket
;
/**
* @author alex.yao
* @date 2023/12/7
**/
public
abstract
class
AbstractWsHandler
{
public
abstract
void
doHandler
(
WebSocket
webSocket
,
String
message
);
}
src/main/java/cn/com/poc/expose/websocket/handler/TextToSpeechTencentHandler.java
0 → 100644
View file @
cbfb29ad
package
cn
.
com
.
poc
.
expose
.
websocket
.
handler
;
import
cn.com.poc.common.service.BosConfigService
;
import
cn.com.poc.common.utils.*
;
import
cn.com.poc.expose.websocket.dto.TextToSpeechTencentResponse
;
import
cn.com.poc.expose.websocket.exception.WebsocketException
;
import
cn.com.yict.framemax.core.config.Config
;
import
cn.com.yict.framemax.core.exception.BusinessException
;
import
cn.com.yict.framemax.core.i18n.I18nUtils
;
import
com.tencent.SpeechClient
;
import
com.tencent.tts.model.SpeechSynthesisRequest
;
import
com.tencent.tts.model.SpeechSynthesisResponse
;
import
com.tencent.tts.service.SpeechSynthesisListener
;
import
com.tencent.tts.service.SpeechSynthesizer
;
import
org.java_websocket.WebSocket
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.util.ArrayList
;
import
java.util.Base64
;
import
java.util.List
;
import
java.util.concurrent.atomic.AtomicInteger
;
public
class
TextToSpeechTencentHandler
extends
AbstractWsHandler
{
final
Logger
logger
=
LoggerFactory
.
getLogger
(
TextToSpeechTencentHandler
.
class
);
private
SpeechSynthesizer
speechSynthesizer
;
private
BosConfigService
bosConfigService
;
@Override
public
void
doHandler
(
WebSocket
webSocket
,
String
message
)
{
try
{
bosConfigService
=
SpringUtils
.
getBean
(
BosConfigService
.
class
);
TextToSpeechTencentResponse
response
=
JsonUtils
.
deSerialize
(
message
,
TextToSpeechTencentResponse
.
class
);
if
(
response
==
null
)
{
throw
new
WebsocketException
(
"arg cannot null"
);
}
if
(
StringUtils
.
isBlank
(
response
.
getContent
()))
{
throw
new
WebsocketException
(
"content cannot null"
);
}
initTTS
(
webSocket
,
response
);
textToSpeech
(
response
.
getContent
());
}
catch
(
Exception
e
)
{
WebsocketException
websocketException
=
new
WebsocketException
(
e
);
webSocket
.
send
(
websocketException
.
getMessage
());
throw
websocketException
;
}
}
/**
* 调用TTS
*/
private
void
textToSpeech
(
String
text
)
{
this
.
speechSynthesizer
.
synthesisLongText
(
text
);
}
/**
* 初始化TTS
*/
private
void
initTTS
(
WebSocket
webSocket
,
TextToSpeechTencentResponse
textToSpeechTencentResponse
)
throws
IOException
{
//从配置文件读取密钥
String
appId
=
Config
.
get
(
"tencent.speech.synthesizer.appid"
);
String
secretId
=
Config
.
get
(
"tencent.speech.synthesizer.secretId"
);
String
secretKey
=
Config
.
get
(
"tencent.speech.synthesizer.secretKey"
);
//创建SpeechSynthesizerClient实例,目前是单例
SpeechClient
client
=
SpeechClient
.
newInstance
(
appId
,
secretId
,
secretKey
);
//初始化SpeechSynthesizerRequest,SpeechSynthesizerRequest包含请求参数
SpeechSynthesisRequest
request
=
SpeechSynthesisRequest
.
initialize
();
request
.
setSampleRate
(
textToSpeechTencentResponse
.
getSampleRate
());
request
.
setSpeed
(
textToSpeechTencentResponse
.
getSpeed
());
request
.
setCodec
(
textToSpeechTencentResponse
.
getCodec
());
request
.
setVolume
(
textToSpeechTencentResponse
.
getVolume
());
request
.
setVoiceType
(
textToSpeechTencentResponse
.
getVoiceType
());
//使用客户端client创建语音合成实例
if
(
"wav"
.
equals
(
textToSpeechTencentResponse
.
getCodec
()))
{
request
.
setCodec
(
"pcm"
);
}
speechSynthesizer
=
client
.
newSpeechSynthesizer
(
request
,
new
SpeechSynthesisListener
()
{
List
<
byte
[]>
audioBytes
=
new
ArrayList
<>();
AtomicInteger
sessionId
=
new
AtomicInteger
(
0
);
File
tempAudioFile
=
File
.
createTempFile
(
UUIDTool
.
getUUID
(),
textToSpeechTencentResponse
.
getCodec
());
AtomicInteger
count
=
new
AtomicInteger
(
0
);
@Override
public
void
onComplete
(
SpeechSynthesisResponse
response
)
{
logger
.
info
(
"onComplete"
);
try
(
FileOutputStream
fileOutputStream
=
new
FileOutputStream
(
tempAudioFile
,
true
))
{
for
(
byte
[]
audioByte
:
audioBytes
)
{
fileOutputStream
.
write
(
audioByte
);
}
}
catch
(
IOException
e
)
{
logger
.
error
(
"onComplete:{}"
,
e
.
getMessage
());
}
Path
path
=
tempAudioFile
.
toPath
();
if
(
"wav"
.
equals
(
textToSpeechTencentResponse
.
getCodec
()))
{
try
{
path
=
PcmToWav
.
convertAudioFiles
(
tempAudioFile
.
getPath
());
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
//上传音频
try
(
InputStream
fileInputStream
=
Files
.
newInputStream
(
path
);)
{
String
uploadUrl
=
bosConfigService
.
upload
(
fileInputStream
,
textToSpeechTencentResponse
.
getCodec
(),
null
);
webSocket
.
send
(
"{\"replyVoiceUrl\":\""
+
uploadUrl
+
"\"}"
);
}
catch
(
Exception
e
)
{
throw
new
BusinessException
(
e
);
}
webSocket
.
send
(
"{\"final\":true}"
);
webSocket
.
close
();
}
@Override
public
void
onMessage
(
byte
[]
data
)
{
//发送音频
sessionId
.
incrementAndGet
();
Base64
.
Encoder
encoder
=
Base64
.
getEncoder
();
String
base64
=
encoder
.
encodeToString
(
data
);
webSocket
.
send
(
"{\"sessionId\":"
+
count
.
get
()
+
",\"audio\":\""
+
base64
+
"\"}"
);
audioBytes
.
add
(
data
);
}
@Override
public
void
onFail
(
SpeechSynthesisResponse
response
)
{
logger
.
warn
(
"onFail:{}"
,
response
.
getMessage
());
WebsocketException
websocketException
=
new
WebsocketException
(
response
.
getMessage
());
webSocket
.
send
(
websocketException
.
toString
());
webSocket
.
close
();
throw
websocketException
;
}
});
}
}
src/main/java/cn/com/poc/expose/websocket/holder/WSHandlerHolder.java
0 → 100644
View file @
cbfb29ad
package
cn
.
com
.
poc
.
expose
.
websocket
.
holder
;
import
cn.com.poc.expose.websocket.handler.AbstractWsHandler
;
/**
* @author alex.yao
* @date 2024/3/19 22:50
*/
public
class
WSHandlerHolder
{
private
final
static
ThreadLocal
<
AbstractWsHandler
>
WS_HANDLER_HOLDER
=
new
ThreadLocal
<>();
public
static
AbstractWsHandler
get
(){
return
WS_HANDLER_HOLDER
.
get
();
}
public
static
void
set
(
AbstractWsHandler
abstractWsHandler
){
WS_HANDLER_HOLDER
.
set
(
abstractWsHandler
);
}
public
static
void
clear
(){
WS_HANDLER_HOLDER
.
remove
();
}
}
src/main/java/cn/com/poc/expose/websocket/init/SuperLinkWSRun.java
0 → 100644
View file @
cbfb29ad
package
cn
.
com
.
poc
.
expose
.
websocket
.
init
;
import
cn.com.poc.expose.websocket.SuperLinkWebSocketServer
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
/**
* @author alex.yao
* @date 2023/12/7
**/
@Component
public
class
SuperLinkWSRun
implements
InitializingBean
{
@Resource
private
SuperLinkWebSocketServer
superLinkWebSocketServer
;
@Override
public
void
afterPropertiesSet
()
throws
Exception
{
if
(!
superLinkWebSocketServer
.
isRun
())
{
superLinkWebSocketServer
.
start
();
}
}
}
src/main/java/cn/com/poc/message/service/impl/AgentApplicationConsumerServiceImpl.java
View file @
cbfb29ad
...
@@ -2,12 +2,10 @@ package cn.com.poc.message.service.impl;
...
@@ -2,12 +2,10 @@ package cn.com.poc.message.service.impl;
import
cn.com.poc.agent_application.aggregate.AgentApplicationMallService
;
import
cn.com.poc.agent_application.aggregate.AgentApplicationMallService
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationPublishEntity
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationPublishEntity
;
import
cn.com.poc.agent_application.service.BizAgentApplicationDialoguesRecordService
;
import
cn.com.poc.agent_application.service.BizAgentApplicationPublishService
;
import
cn.com.poc.agent_application.service.BizAgentApplicationPublishService
;
import
cn.com.poc.message.entity.AgentApplicationClickEventMessage
;
import
cn.com.poc.message.entity.AgentApplicationClickEventMessage
;
import
cn.com.poc.message.service.AgentApplicationConsumerService
;
import
cn.com.poc.message.service.AgentApplicationConsumerService
;
import
cn.com.poc.message.topic.AgentApplicationTopic
;
import
cn.com.poc.message.topic.AgentApplicationTopic
;
import
cn.com.yict.framemax.core.service.BaseService
;
import
cn.com.yict.framemax.tumbleweed.client.annotation.Consumer
;
import
cn.com.yict.framemax.tumbleweed.client.annotation.Consumer
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
...
src/main/java/cn/com/poc/support/dgTools/DgtoolsAbstractHttpClient.java
View file @
cbfb29ad
...
@@ -3,7 +3,7 @@ package cn.com.poc.support.dgTools;
...
@@ -3,7 +3,7 @@ package cn.com.poc.support.dgTools;
import
cn.com.poc.common.constant.FmxParamConfigConstant
;
import
cn.com.poc.common.constant.FmxParamConfigConstant
;
import
cn.com.poc.common.utils.ListUtils
;
import
cn.com.poc.common.utils.ListUtils
;
import
cn.com.poc.common.utils.http.LocalHttpClient
;
import
cn.com.poc.common.utils.http.LocalHttpClient
;
import
cn.com.poc.thirdparty.resource.demand.ai.
common.DgtoolsApiConstants
;
import
cn.com.poc.thirdparty.resource.demand.ai.
route.DgtoolsApiRoute
;
import
cn.com.poc.support.dgTools.request.AbstractParam
;
import
cn.com.poc.support.dgTools.request.AbstractParam
;
import
cn.com.poc.support.dgTools.request.AbstractRequest
;
import
cn.com.poc.support.dgTools.request.AbstractRequest
;
import
cn.com.poc.support.dgTools.request.ProjectTokenRequest
;
import
cn.com.poc.support.dgTools.request.ProjectTokenRequest
;
...
@@ -117,8 +117,8 @@ public class DgtoolsAbstractHttpClient {
...
@@ -117,8 +117,8 @@ public class DgtoolsAbstractHttpClient {
}
}
HttpUriRequest
httpUriRequest
=
post
HttpUriRequest
httpUriRequest
=
post
.
setHeader
(
DgtoolsApi
Constants
.
JSON_HEADER
)
.
setHeader
(
DgtoolsApi
Route
.
JSON_HEADER
)
.
setUri
(
dgtoolsDomainurl
+
DgtoolsApi
Constants
.
BASE_URL
+
url
)
.
setUri
(
dgtoolsDomainurl
+
DgtoolsApi
Route
.
BASE_URL
+
url
)
.
setEntity
(
new
StringEntity
(
json
,
StandardCharsets
.
UTF_8
))
.
setEntity
(
new
StringEntity
(
json
,
StandardCharsets
.
UTF_8
))
.
build
();
.
build
();
DgtoolsApiResult
dgtoolsApiResult
=
LocalHttpClient
.
executeJsonResult
(
httpUriRequest
,
DgtoolsApiResult
.
class
);
DgtoolsApiResult
dgtoolsApiResult
=
LocalHttpClient
.
executeJsonResult
(
httpUriRequest
,
DgtoolsApiResult
.
class
);
...
...
src/main/java/cn/com/poc/support/dgTools/service/impl/AuthorizationServiceImpl.java
View file @
cbfb29ad
...
@@ -4,7 +4,7 @@ import cn.com.poc.common.constant.FmxParamConfigConstant;
...
@@ -4,7 +4,7 @@ import cn.com.poc.common.constant.FmxParamConfigConstant;
import
cn.com.poc.common.constant.MkpRedisKeyConstant
;
import
cn.com.poc.common.constant.MkpRedisKeyConstant
;
import
cn.com.poc.common.service.RedisService
;
import
cn.com.poc.common.service.RedisService
;
import
cn.com.poc.support.dgTools.DgtoolsAbstractHttpClient
;
import
cn.com.poc.support.dgTools.DgtoolsAbstractHttpClient
;
import
cn.com.poc.thirdparty.resource.demand.ai.
common.DgtoolsApiConstants
;
import
cn.com.poc.thirdparty.resource.demand.ai.
route.DgtoolsApiRoute
;
import
cn.com.poc.support.dgTools.request.ProjectTokenRequest
;
import
cn.com.poc.support.dgTools.request.ProjectTokenRequest
;
import
cn.com.poc.support.dgTools.result.ProjectTokenResult
;
import
cn.com.poc.support.dgTools.result.ProjectTokenResult
;
import
cn.com.poc.support.dgTools.service.AuthorizationService
;
import
cn.com.poc.support.dgTools.service.AuthorizationService
;
...
@@ -51,8 +51,8 @@ public class AuthorizationServiceImpl implements AuthorizationService {
...
@@ -51,8 +51,8 @@ public class AuthorizationServiceImpl implements AuthorizationService {
request
.
setProjectKey
(
projectKey
);
request
.
setProjectKey
(
projectKey
);
request
.
setProjectSecret
(
projectSecret
);
request
.
setProjectSecret
(
projectSecret
);
List
<
Header
>
headers
=
new
ArrayList
<>();
List
<
Header
>
headers
=
new
ArrayList
<>();
headers
.
add
(
DgtoolsApi
Constants
.
PAY_HEADER
);
headers
.
add
(
DgtoolsApi
Route
.
PAY_HEADER
);
ProjectTokenResult
projectTokenResult
=
dgToolsAbstractHttpClient
.
doRequest
(
DgtoolsApi
Constants
.
GET_APP_TOKEN
,
request
,
headers
);
ProjectTokenResult
projectTokenResult
=
dgToolsAbstractHttpClient
.
doRequest
(
DgtoolsApi
Route
.
GET_APP_TOKEN
,
request
,
headers
);
return
projectTokenResult
.
getAppToken
();
return
projectTokenResult
.
getAppToken
();
}
}
...
...
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/aggregate/impl/AICreateImageServiceImpl.java
View file @
cbfb29ad
...
@@ -8,7 +8,7 @@ import cn.com.poc.thirdparty.resource.demand.ai.entity.OpenAiResult;
...
@@ -8,7 +8,7 @@ import cn.com.poc.thirdparty.resource.demand.ai.entity.OpenAiResult;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.generations.*
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.generations.*
;
import
cn.com.poc.thirdparty.resource.demand.member.service.DemandAuthService
;
import
cn.com.poc.thirdparty.resource.demand.member.service.DemandAuthService
;
import
cn.com.poc.support.dgTools.DgtoolsAbstractHttpClient
;
import
cn.com.poc.support.dgTools.DgtoolsAbstractHttpClient
;
import
cn.com.poc.thirdparty.resource.demand.ai.
common.DgtoolsApiConstants
;
import
cn.com.poc.thirdparty.resource.demand.ai.
route.DgtoolsApiRoute
;
import
cn.com.yict.framemax.core.i18n.I18nMessageException
;
import
cn.com.yict.framemax.core.i18n.I18nMessageException
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
...
@@ -84,10 +84,10 @@ public class AICreateImageServiceImpl implements AICreateImageService {
...
@@ -84,10 +84,10 @@ public class AICreateImageServiceImpl implements AICreateImageService {
Assert
.
isTrue
(
request
.
getN
()
<=
10
&&
request
.
getN
()
>=
1
,
"The number of images to generate. Must be between 1 and 10."
);
Assert
.
isTrue
(
request
.
getN
()
<=
10
&&
request
.
getN
()
>=
1
,
"The number of images to generate. Must be between 1 and 10."
);
List
<
Header
>
headers
=
new
ArrayList
<>();
List
<
Header
>
headers
=
new
ArrayList
<>();
headers
.
add
(
DgtoolsApi
Constants
.
JSON_HEADER
);
headers
.
add
(
DgtoolsApi
Route
.
JSON_HEADER
);
headers
.
add
(
DgtoolsApi
Constants
.
AI_HEADER
);
headers
.
add
(
DgtoolsApi
Route
.
AI_HEADER
);
headers
.
add
(
new
BasicHeader
(
DgtoolsApi
Constants
.
HEADER_X_PLATFORM_AUTHORIZATION
,
demandAuthService
.
getToken
()));
headers
.
add
(
new
BasicHeader
(
DgtoolsApi
Route
.
HEADER_X_PLATFORM_AUTHORIZATION
,
demandAuthService
.
getToken
()));
OpenAiResult
openAiResult
=
dgToolsAbstractHttpClient
.
doRequest
(
DgtoolsApi
Constants
.
DgtoolsAI
.
AI_OPENAI_CREATE_IMAGE
,
request
,
headers
);
OpenAiResult
openAiResult
=
dgToolsAbstractHttpClient
.
doRequest
(
DgtoolsApi
Route
.
DgtoolsAI
.
AI_OPENAI_CREATE_IMAGE
,
request
,
headers
);
if
(
openAiResult
!=
null
)
{
if
(
openAiResult
!=
null
)
{
GenerationsResult
generationsResult
=
JSONObject
.
parseObject
(
openAiResult
.
getMessage
(),
GenerationsResult
.
class
);
GenerationsResult
generationsResult
=
JSONObject
.
parseObject
(
openAiResult
.
getMessage
(),
GenerationsResult
.
class
);
return
generationsResult
;
return
generationsResult
;
...
@@ -114,10 +114,10 @@ public class AICreateImageServiceImpl implements AICreateImageService {
...
@@ -114,10 +114,10 @@ public class AICreateImageServiceImpl implements AICreateImageService {
Assert
.
isTrue
(
request
.
getNum
()
<=
6
&&
request
.
getNum
()
>=
1
,
"图片生成数量,支持1-6张"
);
Assert
.
isTrue
(
request
.
getNum
()
<=
6
&&
request
.
getNum
()
>=
1
,
"图片生成数量,支持1-6张"
);
List
<
Header
>
headers
=
new
ArrayList
<>();
List
<
Header
>
headers
=
new
ArrayList
<>();
headers
.
add
(
DgtoolsApi
Constants
.
JSON_HEADER
);
headers
.
add
(
DgtoolsApi
Route
.
JSON_HEADER
);
headers
.
add
(
DgtoolsApi
Constants
.
AI_HEADER
);
headers
.
add
(
DgtoolsApi
Route
.
AI_HEADER
);
headers
.
add
(
new
BasicHeader
(
DgtoolsApi
Constants
.
HEADER_X_PLATFORM_AUTHORIZATION
,
demandAuthService
.
getToken
()));
headers
.
add
(
new
BasicHeader
(
DgtoolsApi
Route
.
HEADER_X_PLATFORM_AUTHORIZATION
,
demandAuthService
.
getToken
()));
BaiduGetImageResult
baiduGetImageResult
=
dgToolsAbstractHttpClient
.
doRequest
(
DgtoolsApi
Constants
.
DgtoolsAI
.
AI_BAIDU_CREATE_IMAGE
,
request
,
headers
);
BaiduGetImageResult
baiduGetImageResult
=
dgToolsAbstractHttpClient
.
doRequest
(
DgtoolsApi
Route
.
DgtoolsAI
.
AI_BAIDU_CREATE_IMAGE
,
request
,
headers
);
if
(
baiduGetImageResult
!=
null
)
{
if
(
baiduGetImageResult
!=
null
)
{
GenerationsResult
generationsResult
=
new
GenerationsResult
();
GenerationsResult
generationsResult
=
new
GenerationsResult
();
List
<
ImgUrl
>
imgUrls
=
baiduGetImageResult
.
getData
().
getImgUrls
();
List
<
ImgUrl
>
imgUrls
=
baiduGetImageResult
.
getData
().
getImgUrls
();
...
@@ -150,10 +150,10 @@ public class AICreateImageServiceImpl implements AICreateImageService {
...
@@ -150,10 +150,10 @@ public class AICreateImageServiceImpl implements AICreateImageService {
}
}
List
<
Header
>
headers
=
new
ArrayList
<>();
List
<
Header
>
headers
=
new
ArrayList
<>();
headers
.
add
(
DgtoolsApi
Constants
.
JSON_HEADER
);
headers
.
add
(
DgtoolsApi
Route
.
JSON_HEADER
);
headers
.
add
(
DgtoolsApi
Constants
.
AI_HEADER
);
headers
.
add
(
DgtoolsApi
Route
.
AI_HEADER
);
headers
.
add
(
new
BasicHeader
(
DgtoolsApi
Constants
.
HEADER_X_PLATFORM_AUTHORIZATION
,
demandAuthService
.
getToken
()));
headers
.
add
(
new
BasicHeader
(
DgtoolsApi
Route
.
HEADER_X_PLATFORM_AUTHORIZATION
,
demandAuthService
.
getToken
()));
BaiduGetImageV2Result
baiduGetImageV2Result
=
dgToolsAbstractHttpClient
.
doRequest
(
DgtoolsApi
Constants
.
DgtoolsAI
.
AI_BAIDU_CREATE_IMAGE_V2
,
request
,
headers
);
BaiduGetImageV2Result
baiduGetImageV2Result
=
dgToolsAbstractHttpClient
.
doRequest
(
DgtoolsApi
Route
.
DgtoolsAI
.
AI_BAIDU_CREATE_IMAGE_V2
,
request
,
headers
);
if
(
baiduGetImageV2Result
!=
null
)
{
if
(
baiduGetImageV2Result
!=
null
)
{
if
(
FAILED
.
equals
(
baiduGetImageV2Result
.
getData
().
getTaskStatus
()))
{
if
(
FAILED
.
equals
(
baiduGetImageV2Result
.
getData
().
getTaskStatus
()))
{
...
@@ -195,10 +195,10 @@ public class AICreateImageServiceImpl implements AICreateImageService {
...
@@ -195,10 +195,10 @@ public class AICreateImageServiceImpl implements AICreateImageService {
Assert
.
notNull
(
request
.
getPrompt
(),
"文生图配置异常,请联系开发人员"
);
Assert
.
notNull
(
request
.
getPrompt
(),
"文生图配置异常,请联系开发人员"
);
List
<
Header
>
headers
=
new
ArrayList
<>();
List
<
Header
>
headers
=
new
ArrayList
<>();
headers
.
add
(
DgtoolsApi
Constants
.
JSON_HEADER
);
headers
.
add
(
DgtoolsApi
Route
.
JSON_HEADER
);
headers
.
add
(
DgtoolsApi
Constants
.
AI_HEADER
);
headers
.
add
(
DgtoolsApi
Route
.
AI_HEADER
);
headers
.
add
(
new
BasicHeader
(
DgtoolsApi
Constants
.
HEADER_X_PLATFORM_AUTHORIZATION
,
demandAuthService
.
getToken
()));
headers
.
add
(
new
BasicHeader
(
DgtoolsApi
Route
.
HEADER_X_PLATFORM_AUTHORIZATION
,
demandAuthService
.
getToken
()));
BaiduAISailsText2ImageResult
imageResult
=
dgToolsAbstractHttpClient
.
doRequest
(
DgtoolsApi
Constants
.
DgtoolsAI
.
AI_BAIDU_SAILS_TEXT_CREATE_IMAGE
,
request
,
headers
);
BaiduAISailsText2ImageResult
imageResult
=
dgToolsAbstractHttpClient
.
doRequest
(
DgtoolsApi
Route
.
DgtoolsAI
.
AI_BAIDU_SAILS_TEXT_CREATE_IMAGE
,
request
,
headers
);
if
(
imageResult
==
null
)
{
if
(
imageResult
==
null
)
{
throw
new
I18nMessageException
(
"exception/middle.platform.is.unresponsive"
);
throw
new
I18nMessageException
(
"exception/middle.platform.is.unresponsive"
);
}
}
...
@@ -234,10 +234,10 @@ public class AICreateImageServiceImpl implements AICreateImageService {
...
@@ -234,10 +234,10 @@ public class AICreateImageServiceImpl implements AICreateImageService {
String
jsonBody
=
dgToolsAbstractHttpClient
.
buildJson
(
request
);
String
jsonBody
=
dgToolsAbstractHttpClient
.
buildJson
(
request
);
CloseableHttpClient
httpClient
=
HttpClients
.
createDefault
();
CloseableHttpClient
httpClient
=
HttpClients
.
createDefault
();
CloseableHttpResponse
httpResponse
=
httpClient
.
execute
(
RequestBuilder
.
create
(
POST
)
CloseableHttpResponse
httpResponse
=
httpClient
.
execute
(
RequestBuilder
.
create
(
POST
)
.
setUri
(
DOMAIN_URL
+
DgtoolsApi
Constants
.
BASE_URL
+
DgtoolsApiConstants
.
DgtoolsAI
.
AI_BAIDU_SAILS_IMAGE_CREATE_TEXT
)
.
setUri
(
DOMAIN_URL
+
DgtoolsApi
Route
.
BASE_URL
+
DgtoolsApiRoute
.
DgtoolsAI
.
AI_BAIDU_SAILS_IMAGE_CREATE_TEXT
)
.
addHeader
(
DgtoolsApi
Constants
.
JSON_HEADER
)
.
addHeader
(
DgtoolsApi
Route
.
JSON_HEADER
)
.
addHeader
(
DgtoolsApi
Constants
.
AI_HEADER
)
.
addHeader
(
DgtoolsApi
Route
.
AI_HEADER
)
.
addHeader
(
new
BasicHeader
(
DgtoolsApi
Constants
.
HEADER_X_PLATFORM_AUTHORIZATION
,
demandAuthService
.
getToken
()))
.
addHeader
(
new
BasicHeader
(
DgtoolsApi
Route
.
HEADER_X_PLATFORM_AUTHORIZATION
,
demandAuthService
.
getToken
()))
.
setEntity
(
new
StringEntity
(
jsonBody
,
StandardCharsets
.
UTF_8
))
.
setEntity
(
new
StringEntity
(
jsonBody
,
StandardCharsets
.
UTF_8
))
.
build
()
.
build
()
);
);
...
...
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/aggregate/impl/AIDialogueServiceImpl.java
View file @
cbfb29ad
...
@@ -8,7 +8,7 @@ import cn.com.poc.thirdparty.resource.demand.ai.entity.largemodel.LargeModelDema
...
@@ -8,7 +8,7 @@ import cn.com.poc.thirdparty.resource.demand.ai.entity.largemodel.LargeModelDema
import
cn.com.poc.thirdparty.resource.demand.ai.entity.largemodel.LargeModelResponse
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.largemodel.LargeModelResponse
;
import
cn.com.poc.thirdparty.resource.demand.member.service.DemandAuthService
;
import
cn.com.poc.thirdparty.resource.demand.member.service.DemandAuthService
;
import
cn.com.poc.support.dgTools.DgtoolsAbstractHttpClient
;
import
cn.com.poc.support.dgTools.DgtoolsAbstractHttpClient
;
import
cn.com.poc.thirdparty.resource.demand.ai.
common.DgtoolsApiConstants
;
import
cn.com.poc.thirdparty.resource.demand.ai.
route.DgtoolsApiRoute
;
import
org.apache.http.Header
;
import
org.apache.http.Header
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.apache.http.client.methods.RequestBuilder
;
import
org.apache.http.client.methods.RequestBuilder
;
...
@@ -70,12 +70,12 @@ public class AIDialogueServiceImpl implements AIDialogueService {
...
@@ -70,12 +70,12 @@ public class AIDialogueServiceImpl implements AIDialogueService {
@Override
@Override
public
FunctionCallResult
functionCall
(
FunctionCallResponse
response
)
{
public
FunctionCallResult
functionCall
(
FunctionCallResponse
response
)
{
String
url
=
DgtoolsApi
Constants
.
DgtoolsAI
.
FUNCTION_CALL
;
String
url
=
DgtoolsApi
Route
.
DgtoolsAI
.
FUNCTION_CALL
;
response
.
setApiKey
(
API_KEY
);
response
.
setApiKey
(
API_KEY
);
List
<
Header
>
headers
=
new
ArrayList
<
Header
>()
{{
List
<
Header
>
headers
=
new
ArrayList
<
Header
>()
{{
add
(
DgtoolsApi
Constants
.
JSON_HEADER
);
add
(
DgtoolsApi
Route
.
JSON_HEADER
);
add
(
DgtoolsApi
Constants
.
AI_HEADER
);
add
(
DgtoolsApi
Route
.
AI_HEADER
);
add
(
new
BasicHeader
(
DgtoolsApi
Constants
.
HEADER_X_PLATFORM_AUTHORIZATION
,
demandAuthService
.
getToken
()));
add
(
new
BasicHeader
(
DgtoolsApi
Route
.
HEADER_X_PLATFORM_AUTHORIZATION
,
demandAuthService
.
getToken
()));
}};
}};
return
dgToolsAbstractHttpClient
.
doRequest
(
url
,
response
,
headers
);
return
dgToolsAbstractHttpClient
.
doRequest
(
url
,
response
,
headers
);
}
}
...
@@ -84,10 +84,10 @@ public class AIDialogueServiceImpl implements AIDialogueService {
...
@@ -84,10 +84,10 @@ public class AIDialogueServiceImpl implements AIDialogueService {
String
jsonBody
=
dgToolsAbstractHttpClient
.
buildJson
(
request
);
String
jsonBody
=
dgToolsAbstractHttpClient
.
buildJson
(
request
);
CloseableHttpClient
httpClient
=
HttpClients
.
createDefault
();
CloseableHttpClient
httpClient
=
HttpClients
.
createDefault
();
CloseableHttpResponse
httpResponse
=
httpClient
.
execute
(
RequestBuilder
.
create
(
POST
)
CloseableHttpResponse
httpResponse
=
httpClient
.
execute
(
RequestBuilder
.
create
(
POST
)
.
setUri
(
DOMAIN_URL
+
DgtoolsApi
Constants
.
BASE_URL
+
DgtoolsApiConstants
.
DgtoolsAI
.
LARGE_MODEL
)
.
setUri
(
DOMAIN_URL
+
DgtoolsApi
Route
.
BASE_URL
+
DgtoolsApiRoute
.
DgtoolsAI
.
LARGE_MODEL
)
.
addHeader
(
DgtoolsApi
Constants
.
JSON_HEADER
)
.
addHeader
(
DgtoolsApi
Route
.
JSON_HEADER
)
.
addHeader
(
DgtoolsApi
Constants
.
AI_HEADER
)
.
addHeader
(
DgtoolsApi
Route
.
AI_HEADER
)
.
addHeader
(
new
BasicHeader
(
DgtoolsApi
Constants
.
HEADER_X_PLATFORM_AUTHORIZATION
,
demandAuthService
.
getToken
()))
.
addHeader
(
new
BasicHeader
(
DgtoolsApi
Route
.
HEADER_X_PLATFORM_AUTHORIZATION
,
demandAuthService
.
getToken
()))
.
setEntity
(
new
StringEntity
(
jsonBody
,
StandardCharsets
.
UTF_8
))
.
setEntity
(
new
StringEntity
(
jsonBody
,
StandardCharsets
.
UTF_8
))
.
build
()
.
build
()
);
);
...
@@ -97,11 +97,11 @@ public class AIDialogueServiceImpl implements AIDialogueService {
...
@@ -97,11 +97,11 @@ public class AIDialogueServiceImpl implements AIDialogueService {
}
}
private
LargeModelDemandResult
largeModelRequest
(
LargeModelDemandResponse
request
)
{
private
LargeModelDemandResult
largeModelRequest
(
LargeModelDemandResponse
request
)
{
String
url
=
DgtoolsApi
Constants
.
DgtoolsAI
.
LARGE_MODEL
;
String
url
=
DgtoolsApi
Route
.
DgtoolsAI
.
LARGE_MODEL
;
List
<
Header
>
headers
=
new
ArrayList
<
Header
>()
{{
List
<
Header
>
headers
=
new
ArrayList
<
Header
>()
{{
add
(
DgtoolsApi
Constants
.
JSON_HEADER
);
add
(
DgtoolsApi
Route
.
JSON_HEADER
);
add
(
DgtoolsApi
Constants
.
AI_HEADER
);
add
(
DgtoolsApi
Route
.
AI_HEADER
);
add
(
new
BasicHeader
(
DgtoolsApi
Constants
.
HEADER_X_PLATFORM_AUTHORIZATION
,
demandAuthService
.
getToken
()));
add
(
new
BasicHeader
(
DgtoolsApi
Route
.
HEADER_X_PLATFORM_AUTHORIZATION
,
demandAuthService
.
getToken
()));
}};
}};
return
dgToolsAbstractHttpClient
.
doRequest
(
url
,
request
,
headers
);
return
dgToolsAbstractHttpClient
.
doRequest
(
url
,
request
,
headers
);
}
}
...
...
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/aggregate/impl/DemandKnowledgeServiceImpl.java
View file @
cbfb29ad
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
aggregate
.
impl
;
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
aggregate
.
impl
;
import
cn.com.poc.support.dgTools.DgtoolsAbstractHttpClient
;
import
cn.com.poc.support.dgTools.DgtoolsAbstractHttpClient
;
import
cn.com.poc.thirdparty.resource.demand.ai.
common.DgtoolsApiConstants
;
import
cn.com.poc.thirdparty.resource.demand.ai.
route.DgtoolsApiRoute
;
import
cn.com.poc.support.dgTools.result.AbstractResult
;
import
cn.com.poc.support.dgTools.result.AbstractResult
;
import
cn.com.poc.thirdparty.resource.demand.ai.aggregate.DemandKnowledgeService
;
import
cn.com.poc.thirdparty.resource.demand.ai.aggregate.DemandKnowledgeService
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.knowledge.*
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.knowledge.*
;
...
@@ -33,7 +33,7 @@ public class DemandKnowledgeServiceImpl implements DemandKnowledgeService {
...
@@ -33,7 +33,7 @@ public class DemandKnowledgeServiceImpl implements DemandKnowledgeService {
TrainKnowledgeRequest
request
=
new
TrainKnowledgeRequest
();
TrainKnowledgeRequest
request
=
new
TrainKnowledgeRequest
();
request
.
setDocumentUrl
(
fileURL
);
request
.
setDocumentUrl
(
fileURL
);
request
.
setSegmentationConfig
(
segmentationConfig
);
request
.
setSegmentationConfig
(
segmentationConfig
);
TrainKnowledgeResult
trainKnowledgeResult
=
dgToolsAbstractHttpClient
.
doRequest
(
DgtoolsApi
Constants
.
DgtoolsAI
.
TRAIN_KNOWLEDGE
,
request
,
getHeaders
());
TrainKnowledgeResult
trainKnowledgeResult
=
dgToolsAbstractHttpClient
.
doRequest
(
DgtoolsApi
Route
.
DgtoolsAI
.
TRAIN_KNOWLEDGE
,
request
,
getHeaders
());
if
(
null
==
trainKnowledgeResult
)
{
if
(
null
==
trainKnowledgeResult
)
{
throw
new
I18nMessageException
(
"exception/abnormal.knowledge.base.training"
);
throw
new
I18nMessageException
(
"exception/abnormal.knowledge.base.training"
);
}
}
...
@@ -46,7 +46,7 @@ public class DemandKnowledgeServiceImpl implements DemandKnowledgeService {
...
@@ -46,7 +46,7 @@ public class DemandKnowledgeServiceImpl implements DemandKnowledgeService {
TrainKnowledgeRequest
request
=
new
TrainKnowledgeRequest
();
TrainKnowledgeRequest
request
=
new
TrainKnowledgeRequest
();
request
.
setDocumentUrl
(
fileURL
);
request
.
setDocumentUrl
(
fileURL
);
request
.
setSegmentationConfig
(
segmentationConfig
);
request
.
setSegmentationConfig
(
segmentationConfig
);
TrainKnowledgeResult
trainKnowledgeResult
=
dgToolsAbstractHttpClient
.
doRequest
(
DgtoolsApi
Constants
.
DgtoolsAI
.
TRAIN_KNOWLEDGE_EVENT
,
request
,
getHeaders
());
TrainKnowledgeResult
trainKnowledgeResult
=
dgToolsAbstractHttpClient
.
doRequest
(
DgtoolsApi
Route
.
DgtoolsAI
.
TRAIN_KNOWLEDGE_EVENT
,
request
,
getHeaders
());
if
(
null
==
trainKnowledgeResult
)
{
if
(
null
==
trainKnowledgeResult
)
{
throw
new
I18nMessageException
(
"exception/abnormal.knowledge.base.training"
);
throw
new
I18nMessageException
(
"exception/abnormal.knowledge.base.training"
);
}
}
...
@@ -58,7 +58,7 @@ public class DemandKnowledgeServiceImpl implements DemandKnowledgeService {
...
@@ -58,7 +58,7 @@ public class DemandKnowledgeServiceImpl implements DemandKnowledgeService {
Assert
.
notBlank
(
knowledgeId
);
Assert
.
notBlank
(
knowledgeId
);
TrainKnowledgeStatusRequest
request
=
new
TrainKnowledgeStatusRequest
();
TrainKnowledgeStatusRequest
request
=
new
TrainKnowledgeStatusRequest
();
request
.
setKnowledgeId
(
knowledgeId
);
request
.
setKnowledgeId
(
knowledgeId
);
TrainKnowledgeStatusResult
trainKnowledgeStatusResult
=
dgToolsAbstractHttpClient
.
doRequest
(
DgtoolsApi
Constants
.
DgtoolsAI
.
TRAIN_KNOWLEDGE_STATUS
,
request
,
getHeaders
());
TrainKnowledgeStatusResult
trainKnowledgeStatusResult
=
dgToolsAbstractHttpClient
.
doRequest
(
DgtoolsApi
Route
.
DgtoolsAI
.
TRAIN_KNOWLEDGE_STATUS
,
request
,
getHeaders
());
if
(
null
==
trainKnowledgeStatusResult
)
{
if
(
null
==
trainKnowledgeStatusResult
)
{
throw
new
I18nMessageException
(
"exception/abnormal.training.status.of.knowledge.base.acquisition"
);
throw
new
I18nMessageException
(
"exception/abnormal.training.status.of.knowledge.base.acquisition"
);
}
}
...
@@ -70,7 +70,7 @@ public class DemandKnowledgeServiceImpl implements DemandKnowledgeService {
...
@@ -70,7 +70,7 @@ public class DemandKnowledgeServiceImpl implements DemandKnowledgeService {
Assert
.
notBlank
(
knowledgeId
);
Assert
.
notBlank
(
knowledgeId
);
DelKnowledgeRequest
request
=
new
DelKnowledgeRequest
();
DelKnowledgeRequest
request
=
new
DelKnowledgeRequest
();
request
.
setKnowledgeId
(
knowledgeId
);
request
.
setKnowledgeId
(
knowledgeId
);
AbstractResult
abstractResult
=
dgToolsAbstractHttpClient
.
doRequest
(
DgtoolsApi
Constants
.
DgtoolsAI
.
DEL_KNOWLEDGE
,
request
,
getHeaders
());
AbstractResult
abstractResult
=
dgToolsAbstractHttpClient
.
doRequest
(
DgtoolsApi
Route
.
DgtoolsAI
.
DEL_KNOWLEDGE
,
request
,
getHeaders
());
if
(
null
==
abstractResult
)
{
if
(
null
==
abstractResult
)
{
throw
new
I18nMessageException
(
"exception/delete.knowledge.base.exception"
);
throw
new
I18nMessageException
(
"exception/delete.knowledge.base.exception"
);
}
}
...
@@ -89,7 +89,7 @@ public class DemandKnowledgeServiceImpl implements DemandKnowledgeService {
...
@@ -89,7 +89,7 @@ public class DemandKnowledgeServiceImpl implements DemandKnowledgeService {
searchKnowledgeRequest
.
setQuery
(
query
);
searchKnowledgeRequest
.
setQuery
(
query
);
searchKnowledgeRequest
.
setKnowLedgeIds
(
knowledgeIds
);
searchKnowledgeRequest
.
setKnowLedgeIds
(
knowledgeIds
);
searchKnowledgeRequest
.
setTopK
(
topK
);
searchKnowledgeRequest
.
setTopK
(
topK
);
SearchKnowledgeResult
searchKnowledgeResult
=
dgToolsAbstractHttpClient
.
doRequest
(
DgtoolsApi
Constants
.
DgtoolsAI
.
SEARCH_KNOWLEDGE
,
searchKnowledgeRequest
,
getHeaders
());
SearchKnowledgeResult
searchKnowledgeResult
=
dgToolsAbstractHttpClient
.
doRequest
(
DgtoolsApi
Route
.
DgtoolsAI
.
SEARCH_KNOWLEDGE
,
searchKnowledgeRequest
,
getHeaders
());
if
(
null
==
searchKnowledgeResult
)
{
if
(
null
==
searchKnowledgeResult
)
{
throw
new
I18nMessageException
(
"exception/query.knowledge.base.exception"
);
throw
new
I18nMessageException
(
"exception/query.knowledge.base.exception"
);
}
}
...
@@ -104,7 +104,7 @@ public class DemandKnowledgeServiceImpl implements DemandKnowledgeService {
...
@@ -104,7 +104,7 @@ public class DemandKnowledgeServiceImpl implements DemandKnowledgeService {
GetKnowledgeChunkInfoRequest
request
=
new
GetKnowledgeChunkInfoRequest
();
GetKnowledgeChunkInfoRequest
request
=
new
GetKnowledgeChunkInfoRequest
();
request
.
setKnowledgeIds
(
knowledgeIds
);
request
.
setKnowledgeIds
(
knowledgeIds
);
request
.
setQuery
(
query
);
request
.
setQuery
(
query
);
return
dgToolsAbstractHttpClient
.
doRequest
(
DgtoolsApi
Constants
.
DgtoolsAI
.
GET_KNOWLEDGE_CHUNK_INFOS
,
request
,
getHeaders
(),
pagingInfo
);
return
dgToolsAbstractHttpClient
.
doRequest
(
DgtoolsApi
Route
.
DgtoolsAI
.
GET_KNOWLEDGE_CHUNK_INFOS
,
request
,
getHeaders
(),
pagingInfo
);
}
}
@Override
@Override
...
@@ -113,7 +113,7 @@ public class DemandKnowledgeServiceImpl implements DemandKnowledgeService {
...
@@ -113,7 +113,7 @@ public class DemandKnowledgeServiceImpl implements DemandKnowledgeService {
request
.
setKnowledgeId
(
knowledgeId
);
request
.
setKnowledgeId
(
knowledgeId
);
request
.
setChunkRelationId
(
chunkRelationId
);
request
.
setChunkRelationId
(
chunkRelationId
);
request
.
setIsOpen
(
isOpen
);
request
.
setIsOpen
(
isOpen
);
dgToolsAbstractHttpClient
.
doRequest
(
DgtoolsApi
Constants
.
DgtoolsAI
.
OPEN_KNOWLEDGE_CHUNK
,
request
,
getHeaders
());
dgToolsAbstractHttpClient
.
doRequest
(
DgtoolsApi
Route
.
DgtoolsAI
.
OPEN_KNOWLEDGE_CHUNK
,
request
,
getHeaders
());
}
}
@Override
@Override
...
@@ -121,7 +121,7 @@ public class DemandKnowledgeServiceImpl implements DemandKnowledgeService {
...
@@ -121,7 +121,7 @@ public class DemandKnowledgeServiceImpl implements DemandKnowledgeService {
UpsertChunkInfoRequest
request
=
new
UpsertChunkInfoRequest
();
UpsertChunkInfoRequest
request
=
new
UpsertChunkInfoRequest
();
request
.
setKnowledgeId
(
knowledgeId
);
request
.
setKnowledgeId
(
knowledgeId
);
request
.
setChunkRelationId
(
chunkRelationId
);
request
.
setChunkRelationId
(
chunkRelationId
);
dgToolsAbstractHttpClient
.
doRequest
(
DgtoolsApi
Constants
.
DgtoolsAI
.
DELETE_KNOWLEDGE_CHUNK
,
request
,
getHeaders
());
dgToolsAbstractHttpClient
.
doRequest
(
DgtoolsApi
Route
.
DgtoolsAI
.
DELETE_KNOWLEDGE_CHUNK
,
request
,
getHeaders
());
}
}
@Override
@Override
...
@@ -130,7 +130,7 @@ public class DemandKnowledgeServiceImpl implements DemandKnowledgeService {
...
@@ -130,7 +130,7 @@ public class DemandKnowledgeServiceImpl implements DemandKnowledgeService {
request
.
setKnowledgeId
(
knowledgeId
);
request
.
setKnowledgeId
(
knowledgeId
);
request
.
setChunkRelationId
(
chunkRelationId
);
request
.
setChunkRelationId
(
chunkRelationId
);
request
.
setChunkContent
(
content
);
request
.
setChunkContent
(
content
);
dgToolsAbstractHttpClient
.
doRequest
(
DgtoolsApi
Constants
.
DgtoolsAI
.
UPDATE_KNOWLEDGE_CHUNK_DOC
,
request
,
getHeaders
());
dgToolsAbstractHttpClient
.
doRequest
(
DgtoolsApi
Route
.
DgtoolsAI
.
UPDATE_KNOWLEDGE_CHUNK_DOC
,
request
,
getHeaders
());
}
}
@Override
@Override
...
@@ -139,14 +139,14 @@ public class DemandKnowledgeServiceImpl implements DemandKnowledgeService {
...
@@ -139,14 +139,14 @@ public class DemandKnowledgeServiceImpl implements DemandKnowledgeService {
request
.
setKnowledgeId
(
knowledgeId
);
request
.
setKnowledgeId
(
knowledgeId
);
request
.
setChunkSort
(
chunkSort
);
request
.
setChunkSort
(
chunkSort
);
request
.
setChunkContent
(
content
);
request
.
setChunkContent
(
content
);
dgToolsAbstractHttpClient
.
doRequest
(
DgtoolsApi
Constants
.
DgtoolsAI
.
ADD_KNOWLEDGE_CHUNK
,
request
,
getHeaders
());
dgToolsAbstractHttpClient
.
doRequest
(
DgtoolsApi
Route
.
DgtoolsAI
.
ADD_KNOWLEDGE_CHUNK
,
request
,
getHeaders
());
}
}
private
List
<
Header
>
getHeaders
()
{
private
List
<
Header
>
getHeaders
()
{
List
<
Header
>
headers
=
new
ArrayList
<>();
List
<
Header
>
headers
=
new
ArrayList
<>();
headers
.
add
(
DgtoolsApi
Constants
.
JSON_HEADER
);
headers
.
add
(
DgtoolsApi
Route
.
JSON_HEADER
);
headers
.
add
(
DgtoolsApi
Constants
.
AI_HEADER
);
headers
.
add
(
DgtoolsApi
Route
.
AI_HEADER
);
headers
.
add
(
new
BasicHeader
(
DgtoolsApi
Constants
.
HEADER_X_PLATFORM_AUTHORIZATION
,
demandAuthService
.
getToken
()));
headers
.
add
(
new
BasicHeader
(
DgtoolsApi
Route
.
HEADER_X_PLATFORM_AUTHORIZATION
,
demandAuthService
.
getToken
()));
return
headers
;
return
headers
;
}
}
}
}
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/function/AbstractLargeModelFunction.java
View file @
cbfb29ad
...
@@ -8,7 +8,14 @@ import java.util.List;
...
@@ -8,7 +8,14 @@ import java.util.List;
public
abstract
class
AbstractLargeModelFunction
{
public
abstract
class
AbstractLargeModelFunction
{
public
abstract
String
doFunction
(
String
content
,
String
key
);
/**
* 执行函数
*
* @param content 入参
* @param identifier 唯一标识
* @return
*/
public
abstract
String
doFunction
(
String
content
,
String
identifier
);
/**
/**
* 获取函数描述
* 获取函数描述
...
@@ -22,9 +29,11 @@ public abstract class AbstractLargeModelFunction {
...
@@ -22,9 +29,11 @@ public abstract class AbstractLargeModelFunction {
*/
*/
public
abstract
List
<
String
>
getLLMConfig
();
public
abstract
List
<
String
>
getLLMConfig
();
/**
/**
* 获取有关变量的配置
* 获取有关变量的配置
*/
*/
public
abstract
List
<
String
>
getVariableStructureLLMConfig
(
List
<
Variable
>
variableStructure
);
public
abstract
List
<
String
>
getLLMConfig
(
List
<
Variable
>
variableStructure
);
}
}
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/function/LargeModelFunctionEnum.java
View file @
cbfb29ad
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
function
;
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
function
;
import
cn.com.poc.common.utils.SpringUtils
;
import
cn.com.poc.common.utils.SpringUtils
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.document_reader.DocumentReaderFunction
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.document_understanding.DocumentUnderstandIngFunction
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.html_reader.HtmlReaderFunction
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.long_memory.SetLongMemoryFunction
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.long_memory.SetLongMemoryFunction
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.
value_memory.SetValueMemory
Function
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.
memory_variable_writer.MemoryVariableWriter
Function
;
public
enum
LargeModelFunctionEnum
{
public
enum
LargeModelFunctionEnum
{
set_long_memory
(
SetLongMemoryFunction
.
class
),
set_long_memory
(
SetLongMemoryFunction
.
class
),
set_value_memory
(
SetValueMemoryFunction
.
class
),
memory_variable_writer
(
MemoryVariableWriterFunction
.
class
),
html_reader
(
HtmlReaderFunction
.
class
),
document_reader
(
DocumentReaderFunction
.
class
),
document_understanding
(
DocumentUnderstandIngFunction
.
class
),
bing_web_search
(
null
),
;
;
private
Class
<?
extends
AbstractLargeModelFunction
>
function
;
private
Class
<?
extends
AbstractLargeModelFunction
>
function
;
LargeModelFunctionEnum
(
Class
<?
extends
AbstractLargeModelFunction
>
function
)
{
LargeModelFunctionEnum
(
Class
<?
extends
AbstractLargeModelFunction
>
function
)
{
...
@@ -23,4 +31,13 @@ public enum LargeModelFunctionEnum {
...
@@ -23,4 +31,13 @@ public enum LargeModelFunctionEnum {
public
void
setFunction
(
Class
<
AbstractLargeModelFunction
>
function
)
{
public
void
setFunction
(
Class
<
AbstractLargeModelFunction
>
function
)
{
this
.
function
=
function
;
this
.
function
=
function
;
}
}
public
static
LargeModelFunctionEnum
getFunction
(
String
functionName
)
{
for
(
LargeModelFunctionEnum
value
:
LargeModelFunctionEnum
.
values
())
{
if
(
value
.
name
().
equals
(
functionName
))
{
return
value
;
}
}
return
null
;
}
}
}
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/function/document_reader/DocumentReaderFunction.java
0 → 100644
View file @
cbfb29ad
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
function
.
document_reader
;
import
cn.com.poc.agent_application.entity.Variable
;
import
cn.com.poc.common.utils.DocumentLoad
;
import
cn.com.poc.common.utils.JsonUtils
;
import
cn.com.poc.common.utils.StringUtils
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.AbstractLargeModelFunction
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.entity.FunctionLLMConfig
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.entity.Parameters
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.entity.Properties
;
import
cn.hutool.core.collection.ListUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
org.springframework.stereotype.Component
;
import
java.io.File
;
import
java.util.List
;
@Component
public
class
DocumentReaderFunction
extends
AbstractLargeModelFunction
{
private
final
String
DESC
=
"文档阅读器,读取PDF、docx、doc、txt、md格式文件"
;
private
final
FunctionLLMConfig
functionLLMConfig
=
new
FunctionLLMConfig
.
FunctionLLMConfigBuilder
()
.
name
(
"document_reader"
)
.
description
(
DESC
)
.
parameters
(
new
Parameters
(
"object"
)
.
addProperties
(
"file_urls"
,
new
Properties
(
"array"
,
"doc、docx、pdf、txt、md文件地址"
))
).
build
();
@Override
public
String
doFunction
(
String
content
,
String
identifier
)
{
if
(
StringUtils
.
isBlank
(
content
))
{
return
StringUtils
.
EMPTY
;
}
StringBuilder
sb
=
new
StringBuilder
();
JSONObject
jsonObject
=
JSON
.
parseObject
(
content
);
if
(
jsonObject
.
containsKey
(
"file_urls"
))
{
JSONArray
jsonArray
=
jsonObject
.
getJSONArray
(
"file_urls"
);
int
size
=
jsonArray
.
size
();
if
(
size
==
0
)
{
return
StringUtils
.
EMPTY
;
}
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
String
fileUrl
=
jsonArray
.
getString
(
i
);
File
file
=
DocumentLoad
.
downloadURLDocument
(
fileUrl
);
sb
.
append
(
StringUtils
.
LF
).
append
(
"## Document "
).
append
((
i
+
1
)).
append
(
StringUtils
.
LF
);
sb
.
append
(
DocumentLoad
.
documentToText
(
file
));
}
return
sb
.
toString
();
}
return
StringUtils
.
EMPTY
;
}
@Override
public
String
getDesc
()
{
return
DESC
;
}
@Override
public
List
<
String
>
getLLMConfig
()
{
return
ListUtil
.
toList
(
JsonUtils
.
serialize
(
this
.
functionLLMConfig
));
}
@Override
public
List
<
String
>
getLLMConfig
(
List
<
Variable
>
variableStructure
)
{
return
this
.
getLLMConfig
();
}
}
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/function/document_understanding/DocumentUnderstandIngFunction.java
0 → 100644
View file @
cbfb29ad
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
function
.
document_understanding
;
import
cn.com.poc.agent_application.entity.Variable
;
import
cn.com.poc.common.utils.DocumentLoad
;
import
cn.com.poc.common.utils.JsonUtils
;
import
cn.com.poc.common.utils.StringUtils
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.dialogue.Message
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.largemodel.LargeModelDemandResult
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.largemodel.LargeModelResponse
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.AbstractLargeModelFunction
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.entity.FunctionLLMConfig
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.entity.Parameters
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.entity.Properties
;
import
cn.com.poc.thirdparty.service.LLMService
;
import
cn.hutool.core.collection.ListUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.io.File
;
import
java.util.List
;
@Component
public
class
DocumentUnderstandIngFunction
extends
AbstractLargeModelFunction
{
@Resource
private
LLMService
llmService
;
private
final
String
MODEL
=
"Doubao-pro-128k"
;
private
final
String
TEMPLATE
=
"## 任务\n"
+
"你的任务是根据用户提出的问题,并且对于当前长文档内容理解,支持信息检索、摘要总结、文本分析能力。提取或者总结文档中与内容相关的内容。\n"
+
"\n"
+
"## 文档内容\n"
+
"${document_content}"
+
"\n"
+
"## 用户问题\n"
+
"${question}"
;
private
final
String
DESC
=
"长文档内容理解,支持信息检索、摘要总结、文本分析能力。"
;
private
final
FunctionLLMConfig
functionLLMConfig
=
new
FunctionLLMConfig
.
FunctionLLMConfigBuilder
()
.
name
(
"document_understanding"
)
.
description
(
DESC
)
.
parameters
(
new
Parameters
(
"object"
)
.
addProperties
(
"question"
,
new
Properties
(
"string"
,
"提炼用户的问题"
))
.
addProperties
(
"file_url"
,
new
Properties
(
"string"
,
"doc、docx、pdf、txt、md文件地址"
))
).
build
();
@Override
public
String
doFunction
(
String
content
,
String
identifier
)
{
if
(
StringUtils
.
isBlank
(
content
))
{
return
StringUtils
.
EMPTY
;
}
JSONObject
jsonObject
=
JSON
.
parseObject
(
content
);
String
question
=
jsonObject
.
getString
(
"question"
);
String
fileUrl
=
jsonObject
.
getString
(
"file_url"
);
File
file
=
DocumentLoad
.
downloadURLDocument
(
fileUrl
);
String
documentContent
=
DocumentLoad
.
documentToText
(
file
);
Message
message
=
new
Message
();
message
.
setRole
(
"user"
);
message
.
setContent
(
TEMPLATE
.
replace
(
"${document_content}"
,
documentContent
).
replace
(
"${question}"
,
question
));
LargeModelResponse
largeModelResponse
=
new
LargeModelResponse
();
largeModelResponse
.
setModel
(
MODEL
);
largeModelResponse
.
setMessages
(
new
Message
[]{
message
});
largeModelResponse
.
setStream
(
false
);
largeModelResponse
.
setUser
(
"Document_Understanding"
);
LargeModelDemandResult
largeModelDemandResult
=
llmService
.
chat
(
largeModelResponse
);
return
largeModelDemandResult
.
getMessage
();
}
@Override
public
String
getDesc
()
{
return
DESC
;
}
@Override
public
List
<
String
>
getLLMConfig
()
{
return
ListUtil
.
toList
(
JsonUtils
.
serialize
(
this
.
functionLLMConfig
));
}
@Override
public
List
<
String
>
getLLMConfig
(
List
<
Variable
>
variableStructure
)
{
return
this
.
getLLMConfig
();
}
}
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/function/entity/Function.java
0 → 100644
View file @
cbfb29ad
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
function
.
entity
;
public
class
Function
{
/**
* 函数名
*/
private
String
name
;
/**
* 函数参数
*/
private
Parameters
parameters
;
/**
* 函数描述
*/
private
String
description
;
public
Function
()
{
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
Parameters
getParameters
()
{
return
parameters
;
}
public
void
setParameters
(
Parameters
parameters
)
{
this
.
parameters
=
parameters
;
}
public
String
getDescription
()
{
return
description
;
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
}
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/function/entity/FunctionLLMConfig.java
0 → 100644
View file @
cbfb29ad
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
function
.
entity
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
FunctionLLMConfig
{
private
String
type
;
private
String
description
;
private
Function
function
;
public
String
getType
()
{
return
type
;
}
public
String
getDescription
()
{
return
description
;
}
public
Function
getFunction
()
{
return
function
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
public
void
setFunction
(
Function
function
)
{
this
.
function
=
function
;
}
public
static
class
FunctionLLMConfigBuilder
{
private
String
type
=
"function"
;
private
String
description
;
private
Function
function
=
new
Function
();
public
FunctionLLMConfigBuilder
description
(
String
description
)
{
this
.
description
=
description
;
this
.
function
.
setDescription
(
description
);
return
this
;
}
public
FunctionLLMConfigBuilder
name
(
String
name
)
{
this
.
function
.
setName
(
name
);
return
this
;
}
public
FunctionLLMConfigBuilder
parameters
(
Parameters
parameters
)
{
this
.
function
.
setParameters
(
parameters
);
return
this
;
}
public
FunctionLLMConfig
build
()
{
FunctionLLMConfig
config
=
new
FunctionLLMConfig
();
config
.
setType
(
type
);
config
.
setDescription
(
description
);
config
.
setFunction
(
function
);
return
config
;
}
}
}
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/function/entity/Parameters.java
0 → 100644
View file @
cbfb29ad
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
function
.
entity
;
import
java.util.Map
;
public
class
Parameters
{
private
String
type
;
private
Map
<
String
,
Properties
>
properties
;
public
Parameters
(
String
type
)
{
this
.
type
=
type
;
}
public
Parameters
(
String
type
,
Map
<
String
,
Properties
>
properties
)
{
this
.
type
=
type
;
this
.
properties
=
properties
;
}
public
String
getType
()
{
return
type
;
}
public
Map
<
String
,
Properties
>
getProperties
()
{
return
properties
;
}
public
Parameters
addProperties
(
String
key
,
Properties
properties
)
{
if
(
this
.
properties
==
null
)
{
this
.
properties
=
new
java
.
util
.
HashMap
<>();
}
this
.
properties
.
put
(
key
,
properties
);
return
this
;
}
}
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/function/entity/Properties.java
0 → 100644
View file @
cbfb29ad
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
function
.
entity
;
import
com.fasterxml.jackson.annotation.JsonAlias
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
java.util.List
;
@JsonInclude
(
JsonInclude
.
Include
.
NON_NULL
)
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
Properties
{
private
String
type
;
private
String
description
;
@JsonAlias
(
"enum"
)
private
List
<
String
>
enums
;
public
Properties
(
String
type
,
String
description
)
{
this
.
type
=
type
;
this
.
description
=
description
;
}
public
Properties
(
String
type
,
String
description
,
List
<
String
>
enums
)
{
this
.
type
=
type
;
this
.
description
=
description
;
this
.
enums
=
enums
;
}
public
String
getType
()
{
return
type
;
}
public
String
getDescription
()
{
return
description
;
}
public
List
<
String
>
getEnums
()
{
return
enums
;
}
}
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/function/html_reader/HtmlReaderFunction.java
0 → 100644
View file @
cbfb29ad
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
function
.
html_reader
;
import
cn.com.poc.agent_application.entity.Variable
;
import
cn.com.poc.common.utils.DocumentLoad
;
import
cn.com.poc.common.utils.JsonUtils
;
import
cn.com.poc.common.utils.StringUtils
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.AbstractLargeModelFunction
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.entity.FunctionLLMConfig
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.entity.Parameters
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.entity.Properties
;
import
cn.hutool.core.collection.ListUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
org.springframework.stereotype.Component
;
import
java.util.List
;
@Component
public
class
HtmlReaderFunction
extends
AbstractLargeModelFunction
{
private
final
String
DESC
=
"该方法用于加载和读取Html网页内容,并转换为markdown格式。"
;
private
final
FunctionLLMConfig
functionLLMConfig
=
new
FunctionLLMConfig
.
FunctionLLMConfigBuilder
()
.
name
(
"html_reader"
)
.
description
(
DESC
)
.
parameters
(
new
Parameters
(
"object"
)
.
addProperties
(
"url"
,
new
Properties
(
"string"
,
"网页地址"
)))
.
build
();
@Override
public
String
doFunction
(
String
content
,
String
key
)
{
if
(
StringUtils
.
isBlank
(
content
))
{
return
"FAIL"
;
}
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
content
);
String
url
=
jsonObject
.
getString
(
"url"
);
if
(
StringUtils
.
isNotBlank
(
url
))
{
return
DocumentLoad
.
htmlToMarkdown
(
url
);
}
return
StringUtils
.
EMPTY
;
}
@Override
public
String
getDesc
()
{
return
getDesc
();
}
@Override
public
List
<
String
>
getLLMConfig
()
{
return
ListUtil
.
toList
(
JsonUtils
.
serialize
(
functionLLMConfig
));
}
@Override
public
List
<
String
>
getLLMConfig
(
List
<
Variable
>
variableStructure
)
{
return
this
.
getLLMConfig
();
}
}
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/function/long_memory/LongMemoryEntity.java
→
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/function/long_memory/
Agent
LongMemoryEntity.java
View file @
cbfb29ad
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
function
.
long_memory
;
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
function
.
long_memory
;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.util.Date
;
public
class
LongMemoryEntity
implements
Serializable
{
public
class
Agent
LongMemoryEntity
implements
Serializable
{
private
String
content
;
private
String
content
;
...
...
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/function/long_memory/
Get
LongMemory.java
→
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/function/long_memory/LongMemory.java
View file @
cbfb29ad
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
function
.
long_memory
;
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
function
.
long_memory
;
import
cn.com.poc.agent_application.utils.AgentApplicationTools
;
import
cn.com.poc.common.service.RedisService
;
import
cn.com.poc.common.service.RedisService
;
import
cn.com.poc.common.utils.BlContext
;
import
cn.com.poc.common.utils.BlContext
;
import
cn.com.poc.common.utils.SpringUtils
;
import
cn.com.poc.common.utils.SpringUtils
;
...
@@ -9,18 +10,18 @@ import java.util.List;
...
@@ -9,18 +10,18 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.Set
;
public
class
Get
LongMemory
{
public
class
LongMemory
{
public
static
List
<
LongMemoryEntity
>
get
(
String
key
)
{
public
static
List
<
AgentLongMemoryEntity
>
get
(
String
identifier
)
{
RedisService
redisService
=
SpringUtils
.
getBean
(
RedisService
.
class
);
RedisService
redisService
=
SpringUtils
.
getBean
(
RedisService
.
class
);
List
<
LongMemoryEntity
>
result
=
new
ArrayList
<>();
List
<
Agent
LongMemoryEntity
>
result
=
new
ArrayList
<>();
// 查询用户相关信息(什么内容都可以)
// 查询用户相关信息(什么内容都可以)
String
contentKey
=
SetLongMemoryConstants
.
REDIS_PREFIX
+
key
+
":"
+
BlContext
.
getCurrentUserNotException
().
getUserId
().
toString
();
String
contentKey
=
SetLongMemoryConstants
.
REDIS_PREFIX
+
identifier
+
":"
+
BlContext
.
getCurrentUserNotException
().
getUserId
().
toString
();
Map
<
Object
,
Object
>
map
=
redisService
.
hmget
(
contentKey
);
Map
<
Object
,
Object
>
map
=
redisService
.
hmget
(
contentKey
);
Set
<
Object
>
keySet
=
map
.
keySet
();
Set
<
Object
>
keySet
=
map
.
keySet
();
for
(
Object
mapKey
:
keySet
)
{
for
(
Object
mapKey
:
keySet
)
{
LongMemoryEntity
entity
=
new
LongMemoryEntity
();
AgentLongMemoryEntity
entity
=
new
Agent
LongMemoryEntity
();
entity
.
setContent
(
map
.
get
(
mapKey
).
toString
());
entity
.
setContent
(
map
.
get
(
mapKey
).
toString
());
entity
.
setTimestamp
(
mapKey
.
toString
());
entity
.
setTimestamp
(
mapKey
.
toString
());
result
.
add
(
entity
);
result
.
add
(
entity
);
...
@@ -28,4 +29,28 @@ public class GetLongMemory {
...
@@ -28,4 +29,28 @@ public class GetLongMemory {
return
result
;
return
result
;
}
}
/**
* 清除用户在在应用的长期记忆内容
*
* @param agentId
*/
public
static
void
clean
(
String
agentId
)
{
RedisService
redisService
=
SpringUtils
.
getBean
(
RedisService
.
class
);
String
key
=
AgentApplicationTools
.
identifier
(
agentId
,
agentId
);
String
contentKey
=
SetLongMemoryConstants
.
REDIS_PREFIX
+
key
+
":"
+
BlContext
.
getCurrentUserNotException
().
getUserId
().
toString
();
redisService
.
del
(
contentKey
);
}
/**
* 根据时间戳 删除用户在应用的长期记忆 某个时间保存的内容
*
* @param agentId 应用id
* @param item 时间戳
*/
public
static
void
delByKey
(
String
agentId
,
String
item
)
{
RedisService
redisService
=
SpringUtils
.
getBean
(
RedisService
.
class
);
String
key
=
AgentApplicationTools
.
identifier
(
agentId
,
agentId
);
String
contentKey
=
SetLongMemoryConstants
.
REDIS_PREFIX
+
key
+
":"
+
BlContext
.
getCurrentUserNotException
().
getUserId
().
toString
();
redisService
.
hdel
(
contentKey
,
item
);
}
}
}
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/function/long_memory/SetLongMemoryFunction.java
View file @
cbfb29ad
...
@@ -4,27 +4,35 @@ import cn.com.poc.agent_application.entity.Variable;
...
@@ -4,27 +4,35 @@ import cn.com.poc.agent_application.entity.Variable;
import
cn.com.poc.common.service.RedisService
;
import
cn.com.poc.common.service.RedisService
;
import
cn.com.poc.common.utils.BlContext
;
import
cn.com.poc.common.utils.BlContext
;
import
cn.com.poc.common.utils.DateUtils
;
import
cn.com.poc.common.utils.DateUtils
;
import
cn.com.poc.common.utils.JsonUtils
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.AbstractLargeModelFunction
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.AbstractLargeModelFunction
;
import
cn.com.yict.framemax.core.i18n.I18nMessageException
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.entity.FunctionLLMConfig
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.entity.Parameters
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.entity.Properties
;
import
cn.hutool.core.collection.ListUtil
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONObject
;
import
com.google.gson.Gson
;
import
org.springframework.stereotype.Component
;
import
com.sun.org.apache.regexp.internal.RE
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
/**
/**
* 长期记忆
* 长期记忆
*/
*/
@
Service
@
Component
public
class
SetLongMemoryFunction
extends
AbstractLargeModelFunction
{
public
class
SetLongMemoryFunction
extends
AbstractLargeModelFunction
{
private
String
desc
=
"该方法仅用来保存用户想记录的内容,不能通过该方法进行查询。"
;
private
final
String
desc
=
"该方法仅用来保存用户想记录的内容,不能通过该方法进行查询。"
;
private
final
FunctionLLMConfig
functionLLMConfig
=
new
FunctionLLMConfig
.
FunctionLLMConfigBuilder
()
.
name
(
"set_long_memory"
)
.
description
(
desc
)
.
parameters
(
new
Parameters
(
"object"
).
addProperties
(
"content"
,
new
Properties
(
"string"
,
"内容的详细说明"
)))
.
build
();
private
final
Long
expireTime
=
30
*
60
*
24L
;
// 30天有效期
@Resource
@Resource
private
RedisService
redisService
;
private
RedisService
redisService
;
...
@@ -48,49 +56,51 @@ public class SetLongMemoryFunction extends AbstractLargeModelFunction {
...
@@ -48,49 +56,51 @@ public class SetLongMemoryFunction extends AbstractLargeModelFunction {
// 提取 content
// 提取 content
String
contents
=
jsonObject
.
getStr
(
"content"
);
String
contents
=
jsonObject
.
getStr
(
"content"
);
String
contentKey
=
SetLongMemoryConstants
.
REDIS_PREFIX
+
key
+
":"
+
BlContext
.
getCurrentUserNotException
().
getUserId
().
toString
();
String
contentKey
=
SetLongMemoryConstants
.
REDIS_PREFIX
+
key
+
":"
+
BlContext
.
getCurrentUserNotException
().
getUserId
().
toString
();
redisService
.
hset
(
contentKey
,
DateUtils
.
getCurrTime
(),
contents
);
redisService
.
hset
(
contentKey
,
DateUtils
.
getCurrTime
(),
contents
,
expireTime
);
return
"SUCCESS"
;
return
"SUCCESS"
;
}
}
@Override
@Override
public
List
<
String
>
getLLMConfig
()
{
public
List
<
String
>
getLLMConfig
()
{
Map
<
String
,
Object
>
config
=
new
HashMap
<>();
// Map<String, Object> config = new HashMap<>();
Map
<
String
,
Object
>
function
=
new
HashMap
<>();
// Map<String, Object> function = new HashMap<>();
//
Map
<
String
,
Object
>
content
=
new
HashMap
<>();
// Map<String, Object> content = new HashMap<>();
content
.
put
(
"type"
,
"string"
);
// content.put("type", "string");
content
.
put
(
"description"
,
"内容的详细说明"
);
// content.put("description", "内容的详细说明");
//
Map
<
String
,
Object
>
properties
=
new
HashMap
<>();
// Map<String, Object> properties = new HashMap<>();
properties
.
put
(
"content"
,
content
);
// properties.put("content", content);
//
Map
<
String
,
Object
>
parameters
=
new
HashMap
<>();
// Map<String, Object> parameters = new HashMap<>();
parameters
.
put
(
"type"
,
"object"
);
// parameters.put("type", "object");
parameters
.
put
(
"properties"
,
properties
);
// parameters.put("properties", properties);
//
List
<
String
>
required
=
new
ArrayList
<>();
// List<String> required = new ArrayList<>();
required
.
add
(
"content"
);
// required.add("content");
parameters
.
put
(
"required"
,
required
);
// parameters.put("required", required);
//
//
function
.
put
(
"name"
,
"set_long_memory"
);
// function.put("name", "set_long_memory");
function
.
put
(
"description"
,
desc
);
// function.put("description", desc);
function
.
put
(
"parameters"
,
parameters
);
// function.put("parameters", parameters);
//
config
.
put
(
"type"
,
"function"
);
// config.put("type", "function");
config
.
put
(
"function"
,
function
);
// config.put("function", function);
//
// 将 Map 转换为 JSON 字符串
// // 将 Map 转换为 JSON 字符串
Gson
gson
=
new
Gson
();
// Gson gson = new Gson();
String
jsonString
=
gson
.
toJson
(
config
);
// String jsonString = gson.toJson(config);
//
List
<
String
>
resultList
=
new
ArrayList
<>();
// List<String> resultList = new ArrayList<>();
resultList
.
add
(
jsonString
);
// resultList.add(jsonString);
return
resultList
;
// return resultList;
return
ListUtil
.
toList
(
JsonUtils
.
serialize
(
functionLLMConfig
));
}
}
@Override
@Override
public
List
<
String
>
get
VariableStructure
LLMConfig
(
List
<
Variable
>
variableStructure
)
{
public
List
<
String
>
getLLMConfig
(
List
<
Variable
>
variableStructure
)
{
throw
new
I18nMessageException
(
"exception/variable.structure.configuration.is.not.currently.supported"
);
return
this
.
getLLMConfig
(
);
}
}
}
}
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/function/memory_variable_writer/MemoryVariableWriter.java
0 → 100644
View file @
cbfb29ad
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
function
.
memory_variable_writer
;
import
cn.com.poc.common.service.RedisService
;
import
cn.com.poc.common.utils.BlContext
;
import
cn.com.poc.common.utils.SpringUtils
;
import
cn.hutool.json.JSONArray
;
import
cn.hutool.json.JSONObject
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
MemoryVariableWriter
{
public
static
Map
<
Object
,
Object
>
get
(
String
key
)
{
String
redisKey
=
MemoryVariableWriterConstants
.
REDIS_PREFIX
+
key
+
":"
+
BlContext
.
getCurrentUserNotException
().
getUserId
().
toString
();
RedisService
redisService
=
SpringUtils
.
getBean
(
RedisService
.
class
);
if
(!
redisService
.
hasKey
(
redisKey
))
{
return
null
;
}
Map
<
Object
,
Object
>
result
=
redisService
.
hmget
(
redisKey
);
return
result
;
}
public
static
void
clean
(
String
key
)
{
String
redisKey
=
MemoryVariableWriterConstants
.
REDIS_PREFIX
+
key
+
":"
+
BlContext
.
getCurrentUserNotException
().
getUserId
().
toString
();
RedisService
redisService
=
SpringUtils
.
getBean
(
RedisService
.
class
);
redisService
.
del
(
redisKey
);
}
public
static
void
cleanByPre
(
String
key
)
{
String
redisKey
=
MemoryVariableWriterConstants
.
REDIS_PREFIX
+
key
+
":"
;
RedisService
redisService
=
SpringUtils
.
getBean
(
RedisService
.
class
);
redisService
.
delByPre
(
redisKey
);
}
public
static
void
delItem
(
String
identifier
,
String
...
items
)
{
String
redisKey
=
MemoryVariableWriterConstants
.
REDIS_PREFIX
+
identifier
+
":"
+
BlContext
.
getCurrentUserNotException
().
getUserId
().
toString
();
RedisService
redisService
=
SpringUtils
.
getBean
(
RedisService
.
class
);
redisService
.
hdel
(
redisKey
,
items
);
}
public
static
void
addItem
(
String
identifier
,
Map
<
String
,
Object
>
map
)
{
String
redisKey
=
MemoryVariableWriterConstants
.
REDIS_PREFIX
+
identifier
+
":"
+
BlContext
.
getCurrentUserNotException
().
getUserId
().
toString
();
RedisService
redisService
=
SpringUtils
.
getBean
(
RedisService
.
class
);
// 创建 JSONObject 对象
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
if
(
redisService
.
hasKey
(
redisKey
))
{
Map
<
Object
,
Object
>
hmget
=
redisService
.
hmget
(
redisKey
);
hmget
.
putAll
(
map
);
for
(
Map
.
Entry
<
Object
,
Object
>
entry
:
hmget
.
entrySet
())
{
if
(
entry
.
getKey
()
instanceof
String
)
{
String
tempKey
=
(
String
)
entry
.
getKey
();
result
.
put
(
tempKey
,
entry
.
getValue
());
}
}
}
result
.
putAll
(
map
);
// 30天有效期
long
expireTime
=
30
*
60
*
24L
;
redisService
.
hmset
(
redisKey
,
result
,
expireTime
);
}
private
static
void
setMap
(
JSONObject
jsonObject
,
Map
<
String
,
Object
>
result
)
{
String
key
=
jsonObject
.
getStr
(
"key"
);
String
value
=
jsonObject
.
getStr
(
"value"
);
result
.
put
(
key
,
value
);
}
}
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/function/memory_variable_writer/MemoryVariableWriterConstants.java
0 → 100644
View file @
cbfb29ad
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
function
.
memory_variable_writer
;
public
interface
MemoryVariableWriterConstants
{
String
REDIS_PREFIX
=
"AGENT_APP_FUNCTION:MEMORY_VARIABLE:"
;
}
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/function/
value_memory/SetValueMemory
Function.java
→
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/function/
memory_variable_writer/MemoryVariableWriter
Function.java
View file @
cbfb29ad
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
function
.
value_memory
;
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
function
.
memory_variable_writer
;
import
cn.com.poc.agent_application.entity.Variable
;
import
cn.com.poc.agent_application.entity.Variable
;
import
cn.com.poc.common.service.RedisService
;
import
cn.com.poc.common.service.RedisService
;
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.common.utils.JsonUtils
;
import
cn.com.poc.
thirdparty.resource.demand.ai.entity.dialogue.Function
;
import
cn.com.poc.
common.utils.StringUtils
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.AbstractLargeModelFunction
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.AbstractLargeModelFunction
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.entity.FunctionLLMConfig
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.entity.Parameters
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.entity.Properties
;
import
cn.com.yict.framemax.core.i18n.I18nMessageException
;
import
cn.com.yict.framemax.core.i18n.I18nMessageException
;
import
cn.hutool.core.collection.ListUtil
;
import
cn.hutool.json.JSONArray
;
import
cn.hutool.json.JSONException
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONObject
;
import
com.google.gson.Gson
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
...
@@ -17,27 +22,31 @@ import java.util.HashMap;
...
@@ -17,27 +22,31 @@ import java.util.HashMap;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
@Service
@Component
public
class
SetValueMemoryFunction
extends
AbstractLargeModelFunction
{
public
class
MemoryVariableWriterFunction
extends
AbstractLargeModelFunction
{
private
final
String
DESC
=
"该方法参考key字段给出的内容键,来保存对应的内容值,该方法不可进行查询"
;
private
final
FunctionLLMConfig
functionLLMConfig
=
new
FunctionLLMConfig
.
FunctionLLMConfigBuilder
()
.
name
(
"memory_variable_writer"
)
.
description
(
DESC
)
.
parameters
(
new
Parameters
(
"array"
)
.
addProperties
(
"key"
,
new
Properties
(
"string"
,
"内容键"
))
.
addProperties
(
"value"
,
new
Properties
(
"string"
,
"内容值"
))
).
build
();
private
String
desc
=
"该方法仅用enum给定的内容名来保存用户想记录的内容值,不可使用该方法进行查询"
;
@Resource
@Resource
private
RedisService
redisService
;
private
RedisService
redisService
;
@Override
@Override
public
String
getDesc
()
{
public
String
doFunction
(
String
content
,
String
identifier
)
{
return
desc
;
if
(
StringUtils
.
isBlank
(
content
)
||
StringUtils
.
isBlank
(
identifier
))
{
}
return
"FAIL"
;
}
@Override
String
contentKey
=
MemoryVariableWriterConstants
.
REDIS_PREFIX
+
identifier
+
":"
+
BlContext
.
getCurrentUserNotException
().
getUserId
().
toString
();
public
String
doFunction
(
String
content
,
String
key
)
{
String
contentKey
=
SetValueMemoryConstants
.
REDIS_PREFIX
+
key
+
":"
+
BlContext
.
getCurrentUserNotException
().
getUserId
().
toString
();
// 创建 JSONObject 对象
// 创建 JSONObject 对象
JSONObject
jsonObject
=
new
JSONObject
(
content
);
// 提取 contentName 和 contentValue
String
contentName
=
jsonObject
.
getStr
(
"contentName"
);
String
contentValue
=
jsonObject
.
getStr
(
"contentValue"
);
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
if
(
redisService
.
hasKey
(
contentKey
))
{
if
(
redisService
.
hasKey
(
contentKey
))
{
Map
<
Object
,
Object
>
hmget
=
redisService
.
hmget
(
contentKey
);
Map
<
Object
,
Object
>
hmget
=
redisService
.
hmget
(
contentKey
);
...
@@ -48,58 +57,54 @@ public class SetValueMemoryFunction extends AbstractLargeModelFunction {
...
@@ -48,58 +57,54 @@ public class SetValueMemoryFunction extends AbstractLargeModelFunction {
}
}
}
}
}
}
result
.
put
(
contentName
,
contentValue
);
if
(
isJsonArray
(
content
))
{
redisService
.
hmset
(
contentKey
,
result
);
JSONArray
jsonArray
=
new
JSONArray
(
content
);
for
(
int
i
=
0
;
i
<
jsonArray
.
size
();
i
++)
{
setMap
(
jsonArray
.
getJSONObject
(
i
),
result
);
}
}
else
{
setMap
(
new
JSONObject
(
content
),
result
);
}
// 30天有效期
long
expireTime
=
30
*
60
*
24L
;
redisService
.
hmset
(
contentKey
,
result
,
expireTime
);
return
"SUCCESS"
;
return
"SUCCESS"
;
}
}
private
static
void
setMap
(
JSONObject
jsonObject
,
Map
<
String
,
Object
>
result
)
{
String
key
=
jsonObject
.
getStr
(
"key"
);
String
value
=
jsonObject
.
getStr
(
"value"
);
result
.
put
(
key
,
value
);
}
@Override
public
String
getDesc
()
{
return
DESC
;
}
@Override
@Override
public
List
<
String
>
getLLMConfig
()
{
public
List
<
String
>
getLLMConfig
()
{
throw
new
I18nMessageException
(
"exception/this.method.is.not.supported"
);
throw
new
I18nMessageException
(
"exception/this.method.is.not.supported"
);
}
}
@Override
@Override
public
List
<
String
>
getVariableStructureLLMConfig
(
List
<
Variable
>
variableStructure
)
{
public
List
<
String
>
getLLMConfig
(
List
<
Variable
>
variableStructure
)
{
Map
<
String
,
Object
>
config
=
new
HashMap
<>();
Map
<
String
,
Object
>
function
=
new
HashMap
<>();
Map
<
String
,
Object
>
parameters
=
new
HashMap
<>();
parameters
.
put
(
"type"
,
"object"
);
List
<
String
>
required
=
new
ArrayList
<>();
required
.
add
(
"contentName"
);
required
.
add
(
"contentValue"
);
parameters
.
put
(
"required"
,
required
);
Map
<
String
,
Object
>
properties
=
new
HashMap
<>();
Map
<
String
,
Object
>
contentName
=
new
HashMap
<>();
contentName
.
put
(
"type"
,
"string"
);
contentName
.
put
(
"description"
,
"内容名"
);
List
<
String
>
enumList
=
new
ArrayList
<>();
List
<
String
>
enumList
=
new
ArrayList
<>();
for
(
Variable
variable
:
variableStructure
)
{
for
(
Variable
variable
:
variableStructure
)
{
enumList
.
add
(
variable
.
getKey
());
enumList
.
add
(
variable
.
getKey
());
}
}
contentName
.
put
(
"enum"
,
enumList
);
// 设置变量
this
.
functionLLMConfig
.
getFunction
().
getParameters
().
addProperties
(
"key"
,
new
Properties
(
"string"
,
"内容键"
,
enumList
));
Map
<
String
,
Object
>
contentValue
=
new
HashMap
<>();
return
ListUtil
.
toList
(
JsonUtils
.
serialize
(
functionLLMConfig
));
contentValue
.
put
(
"type"
,
"string"
);
}
contentValue
.
put
(
"description"
,
"内容值"
);
properties
.
put
(
"contentName"
,
contentName
);
properties
.
put
(
"contentValue"
,
contentValue
);
parameters
.
put
(
"properties"
,
properties
);
parameters
.
put
(
"type"
,
"object"
);
function
.
put
(
"name"
,
"set_value_memory"
);
function
.
put
(
"description"
,
desc
);
function
.
put
(
"parameters"
,
parameters
);
config
.
put
(
"type"
,
"function"
);
config
.
put
(
"function"
,
function
);
// 将 Map 转换为 JSON 字符串
Gson
gson
=
new
Gson
();
String
jsonString
=
gson
.
toJson
(
config
);
List
<
String
>
resultList
=
new
ArrayList
<>();
private
boolean
isJsonArray
(
String
json
)
{
resultList
.
add
(
jsonString
);
try
{
return
resultList
;
new
JSONArray
(
json
);
return
true
;
}
catch
(
JSONException
e
)
{
return
false
;
}
}
}
}
}
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/function/value_memory/GetValueMemory.java
deleted
100644 → 0
View file @
43aaf3a4
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
function
.
value_memory
;
import
cn.com.poc.common.service.RedisService
;
import
cn.com.poc.common.utils.BlContext
;
import
cn.com.poc.common.utils.SpringUtils
;
import
java.util.Map
;
/**
* 获取【变量】内容
*/
public
class
GetValueMemory
{
public
static
Map
<
Object
,
Object
>
get
(
String
key
)
{
String
contentKey
=
SetValueMemoryConstants
.
REDIS_PREFIX
+
key
+
":"
+
BlContext
.
getCurrentUserNotException
().
getUserId
().
toString
();
RedisService
redisService
=
SpringUtils
.
getBean
(
RedisService
.
class
);
if
(!
redisService
.
hasKey
(
contentKey
))
{
return
null
;
}
Map
<
Object
,
Object
>
result
=
redisService
.
hmget
(
contentKey
);
return
result
;
}
}
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/function/value_memory/SetValueMemoryConstants.java
deleted
100644 → 0
View file @
43aaf3a4
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
function
.
value_memory
;
public
interface
SetValueMemoryConstants
{
String
REDIS_PREFIX
=
"AGENT_APP_FUNCTION:VALUE_MEMORY:"
;
}
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/
common/DgtoolsApiConstants
.java
→
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/
route/DgtoolsApiRoute
.java
View file @
cbfb29ad
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
common
;
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
route
;
import
org.apache.http.Header
;
import
org.apache.http.Header
;
import
org.apache.http.HttpHeaders
;
import
org.apache.http.HttpHeaders
;
...
@@ -10,7 +10,7 @@ import org.apache.http.message.BasicHeader;
...
@@ -10,7 +10,7 @@ import org.apache.http.message.BasicHeader;
*
*
* @author Roger Wu
* @author Roger Wu
*/
*/
public
interface
DgtoolsApi
Constants
{
public
interface
DgtoolsApi
Route
{
/**
/**
* 中台路由
* 中台路由
...
...
src/main/java/cn/com/poc/thirdparty/resource/demand/clickhouse/service/impl/DataReportServiceImpl.java
View file @
cbfb29ad
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
clickhouse
.
service
.
impl
;
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
clickhouse
.
service
.
impl
;
import
cn.com.poc.support.dgTools.DgtoolsAbstractHttpClient
;
import
cn.com.poc.support.dgTools.DgtoolsAbstractHttpClient
;
import
cn.com.poc.thirdparty.resource.demand.ai.
common.DgtoolsApiConstants
;
import
cn.com.poc.thirdparty.resource.demand.ai.
route.DgtoolsApiRoute
;
import
cn.com.poc.thirdparty.resource.demand.clickhouse.entity.WebBrowseHarvestEntity
;
import
cn.com.poc.thirdparty.resource.demand.clickhouse.entity.WebBrowseHarvestEntity
;
import
cn.com.poc.thirdparty.resource.demand.clickhouse.service.DataReportService
;
import
cn.com.poc.thirdparty.resource.demand.clickhouse.service.DataReportService
;
import
cn.com.poc.thirdparty.resource.demand.member.service.DemandAuthService
;
import
cn.com.poc.thirdparty.resource.demand.member.service.DemandAuthService
;
...
@@ -33,11 +33,11 @@ public class DataReportServiceImpl implements DataReportService {
...
@@ -33,11 +33,11 @@ public class DataReportServiceImpl implements DataReportService {
private
void
dataReport
(
WebBrowseHarvestEntity
request
)
{
private
void
dataReport
(
WebBrowseHarvestEntity
request
)
{
List
<
Header
>
headers
=
new
ArrayList
<
Header
>()
{{
List
<
Header
>
headers
=
new
ArrayList
<
Header
>()
{{
add
(
DgtoolsApi
Constants
.
JSON_HEADER
);
add
(
DgtoolsApi
Route
.
JSON_HEADER
);
add
(
DgtoolsApi
Constants
.
CKHOUSE_HEADER
);
add
(
DgtoolsApi
Route
.
CKHOUSE_HEADER
);
add
(
new
BasicHeader
(
DgtoolsApi
Constants
.
HEADER_X_PLATFORM_AUTHORIZATION
,
demandAuthService
.
getToken
()));
add
(
new
BasicHeader
(
DgtoolsApi
Route
.
HEADER_X_PLATFORM_AUTHORIZATION
,
demandAuthService
.
getToken
()));
}};
}};
dgToolsAbstractHttpClient
.
doRequest
(
DgtoolsApi
Constants
.
ClickHouse
.
WEB_BROWSE_HARVEST_REPORT
,
request
,
headers
);
dgToolsAbstractHttpClient
.
doRequest
(
DgtoolsApi
Route
.
ClickHouse
.
WEB_BROWSE_HARVEST_REPORT
,
request
,
headers
);
}
}
}
}
src/main/java/cn/com/poc/thirdparty/resource/demand/member/api/DemandAuthApi.java
View file @
cbfb29ad
...
@@ -3,7 +3,7 @@ package cn.com.poc.thirdparty.resource.demand.member.api;
...
@@ -3,7 +3,7 @@ package cn.com.poc.thirdparty.resource.demand.member.api;
import
cn.com.poc.thirdparty.resource.demand.member.entity.DemandAuthResponse
;
import
cn.com.poc.thirdparty.resource.demand.member.entity.DemandAuthResponse
;
import
cn.com.poc.thirdparty.resource.demand.member.entity.DemandAuthResult
;
import
cn.com.poc.thirdparty.resource.demand.member.entity.DemandAuthResult
;
import
cn.com.poc.support.dgTools.DgtoolsAbstractHttpClient
;
import
cn.com.poc.support.dgTools.DgtoolsAbstractHttpClient
;
import
cn.com.poc.thirdparty.resource.demand.ai.
common.DgtoolsApiConstants
;
import
cn.com.poc.thirdparty.resource.demand.ai.
route.DgtoolsApiRoute
;
import
org.apache.http.Header
;
import
org.apache.http.Header
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -28,7 +28,7 @@ public class DemandAuthApi {
...
@@ -28,7 +28,7 @@ public class DemandAuthApi {
*/
*/
public
DemandAuthResult
getToken
(
DemandAuthResponse
response
)
{
public
DemandAuthResult
getToken
(
DemandAuthResponse
response
)
{
List
<
Header
>
headers
=
new
LinkedList
<>();
List
<
Header
>
headers
=
new
LinkedList
<>();
headers
.
add
(
DgtoolsApi
Constants
.
MEMBER_HEADER
);
headers
.
add
(
DgtoolsApi
Route
.
MEMBER_HEADER
);
return
dgToolsAbstractHttpClient
.
doRequest
(
DgtoolsApi
Constants
.
MemberPlatform
.
GET_PLATFORM_TOKEN
,
response
,
headers
);
return
dgToolsAbstractHttpClient
.
doRequest
(
DgtoolsApi
Route
.
MemberPlatform
.
GET_PLATFORM_TOKEN
,
response
,
headers
);
}
}
}
}
src/main/java/cn/com/poc/thirdparty/resource/demand/member/api/DemandMemberApi.java
View file @
cbfb29ad
...
@@ -2,7 +2,7 @@ package cn.com.poc.thirdparty.resource.demand.member.api;
...
@@ -2,7 +2,7 @@ package cn.com.poc.thirdparty.resource.demand.member.api;
import
cn.com.poc.common.utils.http.LocalHttpClient
;
import
cn.com.poc.common.utils.http.LocalHttpClient
;
import
cn.com.poc.thirdparty.resource.demand.member.entity.DemandMemberResult
;
import
cn.com.poc.thirdparty.resource.demand.member.entity.DemandMemberResult
;
import
cn.com.poc.thirdparty.resource.demand.ai.
common.DgtoolsApiConstants
;
import
cn.com.poc.thirdparty.resource.demand.ai.
route.DgtoolsApiRoute
;
import
org.apache.http.client.methods.HttpUriRequest
;
import
org.apache.http.client.methods.HttpUriRequest
;
import
org.apache.http.client.methods.RequestBuilder
;
import
org.apache.http.client.methods.RequestBuilder
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
...
@@ -24,10 +24,10 @@ public class DemandMemberApi {
...
@@ -24,10 +24,10 @@ public class DemandMemberApi {
*/
*/
public
String
createDemandMember
(
String
token
)
{
public
String
createDemandMember
(
String
token
)
{
HttpUriRequest
httpUriRequest
=
RequestBuilder
.
post
()
HttpUriRequest
httpUriRequest
=
RequestBuilder
.
post
()
.
setUri
(
dgtoolsDomainurl
+
DgtoolsApi
Constants
.
BASE_URL
+
DgtoolsApiConstants
.
MemberPlatform
.
CRAETE_DEMAND_MEMBER
)
.
setUri
(
dgtoolsDomainurl
+
DgtoolsApi
Route
.
BASE_URL
+
DgtoolsApiRoute
.
MemberPlatform
.
CRAETE_DEMAND_MEMBER
)
.
setHeader
(
DgtoolsApi
Constants
.
JSON_HEADER
)
.
setHeader
(
DgtoolsApi
Route
.
JSON_HEADER
)
.
setHeader
(
DgtoolsApi
Constants
.
HEADER_X_PLATFORM_AUTHORIZATION
,
token
)
.
setHeader
(
DgtoolsApi
Route
.
HEADER_X_PLATFORM_AUTHORIZATION
,
token
)
.
setHeader
(
DgtoolsApi
Constants
.
MEMBER_HEADER
)
.
setHeader
(
DgtoolsApi
Route
.
MEMBER_HEADER
)
.
build
();
.
build
();
return
LocalHttpClient
.
executeJsonResult
(
httpUriRequest
,
String
.
class
);
return
LocalHttpClient
.
executeJsonResult
(
httpUriRequest
,
String
.
class
);
}
}
...
@@ -37,10 +37,10 @@ public class DemandMemberApi {
...
@@ -37,10 +37,10 @@ public class DemandMemberApi {
*/
*/
public
DemandMemberResult
searchDemandMember
(
String
demandMemberId
,
String
token
)
{
public
DemandMemberResult
searchDemandMember
(
String
demandMemberId
,
String
token
)
{
HttpUriRequest
httpUriRequest
=
RequestBuilder
.
post
()
HttpUriRequest
httpUriRequest
=
RequestBuilder
.
post
()
.
setUri
(
dgtoolsDomainurl
+
DgtoolsApi
Constants
.
BASE_URL
+
DgtoolsApiConstants
.
MemberPlatform
.
SEARCH_DEMAND_MEMBER
)
.
setUri
(
dgtoolsDomainurl
+
DgtoolsApi
Route
.
BASE_URL
+
DgtoolsApiRoute
.
MemberPlatform
.
SEARCH_DEMAND_MEMBER
)
.
setHeader
(
DgtoolsApi
Constants
.
JSON_HEADER
)
.
setHeader
(
DgtoolsApi
Route
.
JSON_HEADER
)
.
setHeader
(
DgtoolsApi
Constants
.
HEADER_X_PLATFORM_AUTHORIZATION
,
token
)
.
setHeader
(
DgtoolsApi
Route
.
HEADER_X_PLATFORM_AUTHORIZATION
,
token
)
.
setHeader
(
DgtoolsApi
Constants
.
MEMBER_HEADER
)
.
setHeader
(
DgtoolsApi
Route
.
MEMBER_HEADER
)
.
addParameter
(
"memberId"
,
demandMemberId
)
.
addParameter
(
"memberId"
,
demandMemberId
)
.
build
();
.
build
();
return
LocalHttpClient
.
executeJsonResult
(
httpUriRequest
,
DemandMemberResult
.
class
);
return
LocalHttpClient
.
executeJsonResult
(
httpUriRequest
,
DemandMemberResult
.
class
);
...
...
src/main/java/cn/com/poc/timbre/constants/MatchLangEnum.java
0 → 100644
View file @
cbfb29ad
package
cn
.
com
.
poc
.
timbre
.
constants
;
/**
* 系统环境语言匹配
*
* @author alex.yao
* @Description 作用在AgentApplication应用的音色配置
* 获取当前系统环境语言,匹配对应的音色类型
* 例如:
* 1.系统环境语言为简体,则匹配音色类型为【中文】,matchLang="zh-CN"
* 2.系统环境语言为繁体,则匹配音色类型为【粤语】,matchLang="zh-HK"
* 3.系统环境语言为英语,则匹配音色类型为【英文】,matchLang="en"
*/
public
enum
MatchLangEnum
{
zh_CN
(
0
,
"zh-CN"
),
zh_HK
(
1
,
"zh-HK"
),
en
(
2
,
"en"
);
private
int
language
;
private
String
matchLang
;
MatchLangEnum
(
int
language
,
String
matchLang
)
{
this
.
language
=
language
;
this
.
matchLang
=
matchLang
;
}
public
int
getLanguage
()
{
return
language
;
}
public
String
getMatchLang
()
{
return
matchLang
;
}
public
static
String
getMatchLangByLanguage
(
int
language
)
{
for
(
MatchLangEnum
matchLang
:
MatchLangEnum
.
values
())
{
if
(
matchLang
.
language
==
language
)
{
return
matchLang
.
matchLang
;
}
}
return
null
;
}
}
src/main/java/cn/com/poc/timbre/convert/BizVoiceTimbreConvert.java
0 → 100644
View file @
cbfb29ad
package
cn
.
com
.
poc
.
timbre
.
convert
;
import
cn.com.poc.timbre.constants.MatchLangEnum
;
import
cn.com.poc.timbre.dto.GetTimbreDto
;
import
cn.com.poc.timbre.dto.TimbreInfo
;
import
cn.com.poc.timbre.entity.BizVoiceTimbreEntity
;
import
cn.com.poc.timbre.model.BizVoiceTimbreModel
;
import
cn.hutool.core.collection.ListUtil
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Locale
;
public
class
BizVoiceTimbreConvert
{
public
static
BizVoiceTimbreEntity
modelToEntity
(
BizVoiceTimbreModel
model
)
{
BizVoiceTimbreEntity
entity
=
new
BizVoiceTimbreEntity
();
entity
.
setId
(
model
.
getId
());
entity
.
setTimbreId
(
model
.
getTimbreId
());
entity
.
setLanguage
(
model
.
getLanguage
());
entity
.
setTimbreName
(
model
.
getTimbreName
());
entity
.
setTimbreNameEn
(
model
.
getTimbreNameEn
());
entity
.
setTimbreNameTw
(
model
.
getTimbreNameTw
());
entity
.
setVoiceUrl
(
model
.
getVoiceUrl
());
entity
.
setIsDeleted
(
model
.
getIsDeleted
());
entity
.
setCreator
(
model
.
getCreator
());
entity
.
setCreatedTime
(
model
.
getCreatedTime
());
entity
.
setModifier
(
model
.
getModifier
());
entity
.
setModifiedTime
(
model
.
getModifiedTime
());
entity
.
setSysVersion
(
model
.
getSysVersion
());
return
entity
;
}
public
static
BizVoiceTimbreModel
entityToModel
(
BizVoiceTimbreEntity
entity
)
{
BizVoiceTimbreModel
model
=
new
BizVoiceTimbreModel
();
model
.
setId
(
entity
.
getId
());
model
.
setTimbreId
(
entity
.
getTimbreId
());
model
.
setLanguage
(
entity
.
getLanguage
());
model
.
setTimbreName
(
entity
.
getTimbreName
());
model
.
setTimbreNameEn
(
entity
.
getTimbreNameEn
());
model
.
setTimbreNameTw
(
entity
.
getTimbreNameTw
());
model
.
setVoiceUrl
(
entity
.
getVoiceUrl
());
model
.
setIsDeleted
(
entity
.
getIsDeleted
());
model
.
setCreator
(
entity
.
getCreator
());
model
.
setCreatedTime
(
entity
.
getCreatedTime
());
model
.
setModifier
(
entity
.
getModifier
());
model
.
setModifiedTime
(
entity
.
getModifiedTime
());
model
.
setSysVersion
(
entity
.
getSysVersion
());
return
model
;
}
public
static
GetTimbreDto
entityToGetTimbreDto
(
BizVoiceTimbreEntity
entity
,
Locale
locale
)
{
GetTimbreDto
getTimbreDto
=
new
GetTimbreDto
();
getTimbreDto
.
setLanguage
(
entity
.
getLanguage
());
getTimbreDto
.
setMatchLang
(
MatchLangEnum
.
getMatchLangByLanguage
(
entity
.
getLanguage
()));
TimbreInfo
timbreInfo
=
setTimbreInfo
(
locale
,
entity
);
getTimbreDto
.
setTimbreInfo
(
ListUtil
.
toList
(
timbreInfo
));
return
getTimbreDto
;
}
/**
* entities转换为GetTimbreDto列表
*
* @param entities
* @param locale 语言 zh-cn 中文简体 en 英文 zh-tw 中文繁体
* @return
*/
public
static
List
<
GetTimbreDto
>
entitiesToGetTimbreDtoList
(
List
<
BizVoiceTimbreEntity
>
entities
,
Locale
locale
)
{
List
<
GetTimbreDto
>
dtos
=
new
ArrayList
<>();
// 初始化三个Dto对象 cnDto 中文 enDto 英文 twDto 粤语
List
<
TimbreInfo
>
cnTimbreInfos
=
new
ArrayList
<>();
GetTimbreDto
cnDto
=
new
GetTimbreDto
();
cnDto
.
setLanguage
(
0
);
cnDto
.
setMatchLang
(
MatchLangEnum
.
zh_CN
.
getMatchLang
());
cnDto
.
setTimbreInfo
(
cnTimbreInfos
);
List
<
TimbreInfo
>
cantonTimbreInfos
=
new
ArrayList
<>();
GetTimbreDto
cantonDto
=
new
GetTimbreDto
();
cantonDto
.
setLanguage
(
1
);
cantonDto
.
setMatchLang
(
MatchLangEnum
.
zh_HK
.
getMatchLang
());
cantonDto
.
setTimbreInfo
(
cantonTimbreInfos
);
List
<
TimbreInfo
>
enTimbreInfos
=
new
ArrayList
<>();
GetTimbreDto
enDto
=
new
GetTimbreDto
();
enDto
.
setLanguage
(
2
);
enDto
.
setMatchLang
(
MatchLangEnum
.
en
.
getMatchLang
());
enDto
.
setTimbreInfo
(
enTimbreInfos
);
for
(
BizVoiceTimbreEntity
entity
:
entities
)
{
Integer
language
=
entity
.
getLanguage
();
TimbreInfo
timbreInfo
=
setTimbreInfo
(
locale
,
entity
);
switch
(
language
.
intValue
())
{
case
0
:
cnTimbreInfos
.
add
(
timbreInfo
);
break
;
case
1
:
cantonTimbreInfos
.
add
(
timbreInfo
);
break
;
case
2
:
enTimbreInfos
.
add
(
timbreInfo
);
break
;
}
}
dtos
.
add
(
cnDto
);
dtos
.
add
(
cantonDto
);
dtos
.
add
(
enDto
);
return
dtos
;
}
private
static
TimbreInfo
setTimbreInfo
(
Locale
locale
,
BizVoiceTimbreEntity
entity
)
{
TimbreInfo
timbreInfo
=
new
TimbreInfo
();
timbreInfo
.
setTimbreId
(
entity
.
getTimbreId
());
timbreInfo
.
setVoiceUrl
(
entity
.
getVoiceUrl
());
if
(
Locale
.
SIMPLIFIED_CHINESE
.
equals
(
locale
))
{
timbreInfo
.
setTimbreName
(
entity
.
getTimbreName
());
}
else
if
(
Locale
.
ENGLISH
.
equals
(
locale
))
{
timbreInfo
.
setTimbreName
(
entity
.
getTimbreNameEn
());
}
else
if
(
Locale
.
TRADITIONAL_CHINESE
.
equals
(
locale
))
{
timbreInfo
.
setTimbreName
(
entity
.
getTimbreNameTw
());
}
return
timbreInfo
;
}
}
\ No newline at end of file
src/main/java/cn/com/poc/timbre/dto/GetTimbreDto.java
0 → 100644
View file @
cbfb29ad
package
cn
.
com
.
poc
.
timbre
.
dto
;
import
java.util.List
;
public
class
GetTimbreDto
{
/**
* 音色语言分类 0-中文 1-粤语 2-英文
*/
private
Integer
language
;
/**
* 匹配
*/
private
String
matchLang
;
/**
* 音色信息
*/
private
List
<
TimbreInfo
>
timbreInfo
;
public
String
getMatchLang
()
{
return
matchLang
;
}
public
void
setMatchLang
(
String
matchLang
)
{
this
.
matchLang
=
matchLang
;
}
public
Integer
getLanguage
()
{
return
language
;
}
public
void
setLanguage
(
Integer
language
)
{
this
.
language
=
language
;
}
public
List
<
TimbreInfo
>
getTimbreInfo
()
{
return
timbreInfo
;
}
public
void
setTimbreInfo
(
List
<
TimbreInfo
>
timbreInfo
)
{
this
.
timbreInfo
=
timbreInfo
;
}
}
src/main/java/cn/com/poc/timbre/dto/TimbreInfo.java
0 → 100644
View file @
cbfb29ad
package
cn
.
com
.
poc
.
timbre
.
dto
;
/**
* 音色信息
* @author alex.yao
*/
public
class
TimbreInfo
{
/**
* 音色ID
*/
private
String
timbreId
;
/**
* 音色名称
*/
private
String
timbreName
;
/**
* 音色预览文件地址
*/
private
String
voiceUrl
;
public
String
getTimbreId
()
{
return
timbreId
;
}
public
void
setTimbreId
(
String
timbreId
)
{
this
.
timbreId
=
timbreId
;
}
public
String
getTimbreName
()
{
return
timbreName
;
}
public
void
setTimbreName
(
String
timbreName
)
{
this
.
timbreName
=
timbreName
;
}
public
String
getVoiceUrl
()
{
return
voiceUrl
;
}
public
void
setVoiceUrl
(
String
voiceUrl
)
{
this
.
voiceUrl
=
voiceUrl
;
}
}
src/main/java/cn/com/poc/timbre/entity/BizVoiceTimbreEntity.java
0 → 100644
View file @
cbfb29ad
package
cn
.
com
.
poc
.
timbre
.
entity
;
public
class
BizVoiceTimbreEntity
{
private
static
final
long
serialVersionUID
=
1L
;
/** id
*主键
*/
private
java
.
lang
.
Integer
id
;
public
java
.
lang
.
Integer
getId
(){
return
this
.
id
;
}
public
void
setId
(
java
.
lang
.
Integer
id
){
this
.
id
=
id
;
}
/** timbre_id
*音色ID
*/
private
java
.
lang
.
String
timbreId
;
public
java
.
lang
.
String
getTimbreId
(){
return
this
.
timbreId
;
}
public
void
setTimbreId
(
java
.
lang
.
String
timbreId
){
this
.
timbreId
=
timbreId
;
}
/** language
*音色语言分类 0-中文 1-粤语 2-英文
*/
private
java
.
lang
.
Integer
language
;
public
java
.
lang
.
Integer
getLanguage
(){
return
this
.
language
;
}
public
void
setLanguage
(
java
.
lang
.
Integer
language
){
this
.
language
=
language
;
}
/** timbre_name
*音色名-简体中文
*/
private
java
.
lang
.
String
timbreName
;
public
java
.
lang
.
String
getTimbreName
(){
return
this
.
timbreName
;
}
public
void
setTimbreName
(
java
.
lang
.
String
timbreName
){
this
.
timbreName
=
timbreName
;
}
/** timbre_name_en
*音色名-英文
*/
private
java
.
lang
.
String
timbreNameEn
;
public
java
.
lang
.
String
getTimbreNameEn
(){
return
this
.
timbreNameEn
;
}
public
void
setTimbreNameEn
(
java
.
lang
.
String
timbreNameEn
){
this
.
timbreNameEn
=
timbreNameEn
;
}
/** timbre_name_tw
*音色名-繁体
*/
private
java
.
lang
.
String
timbreNameTw
;
public
java
.
lang
.
String
getTimbreNameTw
(){
return
this
.
timbreNameTw
;
}
public
void
setTimbreNameTw
(
java
.
lang
.
String
timbreNameTw
){
this
.
timbreNameTw
=
timbreNameTw
;
}
/** voice_url
*音色预览地址
*/
private
java
.
lang
.
String
voiceUrl
;
public
java
.
lang
.
String
getVoiceUrl
(){
return
this
.
voiceUrl
;
}
public
void
setVoiceUrl
(
java
.
lang
.
String
voiceUrl
){
this
.
voiceUrl
=
voiceUrl
;
}
/** is_deleted
*是否删除 Y 是 N 否
*/
private
java
.
lang
.
String
isDeleted
;
public
java
.
lang
.
String
getIsDeleted
(){
return
this
.
isDeleted
;
}
public
void
setIsDeleted
(
java
.
lang
.
String
isDeleted
){
this
.
isDeleted
=
isDeleted
;
}
/** CREATOR
*创建人
*/
private
java
.
lang
.
String
creator
;
public
java
.
lang
.
String
getCreator
(){
return
this
.
creator
;
}
public
void
setCreator
(
java
.
lang
.
String
creator
){
this
.
creator
=
creator
;
}
/** CREATED_TIME
*创建时间
*/
private
java
.
util
.
Date
createdTime
;
public
java
.
util
.
Date
getCreatedTime
(){
return
this
.
createdTime
;
}
public
void
setCreatedTime
(
java
.
util
.
Date
createdTime
){
this
.
createdTime
=
createdTime
;
}
/** MODIFIER
*修改人
*/
private
java
.
lang
.
String
modifier
;
public
java
.
lang
.
String
getModifier
(){
return
this
.
modifier
;
}
public
void
setModifier
(
java
.
lang
.
String
modifier
){
this
.
modifier
=
modifier
;
}
/** MODIFIED_TIME
*修改时间
*/
private
java
.
util
.
Date
modifiedTime
;
public
java
.
util
.
Date
getModifiedTime
(){
return
this
.
modifiedTime
;
}
public
void
setModifiedTime
(
java
.
util
.
Date
modifiedTime
){
this
.
modifiedTime
=
modifiedTime
;
}
/** SYS_VERSION
*乐观锁,版本号
*/
private
java
.
lang
.
Integer
sysVersion
;
public
java
.
lang
.
Integer
getSysVersion
(){
return
this
.
sysVersion
;
}
public
void
setSysVersion
(
java
.
lang
.
Integer
sysVersion
){
this
.
sysVersion
=
sysVersion
;
}
}
\ No newline at end of file
src/main/java/cn/com/poc/timbre/model/BizVoiceTimbreModel.java
0 → 100644
View file @
cbfb29ad
package
cn
.
com
.
poc
.
timbre
.
model
;
import
java.io.Serializable
;
import
cn.com.yict.framemax.data.model.BaseModelClass
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.Table
;
import
javax.persistence.Id
;
import
org.hibernate.annotations.DynamicInsert
;
import
org.hibernate.annotations.DynamicUpdate
;
import
javax.persistence.Version
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.GenerationType
;
/**
* Model class for biz_voice_timbre
* 音频音色表
*/
@Entity
@Table
(
name
=
"biz_voice_timbre"
)
@DynamicInsert
@DynamicUpdate
public
class
BizVoiceTimbreModel
extends
BaseModelClass
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/** id
*主键
*/
private
java
.
lang
.
Integer
id
;
@Column
(
name
=
"id"
,
length
=
10
)
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
AUTO
)
public
java
.
lang
.
Integer
getId
(){
return
this
.
id
;
}
public
void
setId
(
java
.
lang
.
Integer
id
){
this
.
id
=
id
;
super
.
addValidField
(
"id"
);
}
/** timbre_id
*音色ID
*/
private
java
.
lang
.
String
timbreId
;
@Column
(
name
=
"timbre_id"
,
length
=
100
)
public
java
.
lang
.
String
getTimbreId
(){
return
this
.
timbreId
;
}
public
void
setTimbreId
(
java
.
lang
.
String
timbreId
){
this
.
timbreId
=
timbreId
;
super
.
addValidField
(
"timbreId"
);
}
/** language
*音色语言分类 0-中文 1-粤语 2-英文
*/
private
java
.
lang
.
Integer
language
;
@Column
(
name
=
"language"
,
length
=
10
)
public
java
.
lang
.
Integer
getLanguage
(){
return
this
.
language
;
}
public
void
setLanguage
(
java
.
lang
.
Integer
language
){
this
.
language
=
language
;
super
.
addValidField
(
"language"
);
}
/** timbre_name
*音色名-简体中文
*/
private
java
.
lang
.
String
timbreName
;
@Column
(
name
=
"timbre_name"
,
length
=
100
)
public
java
.
lang
.
String
getTimbreName
(){
return
this
.
timbreName
;
}
public
void
setTimbreName
(
java
.
lang
.
String
timbreName
){
this
.
timbreName
=
timbreName
;
super
.
addValidField
(
"timbreName"
);
}
/** timbre_name_en
*音色名-英文
*/
private
java
.
lang
.
String
timbreNameEn
;
@Column
(
name
=
"timbre_name_en"
,
length
=
100
)
public
java
.
lang
.
String
getTimbreNameEn
(){
return
this
.
timbreNameEn
;
}
public
void
setTimbreNameEn
(
java
.
lang
.
String
timbreNameEn
){
this
.
timbreNameEn
=
timbreNameEn
;
super
.
addValidField
(
"timbreNameEn"
);
}
/** timbre_name_tw
*音色名-繁体
*/
private
java
.
lang
.
String
timbreNameTw
;
@Column
(
name
=
"timbre_name_tw"
,
length
=
100
)
public
java
.
lang
.
String
getTimbreNameTw
(){
return
this
.
timbreNameTw
;
}
public
void
setTimbreNameTw
(
java
.
lang
.
String
timbreNameTw
){
this
.
timbreNameTw
=
timbreNameTw
;
super
.
addValidField
(
"timbreNameTw"
);
}
/** voice_url
*音色预览地址
*/
private
java
.
lang
.
String
voiceUrl
;
@Column
(
name
=
"voice_url"
,
length
=
120
)
public
java
.
lang
.
String
getVoiceUrl
(){
return
this
.
voiceUrl
;
}
public
void
setVoiceUrl
(
java
.
lang
.
String
voiceUrl
){
this
.
voiceUrl
=
voiceUrl
;
super
.
addValidField
(
"voiceUrl"
);
}
/** is_deleted
*是否删除 Y 是 N 否
*/
private
java
.
lang
.
String
isDeleted
;
@Column
(
name
=
"is_deleted"
,
length
=
1
)
public
java
.
lang
.
String
getIsDeleted
(){
return
this
.
isDeleted
;
}
public
void
setIsDeleted
(
java
.
lang
.
String
isDeleted
){
this
.
isDeleted
=
isDeleted
;
super
.
addValidField
(
"isDeleted"
);
}
/** CREATOR
*创建人
*/
private
java
.
lang
.
String
creator
;
@Column
(
name
=
"CREATOR"
,
length
=
50
)
public
java
.
lang
.
String
getCreator
(){
return
this
.
creator
;
}
public
void
setCreator
(
java
.
lang
.
String
creator
){
this
.
creator
=
creator
;
super
.
addValidField
(
"creator"
);
}
/** CREATED_TIME
*创建时间
*/
private
java
.
util
.
Date
createdTime
;
@Column
(
name
=
"CREATED_TIME"
,
length
=
19
)
public
java
.
util
.
Date
getCreatedTime
(){
return
this
.
createdTime
;
}
public
void
setCreatedTime
(
java
.
util
.
Date
createdTime
){
this
.
createdTime
=
createdTime
;
super
.
addValidField
(
"createdTime"
);
}
/** MODIFIER
*修改人
*/
private
java
.
lang
.
String
modifier
;
@Column
(
name
=
"MODIFIER"
,
length
=
50
)
public
java
.
lang
.
String
getModifier
(){
return
this
.
modifier
;
}
public
void
setModifier
(
java
.
lang
.
String
modifier
){
this
.
modifier
=
modifier
;
super
.
addValidField
(
"modifier"
);
}
/** MODIFIED_TIME
*修改时间
*/
private
java
.
util
.
Date
modifiedTime
;
@Column
(
name
=
"MODIFIED_TIME"
,
length
=
19
)
public
java
.
util
.
Date
getModifiedTime
(){
return
this
.
modifiedTime
;
}
public
void
setModifiedTime
(
java
.
util
.
Date
modifiedTime
){
this
.
modifiedTime
=
modifiedTime
;
super
.
addValidField
(
"modifiedTime"
);
}
/** SYS_VERSION
*乐观锁,版本号
*/
private
java
.
lang
.
Integer
sysVersion
;
@Column
(
name
=
"SYS_VERSION"
,
length
=
10
)
@Version
public
java
.
lang
.
Integer
getSysVersion
(){
return
this
.
sysVersion
;
}
public
void
setSysVersion
(
java
.
lang
.
Integer
sysVersion
){
this
.
sysVersion
=
sysVersion
;
super
.
addValidField
(
"sysVersion"
);
}
}
\ No newline at end of file
src/main/java/cn/com/poc/timbre/repository/BizVoiceTimbreRepository.java
0 → 100644
View file @
cbfb29ad
package
cn
.
com
.
poc
.
timbre
.
repository
;
import
cn.com.yict.framemax.data.repository.Repository
;
import
cn.com.poc.timbre.model.BizVoiceTimbreModel
;
public
interface
BizVoiceTimbreRepository
extends
Repository
<
BizVoiceTimbreModel
,
java
.
lang
.
Integer
>
{
}
\ No newline at end of file
src/main/java/cn/com/poc/timbre/rest/BizVoiceTimbreRest.java
0 → 100644
View file @
cbfb29ad
package
cn
.
com
.
poc
.
timbre
.
rest
;
import
cn.com.poc.timbre.dto.GetTimbreDto
;
import
cn.com.yict.framemax.core.rest.BaseRest
;
import
cn.com.yict.framemax.web.permission.Access
;
import
cn.com.yict.framemax.web.permission.Permission
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
java.util.List
;
@Permission
(
Access
.
Anonymous
)
public
interface
BizVoiceTimbreRest
extends
BaseRest
{
/**
* 获取音色列表
*
* @return
*/
List
<
GetTimbreDto
>
getTimbreList
()
throws
Exception
;
/**
* 获取音色详情
*
* @param timbreId
*/
GetTimbreDto
getTimbreInfo
(
@RequestParam
String
timbreId
)
;
}
\ No newline at end of file
src/main/java/cn/com/poc/timbre/rest/impl/BizVoiceTimbreRest.java
0 → 100644
View file @
cbfb29ad
package
cn
.
com
.
poc
.
timbre
.
rest
.
impl
;
import
cn.com.poc.timbre.convert.BizVoiceTimbreConvert
;
import
cn.com.poc.timbre.dto.GetTimbreDto
;
import
cn.com.poc.timbre.entity.BizVoiceTimbreEntity
;
import
cn.com.poc.timbre.service.BizVoiceTimbreService
;
import
cn.com.yict.framemax.core.context.Context
;
import
cn.hutool.core.lang.Assert
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Locale
;
import
static
cn
.
com
.
poc
.
timbre
.
convert
.
BizVoiceTimbreConvert
.
entityToGetTimbreDto
;
@Component
public
class
BizVoiceTimbreRest
implements
cn
.
com
.
poc
.
timbre
.
rest
.
BizVoiceTimbreRest
{
@Resource
private
BizVoiceTimbreService
bizVoiceTimbreService
;
@Override
public
List
<
GetTimbreDto
>
getTimbreList
()
throws
Exception
{
Locale
currentLocale
=
Context
.
get
().
getMessageSource
().
getCurrentLocale
();
List
<
GetTimbreDto
>
result
=
new
ArrayList
<>();
List
<
BizVoiceTimbreEntity
>
entities
=
bizVoiceTimbreService
.
findByExample
(
new
BizVoiceTimbreEntity
(),
null
);
if
(
CollectionUtils
.
isNotEmpty
(
entities
))
{
result
=
BizVoiceTimbreConvert
.
entitiesToGetTimbreDtoList
(
entities
,
currentLocale
);
}
return
result
;
}
@Override
public
GetTimbreDto
getTimbreInfo
(
String
timbreId
)
{
Assert
.
notNull
(
timbreId
);
BizVoiceTimbreEntity
bizVoiceTimbreEntity
=
bizVoiceTimbreService
.
getByTimbreId
(
timbreId
);
if
(
bizVoiceTimbreEntity
==
null
)
{
return
null
;
}
return
entityToGetTimbreDto
(
bizVoiceTimbreEntity
,
Context
.
get
().
getMessageSource
().
getCurrentLocale
());
}
}
\ No newline at end of file
src/main/java/cn/com/poc/timbre/service/BizVoiceTimbreService.java
0 → 100644
View file @
cbfb29ad
package
cn
.
com
.
poc
.
timbre
.
service
;
import
cn.com.poc.timbre.entity.BizVoiceTimbreEntity
;
import
cn.com.yict.framemax.core.service.BaseService
;
import
cn.com.yict.framemax.data.model.PagingInfo
;
import
java.util.List
;
public
interface
BizVoiceTimbreService
extends
BaseService
{
BizVoiceTimbreEntity
getByTimbreId
(
java
.
lang
.
String
timbreId
);
List
<
BizVoiceTimbreEntity
>
findByExample
(
BizVoiceTimbreEntity
example
,
PagingInfo
pagingInfo
)
throws
Exception
;
}
\ No newline at end of file
src/main/java/cn/com/poc/timbre/service/impl/BizVoiceTimbreServiceImpl.java
0 → 100644
View file @
cbfb29ad
package
cn
.
com
.
poc
.
timbre
.
service
.
impl
;
import
cn.com.poc.common.constant.CommonConstant
;
import
cn.com.yict.framemax.core.service.impl.BaseServiceImpl
;
import
cn.com.poc.timbre.service.BizVoiceTimbreService
;
import
cn.com.poc.timbre.model.BizVoiceTimbreModel
;
import
cn.com.poc.timbre.entity.BizVoiceTimbreEntity
;
import
cn.com.poc.timbre.convert.BizVoiceTimbreConvert
;
import
cn.com.poc.timbre.repository.BizVoiceTimbreRepository
;
import
cn.com.yict.framemax.data.model.PagingInfo
;
import
org.springframework.stereotype.Service
;
import
org.apache.commons.collections4.CollectionUtils
;
import
java.util.ArrayList
;
import
java.util.stream.Collectors
;
import
java.util.List
;
import
javax.annotation.Resource
;
import
org.springframework.util.Assert
;
@Service
public
class
BizVoiceTimbreServiceImpl
extends
BaseServiceImpl
implements
BizVoiceTimbreService
{
@Resource
private
BizVoiceTimbreRepository
repository
;
@Override
public
BizVoiceTimbreEntity
getByTimbreId
(
String
timbreId
)
{
BizVoiceTimbreModel
bizVoiceTimbreModel
=
new
BizVoiceTimbreModel
();
bizVoiceTimbreModel
.
setTimbreId
(
timbreId
);
bizVoiceTimbreModel
.
setIsDeleted
(
CommonConstant
.
IsDeleted
.
N
);
List
<
BizVoiceTimbreModel
>
models
=
this
.
repository
.
findByExample
(
bizVoiceTimbreModel
);
if
(
CollectionUtils
.
isNotEmpty
(
models
))
{
return
BizVoiceTimbreConvert
.
modelToEntity
(
models
.
get
(
0
));
}
return
null
;
}
@Override
public
List
<
BizVoiceTimbreEntity
>
findByExample
(
BizVoiceTimbreEntity
example
,
PagingInfo
pagingInfo
)
throws
Exception
{
List
<
BizVoiceTimbreEntity
>
result
=
new
ArrayList
<
BizVoiceTimbreEntity
>();
BizVoiceTimbreModel
model
=
new
BizVoiceTimbreModel
();
if
(
example
!=
null
)
{
model
=
BizVoiceTimbreConvert
.
entityToModel
(
example
);
}
model
.
setIsDeleted
(
"N"
);
List
<
BizVoiceTimbreModel
>
models
=
this
.
repository
.
findByExample
(
model
,
pagingInfo
);
if
(
CollectionUtils
.
isNotEmpty
(
models
))
{
result
=
models
.
stream
().
map
(
BizVoiceTimbreConvert:
:
modelToEntity
).
collect
(
Collectors
.
toList
());
}
return
result
;
}
}
\ No newline at end of file
src/main/java/cn/com/poc/user/aggregation/MemberInfoService.java
View file @
cbfb29ad
package
cn
.
com
.
poc
.
user
.
aggregation
;
package
cn
.
com
.
poc
.
user
.
aggregation
;
import
cn.com.poc.user.dto.MemberPasswordRequestDto
;
import
cn.com.poc.user.dto.MemberPasswordRequestDto
;
import
cn.com.poc.user.entity.MemberInfoEntity
;
import
cn.com.yict.framemax.core.service.BaseService
;
import
cn.com.yict.framemax.core.service.BaseService
;
/**
/**
...
@@ -11,9 +12,17 @@ import cn.com.yict.framemax.core.service.BaseService;
...
@@ -11,9 +12,17 @@ import cn.com.yict.framemax.core.service.BaseService;
public
interface
MemberInfoService
extends
BaseService
{
public
interface
MemberInfoService
extends
BaseService
{
/**
/**
*
* @param memberPasswordRequestDto
* @param memberPasswordRequestDto
*/
*/
void
configureMemberPassword
(
MemberPasswordRequestDto
memberPasswordRequestDto
)
throws
Exception
;
void
configureMemberPassword
(
MemberPasswordRequestDto
memberPasswordRequestDto
)
throws
Exception
;
/**
* 更新用户信息
*
* @param memberInfoEntity
* @return
* @throws Exception
*/
MemberInfoEntity
updateMemberInfo
(
MemberInfoEntity
memberInfoEntity
);
}
}
src/main/java/cn/com/poc/user/aggregation/impl/MemberInfoServiceImpl.java
View file @
cbfb29ad
...
@@ -2,18 +2,23 @@ package cn.com.poc.user.aggregation.impl;
...
@@ -2,18 +2,23 @@ package cn.com.poc.user.aggregation.impl;
import
cn.com.poc.common.constant.RedisKeyConstant
;
import
cn.com.poc.common.constant.RedisKeyConstant
;
import
cn.com.poc.common.service.RedisService
;
import
cn.com.poc.common.service.RedisService
;
import
cn.com.poc.common.utils.StringUtils
;
import
cn.com.poc.user.dto.MemberPasswordRequestDto
;
import
cn.com.poc.user.dto.MemberPasswordRequestDto
;
import
cn.com.poc.user.aggregation.MemberInfoService
;
import
cn.com.poc.user.aggregation.MemberInfoService
;
import
cn.com.poc.user.constants.Member3rdPartyRelationConstants
;
import
cn.com.poc.user.constants.Member3rdPartyRelationConstants
;
import
cn.com.poc.user.entity.Member3rdPartyRelationEntity
;
import
cn.com.poc.user.entity.Member3rdPartyRelationEntity
;
import
cn.com.poc.user.entity.MemberInfoEntity
;
import
cn.com.poc.user.entity.MemberInfoEntity
;
import
cn.com.poc.user.query.CheckMemberInfoQueryCondition
;
import
cn.com.poc.user.query.CheckMemberInfoQueryItem
;
import
cn.com.poc.user.service.BizMember3rdPartyRelationService
;
import
cn.com.poc.user.service.BizMember3rdPartyRelationService
;
import
cn.com.poc.user.service.BizMemberInfoService
;
import
cn.com.poc.user.service.BizMemberInfoService
;
import
cn.com.yict.framemax.core.i18n.I18nMessageException
;
import
cn.com.yict.framemax.core.i18n.I18nMessageException
;
import
cn.com.yict.framemax.core.service.impl.BaseServiceImpl
;
import
cn.com.yict.framemax.core.service.impl.BaseServiceImpl
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.List
;
/**
/**
* @Author:Roger Wu
* @Author:Roger Wu
...
@@ -37,17 +42,23 @@ public class MemberInfoServiceImpl extends BaseServiceImpl implements MemberInfo
...
@@ -37,17 +42,23 @@ public class MemberInfoServiceImpl extends BaseServiceImpl implements MemberInfo
@Override
@Override
public
void
configureMemberPassword
(
MemberPasswordRequestDto
memberPasswordRequestDto
)
throws
Exception
{
public
void
configureMemberPassword
(
MemberPasswordRequestDto
memberPasswordRequestDto
)
throws
Exception
{
MemberInfoEntity
memberInfoEntity
=
bizMemberInfoService
.
getMemberEntityByAccount
(
memberPasswordRequestDto
.
getAccount
());
if
(
memberInfoEntity
==
null
)
{
throw
new
I18nMessageException
(
"exception/user.cannot.be.found"
);
}
String
authCode
=
(
String
)
redisService
.
get
(
RedisKeyConstant
.
Code
.
AUTH_CODE
+
memberPasswordRequestDto
.
getAccount
());
String
authCode
=
(
String
)
redisService
.
get
(
RedisKeyConstant
.
Code
.
AUTH_CODE
+
memberPasswordRequestDto
.
getAccount
());
if
(
StringUtils
.
isBlank
(
authCode
)
&&
StringUtils
.
isNotBlank
(
memberInfoEntity
.
getMobilePhone
()))
{
authCode
=
(
String
)
redisService
.
get
(
RedisKeyConstant
.
Code
.
AUTH_CODE
+
memberInfoEntity
.
getMobilePhone
());
}
if
(
StringUtils
.
isBlank
(
authCode
)
&&
StringUtils
.
isNotBlank
(
memberInfoEntity
.
getEmail
()))
{
authCode
=
(
String
)
redisService
.
get
(
RedisKeyConstant
.
Code
.
AUTH_CODE
+
memberInfoEntity
.
getEmail
());
}
if
(!
memberPasswordRequestDto
.
getAuthCode
().
equals
(
authCode
))
{
if
(!
memberPasswordRequestDto
.
getAuthCode
().
equals
(
authCode
))
{
throw
new
I18nMessageException
(
"exception/re-verify.the.user.identity"
);
throw
new
I18nMessageException
(
"exception/re-verify.the.user.identity"
);
}
}
MemberInfoEntity
memberInfoEntity
=
bizMemberInfoService
.
getMemberEntityByAccount
(
memberPasswordRequestDto
.
getAccount
());
if
(
memberInfoEntity
==
null
)
{
throw
new
I18nMessageException
(
"exception/user.cannot.be.found"
);
}
Member3rdPartyRelationEntity
member3rdPartyRelationEntity
=
bizMember3rdPartyRelationService
.
getPwRelationByMemberId
(
memberInfoEntity
.
getMemberId
());
Member3rdPartyRelationEntity
member3rdPartyRelationEntity
=
bizMember3rdPartyRelationService
.
getPwRelationByMemberId
(
memberInfoEntity
.
getMemberId
());
if
(
member3rdPartyRelationEntity
==
null
)
{
if
(
member3rdPartyRelationEntity
==
null
)
{
member3rdPartyRelationEntity
=
new
Member3rdPartyRelationEntity
();
member3rdPartyRelationEntity
=
new
Member3rdPartyRelationEntity
();
...
@@ -59,4 +70,27 @@ public class MemberInfoServiceImpl extends BaseServiceImpl implements MemberInfo
...
@@ -59,4 +70,27 @@ public class MemberInfoServiceImpl extends BaseServiceImpl implements MemberInfo
redisService
.
del
(
RedisKeyConstant
.
Code
.
AUTH_CODE
+
memberPasswordRequestDto
.
getAccount
());
redisService
.
del
(
RedisKeyConstant
.
Code
.
AUTH_CODE
+
memberPasswordRequestDto
.
getAccount
());
}
}
@Override
public
MemberInfoEntity
updateMemberInfo
(
MemberInfoEntity
memberInfoEntity
)
{
if
(
StringUtils
.
isNotBlank
(
memberInfoEntity
.
getMobilePhone
()))
{
CheckMemberInfoQueryCondition
condition
=
new
CheckMemberInfoQueryCondition
();
condition
.
setMemberId
(
memberInfoEntity
.
getMemberId
().
longValue
());
condition
.
setMobilePhone
(
memberInfoEntity
.
getMobilePhone
());
List
<
CheckMemberInfoQueryItem
>
checkMemberInfoQueryItems
=
bizMemberInfoService
.
checkMemberInfoIsExist
(
condition
);
if
(
CollectionUtils
.
isNotEmpty
(
checkMemberInfoQueryItems
))
{
throw
new
I18nMessageException
(
"exception/phone.is.exist"
);
}
}
if
(
StringUtils
.
isNotBlank
(
memberInfoEntity
.
getEmail
()))
{
CheckMemberInfoQueryCondition
condition
=
new
CheckMemberInfoQueryCondition
();
condition
.
setMemberId
(
memberInfoEntity
.
getMemberId
().
longValue
());
condition
.
setEmail
(
memberInfoEntity
.
getEmail
());
List
<
CheckMemberInfoQueryItem
>
checkMemberInfoQueryItems
=
bizMemberInfoService
.
checkMemberInfoIsExist
(
condition
);
if
(
CollectionUtils
.
isNotEmpty
(
checkMemberInfoQueryItems
))
{
throw
new
I18nMessageException
(
"exception/email.is.exist"
);
}
}
return
bizMemberInfoService
.
updateMemberInfo
(
memberInfoEntity
);
}
}
}
src/main/java/cn/com/poc/user/builder/EmailLoginChannel.java
View file @
cbfb29ad
...
@@ -5,13 +5,17 @@ import cn.com.poc.common.utils.Assert;
...
@@ -5,13 +5,17 @@ import cn.com.poc.common.utils.Assert;
import
cn.com.poc.common.utils.StringUtils
;
import
cn.com.poc.common.utils.StringUtils
;
import
cn.com.poc.user.dto.MemberLoginRequestDto
;
import
cn.com.poc.user.dto.MemberLoginRequestDto
;
import
cn.com.poc.user.entity.MemberInfoEntity
;
import
cn.com.poc.user.entity.MemberInfoEntity
;
import
cn.com.poc.user.query.CheckMemberInfoQueryCondition
;
import
cn.com.poc.user.query.CheckMemberInfoQueryItem
;
import
cn.com.poc.user.service.BizMemberInfoService
;
import
cn.com.poc.user.service.BizMemberInfoService
;
import
cn.com.yict.framemax.core.i18n.I18nMessageException
;
import
cn.com.yict.framemax.core.i18n.I18nMessageException
;
import
cn.com.yict.framemax.data.model.BaseModel
;
import
cn.com.yict.framemax.data.model.BaseModel
;
import
cn.com.yict.framemax.frame.service.FmxParamConfigService
;
import
cn.com.yict.framemax.frame.service.FmxParamConfigService
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.List
;
@Component
@Component
public
class
EmailLoginChannel
implements
LoginChannelService
{
public
class
EmailLoginChannel
implements
LoginChannelService
{
...
@@ -30,20 +34,35 @@ public class EmailLoginChannel implements LoginChannelService {
...
@@ -30,20 +34,35 @@ public class EmailLoginChannel implements LoginChannelService {
if
(!
judgeCodeService
.
judgeCode
(
memberLoginRequest
.
getAccount
(),
memberLoginRequest
.
getAuthCode
()))
{
if
(!
judgeCodeService
.
judgeCode
(
memberLoginRequest
.
getAccount
(),
memberLoginRequest
.
getAuthCode
()))
{
throw
new
I18nMessageException
(
"exception/verification.code.is.incorrect.please.re-enter"
);
throw
new
I18nMessageException
(
"exception/verification.code.is.incorrect.please.re-enter"
);
}
}
MemberInfoEntity
result
=
bizMemberInfoService
.
getMemberEntityByAccount
(
memberLoginRequest
.
getAccount
());
MemberInfoEntity
memberEntityByAccount
=
bizMemberInfoService
.
getMemberEntityByAccount
(
memberLoginRequest
.
getAccount
());
if
(
result
==
null
)
{
if
(
memberEntityByAccount
==
null
)
{
//用户没有注册过 需要注册
CheckMemberInfoQueryCondition
condition
=
new
CheckMemberInfoQueryCondition
();
MemberInfoEntity
memberInfoEntity
=
new
MemberInfoEntity
();
condition
.
setEmail
(
memberLoginRequest
.
getAccount
());
memberInfoEntity
.
setAccount
(
memberLoginRequest
.
getAccount
());
List
<
CheckMemberInfoQueryItem
>
checkMemberInfoQueryItems
=
bizMemberInfoService
.
checkMemberInfoIsExist
(
condition
);
memberInfoEntity
.
setNickName
(
memberLoginRequest
.
getAccount
());
if
(
CollectionUtils
.
isEmpty
(
checkMemberInfoQueryItems
))
{
//用户没有注册过 需要注册
memberInfoEntity
.
setEmail
(
memberLoginRequest
.
getAccount
());
result
=
registerByEmail
(
memberLoginRequest
);
String
param
=
fmxParamConfigService
.
getParam
(
"member.default.avatar"
);
}
else
{
//用户已经注册过 直接登录
if
(
StringUtils
.
isNoneBlank
(
param
))
{
CheckMemberInfoQueryItem
checkMemberInfoQueryItem
=
checkMemberInfoQueryItems
.
get
(
0
);
memberInfoEntity
.
setAvatarUrl
(
param
);
Integer
memberId
=
checkMemberInfoQueryItem
.
getMemberId
();
result
=
bizMemberInfoService
.
getById
(
memberId
);
}
}
return
bizMemberInfoService
.
createMemberInfo
(
memberInfoEntity
);
}
}
return
memberEntityByAccount
;
return
result
;
}
private
MemberInfoEntity
registerByEmail
(
MemberLoginRequestDto
memberLoginRequest
)
{
MemberInfoEntity
result
;
MemberInfoEntity
memberInfoEntity
=
new
MemberInfoEntity
();
memberInfoEntity
.
setAccount
(
memberLoginRequest
.
getAccount
());
memberInfoEntity
.
setNickName
(
memberLoginRequest
.
getAccount
());
memberInfoEntity
.
setEmail
(
memberLoginRequest
.
getAccount
());
String
param
=
fmxParamConfigService
.
getParam
(
"member.default.avatar"
);
if
(
StringUtils
.
isNoneBlank
(
param
))
{
memberInfoEntity
.
setAvatarUrl
(
param
);
}
result
=
bizMemberInfoService
.
createMemberInfo
(
memberInfoEntity
);
return
result
;
}
}
}
}
src/main/java/cn/com/poc/user/builder/SmsLoginChannel.java
View file @
cbfb29ad
...
@@ -5,12 +5,16 @@ import cn.com.poc.common.utils.Assert;
...
@@ -5,12 +5,16 @@ import cn.com.poc.common.utils.Assert;
import
cn.com.poc.common.utils.StringUtils
;
import
cn.com.poc.common.utils.StringUtils
;
import
cn.com.poc.user.dto.MemberLoginRequestDto
;
import
cn.com.poc.user.dto.MemberLoginRequestDto
;
import
cn.com.poc.user.entity.MemberInfoEntity
;
import
cn.com.poc.user.entity.MemberInfoEntity
;
import
cn.com.poc.user.query.CheckMemberInfoQueryCondition
;
import
cn.com.poc.user.query.CheckMemberInfoQueryItem
;
import
cn.com.poc.user.service.BizMemberInfoService
;
import
cn.com.poc.user.service.BizMemberInfoService
;
import
cn.com.yict.framemax.core.i18n.I18nMessageException
;
import
cn.com.yict.framemax.core.i18n.I18nMessageException
;
import
cn.com.yict.framemax.frame.service.FmxParamConfigService
;
import
cn.com.yict.framemax.frame.service.FmxParamConfigService
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.List
;
/**
/**
* @Author:Roger Wu
* @Author:Roger Wu
...
@@ -39,20 +43,35 @@ public class SmsLoginChannel implements LoginChannelService {
...
@@ -39,20 +43,35 @@ public class SmsLoginChannel implements LoginChannelService {
throw
new
I18nMessageException
(
"exception/verification.code.is.incorrect.please.re-enter"
);
throw
new
I18nMessageException
(
"exception/verification.code.is.incorrect.please.re-enter"
);
}
}
MemberInfoEntity
memberEntityByAccount
=
bizMemberInfoService
.
getMemberEntityByAccount
(
memberLoginRequest
.
getAccount
());
MemberInfoEntity
result
=
bizMemberInfoService
.
getMemberEntityByAccount
(
memberLoginRequest
.
getAccount
());
if
(
memberEntityByAccount
==
null
)
{
//用户没有注册过 需要注册
if
(
result
==
null
)
{
//用户没有注册过 需要注册
MemberInfoEntity
memberInfoEntity
=
new
MemberInfoEntity
();
CheckMemberInfoQueryCondition
condition
=
new
CheckMemberInfoQueryCondition
();
memberInfoEntity
.
setAccount
(
memberLoginRequest
.
getAccount
());
condition
.
setMobilePhone
(
memberLoginRequest
.
getAccount
());
memberInfoEntity
.
setNickName
(
memberLoginRequest
.
getAccount
());
List
<
CheckMemberInfoQueryItem
>
checkMemberInfoQueryItems
=
bizMemberInfoService
.
checkMemberInfoIsExist
(
condition
);
String
param
=
fmxParamConfigService
.
getParam
(
"member.default.avatar"
);
if
(
CollectionUtils
.
isEmpty
(
checkMemberInfoQueryItems
))
{
if
(
StringUtils
.
isNoneBlank
(
param
))
{
result
=
registerByMobilePhone
(
memberLoginRequest
);
memberInfoEntity
.
setAvatarUrl
(
param
);
}
else
{
//用户已经注册过 直接登录
CheckMemberInfoQueryItem
checkMemberInfoQueryItem
=
checkMemberInfoQueryItems
.
get
(
0
);
Integer
memberId
=
checkMemberInfoQueryItem
.
getMemberId
();
result
=
bizMemberInfoService
.
getById
(
memberId
);
}
}
memberInfoEntity
.
setMobilePhone
(
memberLoginRequest
.
getAccount
());
return
bizMemberInfoService
.
createMemberInfo
(
memberInfoEntity
);
}
}
return
memberEntityByAccount
;
return
result
;
}
private
MemberInfoEntity
registerByMobilePhone
(
MemberLoginRequestDto
memberLoginRequest
)
{
MemberInfoEntity
result
;
MemberInfoEntity
memberInfoEntity
=
new
MemberInfoEntity
();
memberInfoEntity
.
setAccount
(
memberLoginRequest
.
getAccount
());
memberInfoEntity
.
setNickName
(
memberLoginRequest
.
getAccount
());
String
param
=
fmxParamConfigService
.
getParam
(
"member.default.avatar"
);
if
(
StringUtils
.
isNoneBlank
(
param
))
{
memberInfoEntity
.
setAvatarUrl
(
param
);
}
memberInfoEntity
.
setMobilePhone
(
memberLoginRequest
.
getAccount
());
result
=
bizMemberInfoService
.
createMemberInfo
(
memberInfoEntity
);
return
result
;
}
}
...
...
src/main/java/cn/com/poc/user/query/CheckMemberInfoQuery.sql
0 → 100644
View file @
cbfb29ad
select
member_id
,
account
,
mobile_phone
,
email
,
is_deleted
from
biz_member_info
where
is_deleted
=
'N'
<<
and
member_id
!=
:
memberId
>>
<<
and
mobile_phone
=
:
mobilePhone
or
account
=
:
mobilePhone
>>
<<
and
email
=
:
email
or
account
=
:
email
>>
\ No newline at end of file
src/main/java/cn/com/poc/user/query/CheckMemberInfoQueryCondition.java
0 → 100644
View file @
cbfb29ad
package
cn
.
com
.
poc
.
user
.
query
;
import
java.io.Serializable
;
/**
* Query Condition class for CheckMemberInfoQuery
*/
public
class
CheckMemberInfoQueryCondition
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
java
.
lang
.
Long
memberId
;
public
java
.
lang
.
Long
getMemberId
(){
return
this
.
memberId
;
}
public
void
setMemberId
(
java
.
lang
.
Long
memberId
){
this
.
memberId
=
memberId
;
}
private
java
.
lang
.
String
mobilePhone
;
public
java
.
lang
.
String
getMobilePhone
(){
return
this
.
mobilePhone
;
}
public
void
setMobilePhone
(
java
.
lang
.
String
mobilePhone
){
this
.
mobilePhone
=
mobilePhone
;
}
private
java
.
lang
.
String
email
;
public
java
.
lang
.
String
getEmail
(){
return
this
.
email
;
}
public
void
setEmail
(
java
.
lang
.
String
email
){
this
.
email
=
email
;
}
}
\ No newline at end of file
src/main/java/cn/com/poc/user/query/CheckMemberInfoQueryItem.java
0 → 100644
View file @
cbfb29ad
package
cn
.
com
.
poc
.
user
.
query
;
import
java.io.Serializable
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
cn.com.yict.framemax.data.model.BaseItemClass
;
/**
* Query Item class for CheckMemberInfoQuery
*/
@Entity
public
class
CheckMemberInfoQueryItem
extends
BaseItemClass
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/** member_id
*member_id
*/
private
java
.
lang
.
Integer
memberId
;
@Column
(
name
=
"member_id"
)
public
java
.
lang
.
Integer
getMemberId
(){
return
this
.
memberId
;
}
public
void
setMemberId
(
java
.
lang
.
Integer
memberId
){
this
.
memberId
=
memberId
;
}
/** account
*account
*/
private
java
.
lang
.
String
account
;
@Column
(
name
=
"account"
)
public
java
.
lang
.
String
getAccount
(){
return
this
.
account
;
}
public
void
setAccount
(
java
.
lang
.
String
account
){
this
.
account
=
account
;
}
/** mobile_phone
*mobile_phone
*/
private
java
.
lang
.
String
mobilePhone
;
@Column
(
name
=
"mobile_phone"
)
public
java
.
lang
.
String
getMobilePhone
(){
return
this
.
mobilePhone
;
}
public
void
setMobilePhone
(
java
.
lang
.
String
mobilePhone
){
this
.
mobilePhone
=
mobilePhone
;
}
/** email
*email
*/
private
java
.
lang
.
String
email
;
@Column
(
name
=
"email"
)
public
java
.
lang
.
String
getEmail
(){
return
this
.
email
;
}
public
void
setEmail
(
java
.
lang
.
String
email
){
this
.
email
=
email
;
}
/** is_deleted
*is_deleted
*/
private
java
.
lang
.
String
isDeleted
;
@Column
(
name
=
"is_deleted"
)
public
java
.
lang
.
String
getIsDeleted
(){
return
this
.
isDeleted
;
}
public
void
setIsDeleted
(
java
.
lang
.
String
isDeleted
){
this
.
isDeleted
=
isDeleted
;
}
}
\ No newline at end of file
src/main/java/cn/com/poc/user/rest/BizMemberInfoRest.java
View file @
cbfb29ad
...
@@ -8,7 +8,6 @@ import cn.com.poc.user.dto.MemberPasswordRequestDto;
...
@@ -8,7 +8,6 @@ import cn.com.poc.user.dto.MemberPasswordRequestDto;
import
cn.com.yict.framemax.core.rest.BaseRest
;
import
cn.com.yict.framemax.core.rest.BaseRest
;
import
cn.com.yict.framemax.web.permission.Access
;
import
cn.com.yict.framemax.web.permission.Access
;
import
cn.com.yict.framemax.web.permission.Permission
;
import
cn.com.yict.framemax.web.permission.Permission
;
import
org.springframework.security.core.parameters.P
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
...
@@ -28,8 +27,11 @@ public interface BizMemberInfoRest extends BaseRest {
...
@@ -28,8 +27,11 @@ public interface BizMemberInfoRest extends BaseRest {
/**
/**
* 用户更改密码
* 用户更改密码
*
* @param authCode 校验码
* @param password 新密码
*/
*/
void
changeMemberPassword
(
@Request
Body
MemberPasswordRequestDto
memberPasswordRequestDto
)
throws
Exception
;
void
changeMemberPassword
(
@Request
Param
String
authCode
,
@RequestParam
String
password
)
throws
Exception
;
/**
/**
* 用户忘记密码
* 用户忘记密码
...
@@ -49,4 +51,10 @@ public interface BizMemberInfoRest extends BaseRest {
...
@@ -49,4 +51,10 @@ public interface BizMemberInfoRest extends BaseRest {
*/
*/
@Permission
(
Access
.
Anonymous
)
@Permission
(
Access
.
Anonymous
)
MemberInfoDto
getMemberNickName
(
@RequestParam
Long
memberId
)
throws
Exception
;
MemberInfoDto
getMemberNickName
(
@RequestParam
Long
memberId
)
throws
Exception
;
/**
* 修改用户信息
*/
MemberInfoDto
updateMemberInfo
(
@RequestBody
MemberInfoDto
memberInfoDto
);
}
}
\ No newline at end of file
src/main/java/cn/com/poc/user/rest/impl/BizMemberInfoRestImpl.java
View file @
cbfb29ad
package
cn
.
com
.
poc
.
user
.
rest
.
impl
;
package
cn
.
com
.
poc
.
user
.
rest
.
impl
;
import
javax.annotation.Resource
;
import
cn.com.poc.common.utils.Assert
;
import
cn.com.poc.common.utils.Assert
;
import
cn.com.poc.common.utils.BlContext
;
import
cn.com.poc.common.utils.BlContext
;
import
cn.com.poc.support.security.oauth.constants.OauthConstants
;
import
cn.com.poc.support.security.oauth.constants.OauthConstants
;
import
cn.com.poc.support.security.oauth.entity.UserBaseEntity
;
import
cn.com.poc.user.aggregation.MemberInfoService
;
import
cn.com.poc.user.builder.LoginChannelBuilder
;
import
cn.com.poc.user.convert.MemberInfoConvert
;
import
cn.com.poc.user.convert.MemberInfoConvert
;
import
cn.com.poc.user.dto.MemberInfoDto
;
import
cn.com.poc.user.dto.MemberInfoDto
;
import
cn.com.poc.user.dto.MemberLoginRequestDto
;
import
cn.com.poc.user.dto.MemberLoginRequestDto
;
import
cn.com.poc.user.dto.MemberLoginResponseDto
;
import
cn.com.poc.user.dto.MemberLoginResponseDto
;
import
cn.com.poc.user.dto.MemberPasswordRequestDto
;
import
cn.com.poc.user.dto.MemberPasswordRequestDto
;
import
cn.com.poc.user.aggregation.MemberInfoService
;
import
cn.com.poc.user.builder.LoginChannelBuilder
;
import
cn.com.poc.user.entity.MemberInfoEntity
;
import
cn.com.poc.user.entity.MemberInfoEntity
;
import
cn.com.poc.user.rest.BizMemberInfoRest
;
import
cn.com.poc.user.service.BizMemberInfoService
;
import
cn.com.poc.user.service.BizMemberInfoService
;
import
cn.com.yict.framemax.core.i18n.I18nMessageException
;
import
cn.com.yict.framemax.core.i18n.I18nMessageException
;
import
cn.com.yict.framemax.security.oauth.OauthAccesstokenManager
;
import
cn.com.yict.framemax.security.oauth.OauthAccesstokenManager
;
import
cn.com.yict.framemax.security.oauth.entity.OauthResultEntity
;
import
cn.com.yict.framemax.security.oauth.entity.OauthResultEntity
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
cn.com.poc.user.rest.BizMemberInfoRest
;
import
javax.annotation.Resource
;
@Component
@Component
public
class
BizMemberInfoRestImpl
implements
BizMemberInfoRest
{
public
class
BizMemberInfoRestImpl
implements
BizMemberInfoRest
{
...
@@ -77,14 +78,18 @@ public class BizMemberInfoRestImpl implements BizMemberInfoRest {
...
@@ -77,14 +78,18 @@ public class BizMemberInfoRestImpl implements BizMemberInfoRest {
/**
/**
* 用户更改密码
* 用户更改密码
*
* @param memberPasswordRequestDto
*/
*/
@Override
@Override
public
void
changeMemberPassword
(
MemberPasswordRequestDto
memberPasswordRequestDto
)
throws
Exception
{
public
void
changeMemberPassword
(
String
authCode
,
String
password
)
throws
Exception
{
Assert
.
notBlank
(
memberPasswordRequestDto
.
getAccount
());
Assert
.
notBlank
(
password
);
Assert
.
notBlank
(
memberPasswordRequestDto
.
getPassword
());
Assert
.
notBlank
(
authCode
);
Assert
.
notBlank
(
memberPasswordRequestDto
.
getAuthCode
());
UserBaseEntity
currentUser
=
BlContext
.
getCurrentUser
();
MemberInfoEntity
memberInfoEntity
=
bizMemberInfoService
.
getById
(
currentUser
.
getUserId
().
intValue
());
MemberPasswordRequestDto
memberPasswordRequestDto
=
new
MemberPasswordRequestDto
();
memberPasswordRequestDto
.
setAccount
(
memberInfoEntity
.
getAccount
());
memberPasswordRequestDto
.
setPassword
(
password
);
memberPasswordRequestDto
.
setAuthCode
(
authCode
);
memberInfoService
.
configureMemberPassword
(
memberPasswordRequestDto
);
memberInfoService
.
configureMemberPassword
(
memberPasswordRequestDto
);
}
}
...
@@ -124,4 +129,16 @@ public class BizMemberInfoRestImpl implements BizMemberInfoRest {
...
@@ -124,4 +129,16 @@ public class BizMemberInfoRestImpl implements BizMemberInfoRest {
memberInfoDto
.
setAvatarUrl
(
memberInfoEntity
.
getAvatarUrl
());
memberInfoDto
.
setAvatarUrl
(
memberInfoEntity
.
getAvatarUrl
());
return
memberInfoDto
;
return
memberInfoDto
;
}
}
@Override
public
MemberInfoDto
updateMemberInfo
(
MemberInfoDto
memberInfoDto
)
{
UserBaseEntity
userBaseEntity
=
BlContext
.
getCurrentUserNotException
();
if
(
userBaseEntity
==
null
)
{
throw
new
I18nMessageException
(
"exception/user.not.login"
);
}
MemberInfoEntity
memberInfoEntity
=
MemberInfoConvert
.
convertDto2Entity
(
memberInfoDto
);
memberInfoEntity
.
setMemberId
(
userBaseEntity
.
getUserId
().
intValue
());
MemberInfoEntity
entity
=
memberInfoService
.
updateMemberInfo
(
memberInfoEntity
);
return
MemberInfoConvert
.
converEntity2Dto
(
entity
);
}
}
}
\ No newline at end of file
src/main/java/cn/com/poc/user/service/BizMemberInfoService.java
View file @
cbfb29ad
package
cn
.
com
.
poc
.
user
.
service
;
package
cn
.
com
.
poc
.
user
.
service
;
import
cn.com.poc.user.entity.MemberInfoEntity
;
import
cn.com.poc.user.entity.MemberInfoEntity
;
import
cn.com.poc.user.query.CheckMemberInfoQueryCondition
;
import
cn.com.poc.user.query.CheckMemberInfoQueryItem
;
import
cn.com.yict.framemax.core.service.BaseService
;
import
cn.com.yict.framemax.core.service.BaseService
;
import
java.util.List
;
public
interface
BizMemberInfoService
extends
BaseService
{
public
interface
BizMemberInfoService
extends
BaseService
{
MemberInfoEntity
getById
(
Integer
memberId
)
throws
Exception
;
MemberInfoEntity
getById
(
Integer
memberId
)
throws
Exception
;
MemberInfoEntity
getMemberEntityByAccount
(
String
account
)
throws
Exception
;
MemberInfoEntity
getMemberEntityByAccount
(
String
account
)
throws
Exception
;
...
@@ -14,4 +18,14 @@ public interface BizMemberInfoService extends BaseService {
...
@@ -14,4 +18,14 @@ public interface BizMemberInfoService extends BaseService {
* @return
* @return
*/
*/
MemberInfoEntity
createMemberInfo
(
MemberInfoEntity
memberInfoEntity
);
MemberInfoEntity
createMemberInfo
(
MemberInfoEntity
memberInfoEntity
);
MemberInfoEntity
updateMemberInfo
(
MemberInfoEntity
memberInfoEntity
);
/**
* 查询会员信息是否存在
*
* @param condition
* @return
*/
List
<
CheckMemberInfoQueryItem
>
checkMemberInfoIsExist
(
CheckMemberInfoQueryCondition
condition
);
}
}
\ No newline at end of file
src/main/java/cn/com/poc/user/service/impl/BizMemberInfoServiceImpl.java
View file @
cbfb29ad
...
@@ -6,6 +6,8 @@ import cn.com.poc.common.utils.StringUtils;
...
@@ -6,6 +6,8 @@ import cn.com.poc.common.utils.StringUtils;
import
cn.com.poc.common.utils.UUIDTool
;
import
cn.com.poc.common.utils.UUIDTool
;
import
cn.com.poc.user.convert.MemberInfoConvert
;
import
cn.com.poc.user.convert.MemberInfoConvert
;
import
cn.com.poc.user.entity.MemberInfoEntity
;
import
cn.com.poc.user.entity.MemberInfoEntity
;
import
cn.com.poc.user.query.CheckMemberInfoQueryCondition
;
import
cn.com.poc.user.query.CheckMemberInfoQueryItem
;
import
cn.com.yict.framemax.core.i18n.I18nMessageException
;
import
cn.com.yict.framemax.core.i18n.I18nMessageException
;
import
cn.com.yict.framemax.core.service.impl.BaseServiceImpl
;
import
cn.com.yict.framemax.core.service.impl.BaseServiceImpl
;
import
cn.com.poc.user.service.BizMemberInfoService
;
import
cn.com.poc.user.service.BizMemberInfoService
;
...
@@ -82,6 +84,40 @@ public class BizMemberInfoServiceImpl extends BaseServiceImpl
...
@@ -82,6 +84,40 @@ public class BizMemberInfoServiceImpl extends BaseServiceImpl
return
MemberInfoConvert
.
convertModel2Entity
(
repository
.
save
(
model
));
return
MemberInfoConvert
.
convertModel2Entity
(
repository
.
save
(
model
));
}
}
@Override
public
MemberInfoEntity
updateMemberInfo
(
MemberInfoEntity
memberInfoEntity
)
{
Assert
.
notNull
(
memberInfoEntity
.
getMemberId
());
BizMemberInfoModel
bizMemberInfoModel
=
repository
.
get
(
memberInfoEntity
.
getMemberId
());
if
(
StringUtils
.
isNotBlank
(
memberInfoEntity
.
getNickName
()))
{
if
(
memberInfoEntity
.
getNickName
().
length
()
>
20
)
{
throw
new
I18nMessageException
(
"exception/nickName.max.len"
);
}
bizMemberInfoModel
.
setNickName
(
memberInfoEntity
.
getNickName
());
}
if
(
StringUtils
.
isNotBlank
(
memberInfoEntity
.
getAvatarUrl
()))
{
bizMemberInfoModel
.
setAvatarUrl
(
memberInfoEntity
.
getAvatarUrl
());
}
if
(
StringUtils
.
isNotBlank
(
memberInfoEntity
.
getMobilePhone
()))
{
bizMemberInfoModel
.
setMobilePhone
(
memberInfoEntity
.
getMobilePhone
());
}
if
(
StringUtils
.
isNotBlank
(
memberInfoEntity
.
getEmail
()))
{
bizMemberInfoModel
.
setEmail
(
memberInfoEntity
.
getEmail
());
}
if
(
StringUtils
.
isNotBlank
(
memberInfoEntity
.
getRemark
()))
{
if
(
memberInfoEntity
.
getRemark
().
length
()
>
200
)
{
throw
new
I18nMessageException
(
"exception/remark.max.len"
);
}
bizMemberInfoModel
.
setRemark
(
memberInfoEntity
.
getRemark
());
}
BizMemberInfoModel
saveModel
=
this
.
repository
.
save
(
bizMemberInfoModel
);
return
MemberInfoConvert
.
convertModel2Entity
(
saveModel
);
}
@Override
public
List
<
CheckMemberInfoQueryItem
>
checkMemberInfoIsExist
(
CheckMemberInfoQueryCondition
condition
)
{
return
this
.
sqlDao
.
query
(
condition
,
CheckMemberInfoQueryItem
.
class
);
}
private
boolean
checkVaildAccountExist
(
String
account
)
{
private
boolean
checkVaildAccountExist
(
String
account
)
{
BizMemberInfoModel
example
=
new
BizMemberInfoModel
();
BizMemberInfoModel
example
=
new
BizMemberInfoModel
();
example
.
setAccount
(
account
);
example
.
setAccount
(
account
);
...
...
src/main/resources/framemax-config/i18n/en/exception.properties
View file @
cbfb29ad
...
@@ -69,4 +69,12 @@ upload.more.than.10m=The uploaded file cannot exceed 10M file name
...
@@ -69,4 +69,12 @@ upload.more.than.10m=The uploaded file cannot exceed 10M file name
error.file.content.is.null
=
Incorrect file, file contents cannot be empty, file name
error.file.content.is.null
=
Incorrect file, file contents cannot be empty, file name
file.content.more.than.100w
=
The number of characters in a file cannot exceed 100w
file.content.more.than.100w
=
The number of characters in a file cannot exceed 100w
collect.limit.message
=
Click too fast, do not repeat the operation
collect.limit.message
=
Click too fast, do not repeat the operation
sms.limit.message
=
Do not send it again. Try again later
sms.limit.message
=
Do not send it again. Try again later
\ No newline at end of file
phone.is.exist
=
The mobile number already exists
email.is.exist
=
The email already exists
file.load.error
=
File loading failure
content.cannot.null
=
Content can not be null
arg.cannot.null
=
Arg can not be null
nickName.max.len
=
Overnickname
remark.max.len
=
Remark content too long
file.content.empty
=
The file content cannot be empty
\ No newline at end of file
src/main/resources/framemax-config/i18n/zh_cn/exception.properties
View file @
cbfb29ad
...
@@ -69,4 +69,12 @@ upload.more.than.10m=\u4E0A\u4F20\u7684\u6587\u4EF6\u4E0D\u80FD\u8D85\u8FC710M,\
...
@@ -69,4 +69,12 @@ upload.more.than.10m=\u4E0A\u4F20\u7684\u6587\u4EF6\u4E0D\u80FD\u8D85\u8FC710M,\
error.file.content.is.null
=
\u9519\u
8BEF
\u7684\u6587\u
4EF6
\u
FF0C
\u6587\u
4EF6
\u5185\u
5BB9
\u
4E0D
\u
80FD
\u
4E3A
\u
7A7A,
\u6587\u
4EF6
\u
540D
error.file.content.is.null
=
\u9519\u
8BEF
\u7684\u6587\u
4EF6
\u
FF0C
\u6587\u
4EF6
\u5185\u
5BB9
\u
4E0D
\u
80FD
\u
4E3A
\u
7A7A,
\u6587\u
4EF6
\u
540D
file.content.more.than.100w
=
\u6587\u
4EF6
\u5185\u
5BB9
\u
5B57
\u
7B26
\u6570\u
4E0D
\u
80FD
\u
8D85
\u
8FC7100w,
\u6587\u
4EF6
\u
540D
file.content.more.than.100w
=
\u6587\u
4EF6
\u5185\u
5BB9
\u
5B57
\u
7B26
\u6570\u
4E0D
\u
80FD
\u
8D85
\u
8FC7100w,
\u6587\u
4EF6
\u
540D
collect.limit.message
=
\u
70B9
\u
51FB
\u
8FC7
\u
5FEB,
\u
8BF7
\u
52FF
\u
91CD
\u
590D
\u
64CD
\u
4F5C
collect.limit.message
=
\u
70B9
\u
51FB
\u
8FC7
\u
5FEB,
\u
8BF7
\u
52FF
\u
91CD
\u
590D
\u
64CD
\u
4F5C
sms.limit.message
=
\u
8BF7
\u
52FF
\u
91CD
\u
590D
\u
53D1
\u9001\u
FF0C
\u
8BF7
\u
7A0D
\u
540E
\u
91CD
\u
8BD5
sms.limit.message
=
\u
8BF7
\u
52FF
\u
91CD
\u
590D
\u
53D1
\u9001\u
FF0C
\u
8BF7
\u
7A0D
\u
540E
\u
91CD
\u
8BD5
\ No newline at end of file
phone.is.exist
=
\u
8BE5
\u
624B
\u
673A
\u
53F7
\u
5DF2
\u
5B58
\u5728
email.is.exist
=
\u
8BE5
\u
90AE
\u
7BB1
\u
5DF2
\u
5B58
\u5728
file.load.error
=
\u6587\u
4EF6
\u
52A0
\u
8F7D
\u5931\u
8D25
content.cannot.null
=
\u5185\u
5BB9
\u
4E0D
\u
80FD
\u
4E3A
\u
7A7A
arg.cannot.null
=
\u
8BF7
\u
6C42
\u
53C2
\u6570\u
4E0D
\u
80FD
\u
4E3A
\u
7A7A
nickName.max.len
=
\u6635\u
79F0
\u
8FC7
\u
957F
remark.max.len
=
\u5185\u
5BB9
\u
8FC7
\u
957F
file.content.empty
=
\u6587\u6863\u5185\u
5BB9
\u
4E0D
\u
80FD
\u
4E3A
\u
7A7A
\ No newline at end of file
src/main/resources/framemax-config/i18n/zh_tw/exception.properties
View file @
cbfb29ad
...
@@ -69,4 +69,12 @@ upload.more.than.10m=\u4E0A\u50B3\u6587\u4EF6\u4E0D\u53EF\u8D85\u904E10M
...
@@ -69,4 +69,12 @@ upload.more.than.10m=\u4E0A\u50B3\u6587\u4EF6\u4E0D\u53EF\u8D85\u904E10M
error.file.content.is.null
=
\u
932F
\u
8AA4
\u7684\u6587\u
4EF6,
\u5185\u
5BB9
\u
4E0D
\u
80FD
\u7232\u
7A7A
error.file.content.is.null
=
\u
932F
\u
8AA4
\u7684\u6587\u
4EF6,
\u5185\u
5BB9
\u
4E0D
\u
80FD
\u7232\u
7A7A
file.content.more.than.100w
=
\u6587\u
4EF6
\u5185\u
5BB9
\u
4E0D
\u
53EF
\u
8D85100w
\u
5B57
\u
7B26
file.content.more.than.100w
=
\u6587\u
4EF6
\u5185\u
5BB9
\u
4E0D
\u
53EF
\u
8D85100w
\u
5B57
\u
7B26
collect.limit.message
=
\u
9EDE
\u
64CA
\u
904E
\u
5FEB
\u
FF0C
\u
8ACB
\u
52FF
\u
91CD
\u8907\u
64CD
\u
4F5C
collect.limit.message
=
\u
9EDE
\u
64CA
\u
904E
\u
5FEB
\u
FF0C
\u
8ACB
\u
52FF
\u
91CD
\u8907\u
64CD
\u
4F5C
sms.limit.message
=
\u
8ACB
\u
52FF
\u
91CD
\u8907\u
767C
\u9001\u
FF0C
\u
7A0D
\u
5F8C
\u
91CD
\u
8A66
sms.limit.message
=
\u
8ACB
\u
52FF
\u
91CD
\u8907\u
767C
\u9001\u
FF0C
\u
7A0D
\u
5F8C
\u
91CD
\u
8A66
\ No newline at end of file
phone.is.exist
=
\u
8A72
\u
624B
\u
6A5F
\u
865F
\u
5DF2
\u
5B58
\u5728
email.is.exist
=
\u
8A72
\u
90F5
\u
7BB1
\u
5DF2
\u
5B58
\u5728
file.load.error
=
\u6587\u
4EF6
\u
52A0
\u
8F09
\u5931\u6557
content.cannot.null
=
\u5185\u
5BB9
\u
4E0D
\u
80FD
\u7232\u
7A7A
arg.cannot.null
=
\u
8ACB
\u
6C42
\u
53C3
\u6578\u
4E0D
\u
80FD
\u7232\u
7A7A
nickName.max.len
=
\u6635\u
7A31
\u
904E
\u9577
remark.max.len
=
\u5185\u
5BB9
\u
904E
\u9577
file.content.empty
=
\u6587\u
4EF6
\u5185\u
5BB9
\u
4E0D
\u
80FD
\u7232\u
7A7A
\ No newline at end of file
src/test/java/cn/com/poc/AgentApplicationInfoTest.java
deleted
100644 → 0
View file @
43aaf3a4
package
cn
.
com
.
poc
;
import
cn.com.poc.agent_application.aggregate.AgentApplicationInfoService
;
import
cn.com.poc.common.service.RedisService
;
import
cn.com.poc.common.utils.BlContext
;
import
cn.com.poc.expose.aggregate.AgentApplicationService
;
import
cn.com.poc.thirdparty.resource.demand.ai.aggregate.DemandKnowledgeService
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.long_memory.SetLongMemoryConstants
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.value_memory.SetValueMemoryConstants
;
import
cn.com.yict.framemax.core.spring.SingleContextInitializer
;
import
com.google.common.collect.Lists
;
import
org.apache.commons.collections4.ListUtils
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.stream.Collectors
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@ContextConfiguration
(
initializers
=
SingleContextInitializer
.
class
)
@WebAppConfiguration
public
class
AgentApplicationInfoTest
{
@Resource
private
AgentApplicationInfoService
applicationInfoService
;
@Resource
private
DemandKnowledgeService
demandKnowledgeService
;
@Resource
private
RedisService
redisService
;
@Test
public
void
del
(){
String
contentKey
=
SetValueMemoryConstants
.
REDIS_PREFIX
;
redisService
.
del
(
contentKey
);
}
/**
* Agent Ӧ�ñ��⣬��������
*/
@Test
public
void
createAgentTitleAndDesc
()
{
String
input
=
"���Ա���"
;
System
.
out
.
println
(
applicationInfoService
.
createAgentTitleAndDesc
(
input
));
}
@Test
public
void
knowledgeTest
()
{
ArrayList
<
String
>
list
=
new
ArrayList
<
String
>()
{{
}};
System
.
out
.
println
(
list
.
toString
());
}
@Test
public
void
test
()
{
List
<
Object
>
list
=
Lists
.
newArrayList
(
"1"
,
"2"
,
"3"
,
"4"
,
"5"
,
"6"
,
"7"
,
"8"
,
"9"
,
"1"
);
redisService
.
lSet
(
"key"
,
list
);
// redisService.sSet("key",1);
}
@Resource
private
AgentApplicationService
agentApplicationService
;
@Test
public
void
test2
()
throws
InterruptedException
{
agentApplicationService
.
createRecommendQuestion
();
}
}
src/test/java/cn/com/poc/demand/AiDialogueTest.java
deleted
100644 → 0
View file @
43aaf3a4
package
cn
.
com
.
poc
.
demand
;
import
cn.com.poc.thirdparty.resource.demand.ai.aggregate.AIDialogueService
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.dialogue.Function
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.function.FunctionCallResponse
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.function.FunctionCallResult
;
import
cn.com.yict.framemax.core.spring.SingleContextInitializer
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@ContextConfiguration
(
initializers
=
SingleContextInitializer
.
class
)
@WebAppConfiguration
public
class
AiDialogueTest
{
@Resource
AIDialogueService
aiDialogueService
;
@Test
public
void
functionCall
()
{
String
query
=
"帮我记一下,今天下午需要开会"
;
Map
<
String
,
Object
>
content
=
new
HashMap
<>();
content
.
put
(
"type"
,
"string"
);
content
.
put
(
"description"
,
"内容的详细说明"
);
Map
<
String
,
Object
>
properties
=
new
HashMap
<>();
properties
.
put
(
"content"
,
content
);
Map
<
String
,
Object
>
parameters
=
new
HashMap
<>();
parameters
.
put
(
"type"
,
"object"
);
parameters
.
put
(
"properties"
,
properties
);
List
<
String
>
required
=
new
ArrayList
<>();
required
.
add
(
"content"
);
parameters
.
put
(
"required"
,
required
);
Function
function
=
new
Function
();
function
.
setName
(
"set_long_memory"
);
function
.
setDescription
(
"该方法仅用来保存用户想记录的内容,不能通过该方法进行查询。"
);
function
.
setParameters
(
parameters
);
List
<
Function
>
functions
=
new
ArrayList
<>();
functions
.
add
(
function
);
FunctionCallResponse
functionCallResponse
=
new
FunctionCallResponse
();
functionCallResponse
.
setQuery
(
query
);
functionCallResponse
.
setFunctions
(
functions
);
FunctionCallResult
functionCallResult
=
aiDialogueService
.
functionCall
(
functionCallResponse
);
System
.
out
.
println
(
functionCallResult
);
}
}
src/test/java/cn/com/poc/expose/aggregate/AgentApplicationServiceTest.java
0 → 100644
View file @
cbfb29ad
package
cn
.
com
.
poc
.
expose
.
aggregate
;
import
cn.com.poc.agent_application.query.MemberCollectQueryCondition
;
import
cn.com.poc.agent_application.query.MemberCollectQueryItem
;
import
cn.com.poc.agent_application.service.BizMemberAgentApplicationCollectService
;
import
cn.com.poc.common.constant.CommonConstant
;
import
cn.com.poc.expose.aggregate.impl.AgentApplicationServiceImpl
;
import
cn.com.yict.framemax.core.spring.SingleContextInitializer
;
import
cn.com.yict.framemax.data.model.PagingInfo
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.mockito.InjectMocks
;
import
org.mockito.Mock
;
import
org.mockito.Mockito
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.List
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
mockito
.
Mockito
.
when
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@ContextConfiguration
(
initializers
=
SingleContextInitializer
.
class
)
@WebAppConfiguration
public
class
AgentApplicationServiceTest
{
private
BizMemberAgentApplicationCollectService
bizMemberAgentApplicationCollectService
;
@Resource
private
AgentApplicationServiceImpl
agentApplicationService
;
private
Long
memberId
;
private
PagingInfo
pagingInfo
;
private
MemberCollectQueryCondition
condition
;
private
List
<
MemberCollectQueryItem
>
memberCollectQueryItems
;
@Before
public
void
setUp
()
{
memberId
=
1L
;
pagingInfo
=
new
PagingInfo
();
condition
=
new
MemberCollectQueryCondition
();
condition
.
setMemberId
(
memberId
);
condition
.
setIsCollect
(
CommonConstant
.
YOrN
.
Y
);
memberCollectQueryItems
=
new
ArrayList
<>();
memberCollectQueryItems
.
add
(
new
MemberCollectQueryItem
());
bizMemberAgentApplicationCollectService
=
Mockito
.
mock
(
BizMemberAgentApplicationCollectService
.
class
);
}
@Test
public
void
testGetCollectedApplications
()
{
// Mock the behavior of bizMemberAgentApplicationCollectService
when
(
bizMemberAgentApplicationCollectService
.
queryMemberCollect
(
condition
,
pagingInfo
)).
thenReturn
(
memberCollectQueryItems
);
// Call the method to be tested
List
<
MemberCollectQueryItem
>
result
=
agentApplicationService
.
getCollectedApplications
(
memberId
,
pagingInfo
);
// Verify that the service method was called with the correct parameters
Mockito
.
verify
(
bizMemberAgentApplicationCollectService
).
queryMemberCollect
(
condition
,
pagingInfo
);
}
@Test
public
void
autoPlayByAgentId
()
{
Long
memberId
=
197L
;
String
agentId
=
"bde291ad70f340458e7c6d8ef572eb59"
;
System
.
out
.
println
(
agentApplicationService
.
autoPlayByAgentId
(
memberId
,
agentId
));
}
@Test
public
void
enableAutoPlay
()
{
Long
memberId
=
197L
;
String
agentId
=
"bde291ad70f340458e7c6d8ef572eb59"
;
String
autoPlay
=
CommonConstant
.
YOrN
.
Y
;
String
result
=
agentApplicationService
.
enableAutoPlay
(
memberId
,
agentId
,
autoPlay
);
System
.
out
.
println
(
result
);
}
}
src/test/java/cn/com/poc/thirdparty/resource/demand/ai/function/DocumentReaderFunctionTest.java
0 → 100644
View file @
cbfb29ad
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
function
;
import
cn.com.poc.agent_application.entity.Variable
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.document_reader.DocumentReaderFunction
;
import
cn.com.yict.framemax.core.spring.SingleContextInitializer
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.mockito.InjectMocks
;
import
org.mockito.Mockito
;
import
org.mockito.MockitoAnnotations
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
javax.annotation.Resource
;
import
java.util.List
;
import
java.util.UUID
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@ContextConfiguration
(
initializers
=
SingleContextInitializer
.
class
)
@WebAppConfiguration
public
class
DocumentReaderFunctionTest
{
@Resource
@InjectMocks
DocumentReaderFunction
documentReaderFunction
;
@Before
public
void
init
()
{
MockitoAnnotations
.
initMocks
(
this
);
}
@Test
public
void
testDoFunction
()
{
String
content
=
"{\"file_urls\": [\"https://gsst-poe-sit.gz.bcebos.com/data/20241127/1732704249980.docx\"]}"
;
String
identifier
=
UUID
.
randomUUID
().
toString
();
String
RESULT
=
documentReaderFunction
.
doFunction
(
content
,
identifier
);
assertNotNull
(
RESULT
);
}
@Test
public
void
testGetDesc
()
{
System
.
out
.
println
(
documentReaderFunction
.
getDesc
());
}
@Test
public
void
testGetLLMConfig
()
{
System
.
out
.
println
(
documentReaderFunction
.
getLLMConfig
());
}
@Test
public
void
testGetLLMConfigToVariableStructure
()
{
List
<
Variable
>
variableStructure
=
Mockito
.
mock
(
List
.
class
);
System
.
out
.
println
(
documentReaderFunction
.
getLLMConfig
(
variableStructure
));
}
}
src/test/java/cn/com/poc/thirdparty/resource/demand/ai/function/DocumentUnderstandingFunctionTest.java
0 → 100644
View file @
cbfb29ad
package
cn
.
com
.
poc
.
thirdparty
.
resource
.
demand
.
ai
.
function
;
import
cn.com.poc.agent_application.entity.Variable
;
import
cn.com.poc.thirdparty.resource.demand.ai.function.document_understanding.DocumentUnderstandIngFunction
;
import
cn.com.yict.framemax.core.spring.SingleContextInitializer
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.mockito.Mockito
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
javax.annotation.Resource
;
import
java.util.List
;
import
java.util.UUID
;
import
static
org
.
apache
.
poi
.
hslf
.
record
.
RecordTypes
.
List
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@ContextConfiguration
(
initializers
=
SingleContextInitializer
.
class
)
@WebAppConfiguration
public
class
DocumentUnderstandingFunctionTest
{
@Resource
DocumentUnderstandIngFunction
documentUnderstandIngFunction
;
@Test
public
void
testDoFunction
()
{
String
content
=
"{\"file_url\": \"https://gsst-poe-sit.gz.bcebos.com/data/20241127/1732704249980.docx\",\"question\":\"駕駛執照上的二維碼內載有什麼資料?\"}"
;
String
identifier
=
UUID
.
randomUUID
().
toString
();
String
RESULT
=
documentUnderstandIngFunction
.
doFunction
(
content
,
identifier
);
System
.
out
.
println
(
RESULT
);
}
@Test
public
void
testGetDesc
()
{
System
.
out
.
println
(
documentUnderstandIngFunction
.
getDesc
());
}
@Test
public
void
testGetLLMConfig
()
{
System
.
out
.
println
(
documentUnderstandIngFunction
.
getLLMConfig
());
}
@Test
public
void
testGetLLMConfigToVariableStructure
()
{
List
<
Variable
>
variableStructure
=
Mockito
.
mock
(
List
.
class
);
System
.
out
.
println
(
documentUnderstandIngFunction
.
getLLMConfig
(
variableStructure
));
}
}
src/test/java/cn/com/poc/timbre/rest/BizVoiceTimbreRestTest.java
0 → 100644
View file @
cbfb29ad
package
cn
.
com
.
poc
.
timbre
.
rest
;
import
cn.com.poc.common.utils.JsonUtils
;
import
cn.com.poc.timbre.dto.GetTimbreDto
;
import
cn.com.poc.timbre.entity.BizVoiceTimbreEntity
;
import
cn.com.poc.timbre.rest.impl.BizVoiceTimbreRest
;
import
cn.com.poc.timbre.service.BizVoiceTimbreService
;
import
cn.com.yict.framemax.core.context.Context
;
import
cn.com.yict.framemax.core.i18n.BundleMessageSourceImplementor
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.mockito.*
;
import
org.mockito.junit.MockitoJUnitRunner
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Locale
;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
mockito
.
ArgumentMatchers
.
any
;
import
static
org
.
mockito
.
ArgumentMatchers
.
isNull
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
when
;
@RunWith
(
MockitoJUnitRunner
.
class
)
public
class
BizVoiceTimbreRestTest
{
MockedStatic
<
Context
>
mockedContext
;
@Mock
private
BizVoiceTimbreService
bizVoiceTimbreService
;
@InjectMocks
private
BizVoiceTimbreRest
bizVoiceTimbreRest
;
@Before
public
void
setUp
()
throws
Exception
{
// // Given
List
<
BizVoiceTimbreEntity
>
entities
=
new
ArrayList
<>();
BizVoiceTimbreEntity
bizVoiceTimbreEntity
=
new
BizVoiceTimbreEntity
();
bizVoiceTimbreEntity
.
setId
(
0
);
bizVoiceTimbreEntity
.
setTimbreId
(
"12341423AA"
);
bizVoiceTimbreEntity
.
setLanguage
(
0
);
bizVoiceTimbreEntity
.
setTimbreName
(
"1"
);
bizVoiceTimbreEntity
.
setTimbreNameEn
(
"one"
);
bizVoiceTimbreEntity
.
setTimbreNameTw
(
"一"
);
bizVoiceTimbreEntity
.
setVoiceUrl
(
"http://"
);
bizVoiceTimbreEntity
.
setIsDeleted
(
"N"
);
bizVoiceTimbreEntity
.
setModifiedTime
(
new
Date
());
bizVoiceTimbreEntity
.
setSysVersion
(
0
);
entities
.
add
(
bizVoiceTimbreEntity
);
when
(
bizVoiceTimbreService
.
findByExample
(
any
(),
ArgumentMatchers
.
isNull
())).
thenReturn
(
entities
);
when
(
bizVoiceTimbreService
.
getByTimbreId
(
any
())).
thenReturn
(
bizVoiceTimbreEntity
);
mockedContext
=
Mockito
.
mockStatic
(
Context
.
class
);
Context
mockContext
=
mock
(
Context
.
class
);
BundleMessageSourceImplementor
bundleMessageSource
=
mock
(
BundleMessageSourceImplementor
.
class
);
mockedContext
.
when
(
Context:
:
get
).
thenReturn
(
mockContext
);
mockedContext
.
when
(
Context
.
get
()::
getMessageSource
).
thenReturn
(
bundleMessageSource
);
when
(
bundleMessageSource
.
getCurrentLocale
()).
thenReturn
(
Locale
.
ENGLISH
);
}
@Test
public
void
getTimbreListTest
()
throws
Exception
{
// When
List
<
GetTimbreDto
>
result
=
bizVoiceTimbreRest
.
getTimbreList
();
System
.
out
.
println
(
"getTimbreListTest:"
+
JsonUtils
.
serialize
(
result
));
// Then
assertEquals
(
3
,
result
.
size
());
}
@Test
public
void
getTimbreInfo
()
{
GetTimbreDto
timbreInfo
=
bizVoiceTimbreRest
.
getTimbreInfo
(
"12341423AA"
);
assertNotNull
(
timbreInfo
);
System
.
out
.
println
(
"timbreInfo:"
+
JsonUtils
.
serialize
(
timbreInfo
));
when
(
bizVoiceTimbreService
.
getByTimbreId
(
any
())).
thenReturn
(
isNull
());
timbreInfo
=
bizVoiceTimbreRest
.
getTimbreInfo
(
"12341423AA"
);
assertNull
(
timbreInfo
);
}
@After
public
void
close
()
{
mockedContext
.
close
();
}
}
src/test/java/cn/com/poc/timbre/service/BizVoiceTimbreServiceTest.java
0 → 100644
View file @
cbfb29ad
package
cn
.
com
.
poc
.
timbre
.
service
;
import
cn.com.poc.common.constant.CommonConstant
;
import
cn.com.poc.common.utils.JsonUtils
;
import
cn.com.poc.timbre.entity.BizVoiceTimbreEntity
;
import
cn.com.yict.framemax.core.spring.SingleContextInitializer
;
import
cn.com.yict.framemax.data.model.PagingInfo
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
javax.annotation.Resource
;
import
java.util.List
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@ContextConfiguration
(
initializers
=
SingleContextInitializer
.
class
)
@WebAppConfiguration
public
class
BizVoiceTimbreServiceTest
{
@Resource
private
BizVoiceTimbreService
bizVoiceTimbreService
;
@Test
public
void
getByTimbreIdTest
()
{
BizVoiceTimbreEntity
bizVoiceTimbreEntity
=
bizVoiceTimbreService
.
getByTimbreId
(
"101019"
);
System
.
out
.
println
(
JsonUtils
.
serialize
(
bizVoiceTimbreEntity
));
// 获取不存在
System
.
out
.
println
(
JsonUtils
.
serialize
(
bizVoiceTimbreService
.
getByTimbreId
(
"1"
)));
}
@Test
public
void
findByExampleTest
()
throws
Exception
{
BizVoiceTimbreEntity
bizVoiceTimbreEntity
=
new
BizVoiceTimbreEntity
();
bizVoiceTimbreEntity
.
setIsDeleted
(
CommonConstant
.
YOrN
.
N
);
List
<
BizVoiceTimbreEntity
>
entities
=
bizVoiceTimbreService
.
findByExample
(
bizVoiceTimbreEntity
,
new
PagingInfo
(
10
,
1
));
System
.
out
.
println
(
JsonUtils
.
listToJson
(
entities
));
}
}
src/test/java/cn/com/poc/user/aggregation/MemberInfoServiceTest.java
0 → 100644
View file @
cbfb29ad
package
cn
.
com
.
poc
.
user
.
aggregation
;
import
cn.com.poc.user.entity.MemberInfoEntity
;
import
cn.com.yict.framemax.core.i18n.I18nMessageException
;
import
cn.com.yict.framemax.core.spring.SingleContextInitializer
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.mockito.InjectMocks
;
import
org.mockito.MockitoAnnotations
;
import
org.springframework.test.annotation.Rollback
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@ContextConfiguration
(
initializers
=
SingleContextInitializer
.
class
)
@WebAppConfiguration
public
class
MemberInfoServiceTest
{
@Resource
@InjectMocks
MemberInfoService
memberInfoService
;
@Before
public
void
setUp
()
{
MockitoAnnotations
.
initMocks
(
this
);
}
@Test
(
expected
=
I18nMessageException
.
class
)
@Rollback
@Transactional
public
void
testUpdateMemberInfoWithEmail
()
{
MemberInfoEntity
memberInfoEntity
=
new
MemberInfoEntity
();
memberInfoEntity
.
setEmail
(
"alex.yao@superlinksoft.com"
);
memberInfoEntity
.
setMemberId
(
217
);
memberInfoService
.
updateMemberInfo
(
memberInfoEntity
);
}
}
src/test/java/cn/com/poc/user/builder/LoginChannelTest.java
0 → 100644
View file @
cbfb29ad
package
cn
.
com
.
poc
.
user
.
builder
;
import
cn.com.poc.common.service.JudgeCodeService
;
import
cn.com.poc.user.dto.MemberLoginRequestDto
;
import
cn.com.poc.user.entity.MemberInfoEntity
;
import
cn.com.yict.framemax.core.i18n.I18nMessageException
;
import
cn.com.yict.framemax.core.spring.SingleContextInitializer
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.mockito.InjectMocks
;
import
org.mockito.Mock
;
import
org.mockito.Mockito
;
import
org.mockito.MockitoAnnotations
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.test.annotation.Rollback
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
org.springframework.transaction.annotation.Transactional
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
mockito
.
ArgumentMatchers
.
any
;
import
static
org
.
mockito
.
Mockito
.
when
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@ContextConfiguration
(
initializers
=
SingleContextInitializer
.
class
)
@WebAppConfiguration
public
class
LoginChannelTest
{
@Autowired
@InjectMocks
EmailLoginChannel
emailLoginChannel
;
@Autowired
@InjectMocks
SmsLoginChannel
smsLoginChannel
;
@Mock
JudgeCodeService
judgeCodeService
;
@Before
public
void
setup
()
{
// 启用 Mockito 注解
MockitoAnnotations
.
initMocks
(
this
);
}
@Test
(
expected
=
I18nMessageException
.
class
)
@Transactional
@Rollback
public
void
testEmailDoLogin_judgeCodeError
()
throws
Exception
{
when
(
judgeCodeService
.
judgeCode
(
any
(),
any
())).
thenReturn
(
false
);
MemberLoginRequestDto
memberLoginRequest
=
Mockito
.
mock
(
MemberLoginRequestDto
.
class
);
when
(
memberLoginRequest
.
getAccount
()).
thenReturn
(
"alex.yao@superlinksoft.com"
);
when
(
memberLoginRequest
.
getAuthCode
()).
thenReturn
(
"111"
);
emailLoginChannel
.
doLogin
(
memberLoginRequest
);
}
@Test
@Transactional
@Rollback
public
void
testEmailDoLogin
()
throws
Exception
{
when
(
judgeCodeService
.
judgeCode
(
any
(),
any
())).
thenReturn
(
true
);
MemberLoginRequestDto
memberLoginRequest
=
Mockito
.
mock
(
MemberLoginRequestDto
.
class
);
when
(
memberLoginRequest
.
getAccount
()).
thenReturn
(
"alex.yao@superlinksoft.com"
);
when
(
memberLoginRequest
.
getAuthCode
()).
thenReturn
(
"111"
);
MemberInfoEntity
memberInfoEntity
=
(
MemberInfoEntity
)
emailLoginChannel
.
doLogin
(
memberLoginRequest
);
assertNotNull
(
memberInfoEntity
);
assertEquals
(
memberInfoEntity
.
getMemberId
(),
Integer
.
valueOf
(
197
));
}
@Test
@Transactional
@Rollback
public
void
testEmailDoLogin_registerNewAccount
()
throws
Exception
{
when
(
judgeCodeService
.
judgeCode
(
any
(),
any
())).
thenReturn
(
true
);
MemberLoginRequestDto
memberLoginRequest
=
Mockito
.
mock
(
MemberLoginRequestDto
.
class
);
when
(
memberLoginRequest
.
getAccount
()).
thenReturn
(
"alex.yao1@superlinksoft.com"
);
when
(
memberLoginRequest
.
getAuthCode
()).
thenReturn
(
"111"
);
MemberInfoEntity
memberInfoEntity
=
(
MemberInfoEntity
)
emailLoginChannel
.
doLogin
(
memberLoginRequest
);
assertNotNull
(
memberInfoEntity
);
}
@Test
@Transactional
@Rollback
public
void
testSmsDoLogin
()
throws
Exception
{
when
(
judgeCodeService
.
judgeCode
(
any
(),
any
())).
thenReturn
(
true
);
MemberLoginRequestDto
memberLoginRequest
=
Mockito
.
mock
(
MemberLoginRequestDto
.
class
);
when
(
memberLoginRequest
.
getAccount
()).
thenReturn
(
"13602787613"
);
when
(
memberLoginRequest
.
getAuthCode
()).
thenReturn
(
"111"
);
MemberInfoEntity
memberInfoEntity
=
(
MemberInfoEntity
)
smsLoginChannel
.
doLogin
(
memberLoginRequest
);
assertNotNull
(
memberInfoEntity
);
assertEquals
(
memberInfoEntity
.
getMemberId
(),
Integer
.
valueOf
(
197
));
}
@Test
@Transactional
@Rollback
public
void
testSmsDoLogin_registerNewAccount
()
throws
Exception
{
when
(
judgeCodeService
.
judgeCode
(
any
(),
any
())).
thenReturn
(
true
);
MemberLoginRequestDto
memberLoginRequest
=
Mockito
.
mock
(
MemberLoginRequestDto
.
class
);
when
(
memberLoginRequest
.
getAccount
()).
thenReturn
(
"13602787614"
);
when
(
memberLoginRequest
.
getAuthCode
()).
thenReturn
(
"111"
);
MemberInfoEntity
memberInfoEntity
=
(
MemberInfoEntity
)
smsLoginChannel
.
doLogin
(
memberLoginRequest
);
assertNotNull
(
memberInfoEntity
);
}
}
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