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
0cd9e782
Commit
0cd9e782
authored
Nov 07, 2024
by
alex yao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
style: 创建/更新应用 删除应用
parent
9da0d28a
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
27 deletions
+62
-27
AgentApplicationInfoService.java
...nt_application/aggregate/AgentApplicationInfoService.java
+17
-3
AgentApplicationInfoServiceImpl.java
...ation/aggregate/impl/AgentApplicationInfoServiceImpl.java
+30
-0
AgentApplicationInfoRestImpl.java
...t_application/rest/impl/AgentApplicationInfoRestImpl.java
+15
-24
No files found.
src/main/java/cn/com/poc/agent_application/aggregate/AgentApplicationInfoService.java
View file @
0cd9e782
...
...
@@ -10,17 +10,31 @@ import java.util.List;
public
interface
AgentApplicationInfoService
{
/**
* 创建/更新应用
*/
BizAgentApplicationInfoEntity
saveOrUpdate
(
BizAgentApplicationInfoEntity
entity
)
throws
Exception
;
/**
* 更新并发布应用
*/
boolean
updateAndPublish
(
BizAgentApplicationInfoEntity
entity
)
throws
Exception
;
/**
* 删除Agent应用
*
* @param agentId 应用ID
*/
boolean
deletedAgentApplication
(
String
agentId
)
throws
Exception
;
/**
* 应用预览
*/
String
callAgentApplication
(
String
identifier
,
String
largeModel
,
String
[]
unitIds
,
String
agentSystem
,
Integer
[]
knowledgeIds
,
Integer
communicationTurn
,
Float
topP
,
Float
temperature
,
List
<
Message
>
messages
,
List
<
Tool
>
tools
,
HttpServletResponse
httpServletResponse
)
throws
Exception
;
/**
* 应用下架
*
...
...
@@ -80,13 +94,13 @@ public interface AgentApplicationInfoService {
*
* @param id 应用广场的应用id
* @param agentId Agent应用id
*
*
/
*/
void
collectOrCancelAgentInMall
(
Integer
id
,
String
agentId
)
throws
Exception
;
/**
* 收藏/取消收藏个人空间中的应用
*
* @param agentId Agent应用id
*
*
/
*/
void
collectOrCancelAgentInPerson
(
String
agentId
)
throws
Exception
;
}
src/main/java/cn/com/poc/agent_application/aggregate/impl/AgentApplicationInfoServiceImpl.java
View file @
0cd9e782
...
...
@@ -4,6 +4,7 @@ import cn.com.poc.agent_application.aggregate.AgentApplicationInfoService;
import
cn.com.poc.agent_application.constant.AgentApplicationConstants
;
import
cn.com.poc.agent_application.constant.AgentApplicationDialoguesRecordConstants
;
import
cn.com.poc.agent_application.constant.AgentApplicationGCConfigConstants
;
import
cn.com.poc.agent_application.convert.AgentApplicationInfoConvert
;
import
cn.com.poc.agent_application.entity.*
;
import
cn.com.poc.agent_application.query.DialogsIdsQueryByAgentIdQueryItem
;
import
cn.com.poc.agent_application.service.*
;
...
...
@@ -42,6 +43,7 @@ import org.apache.commons.lang3.StringUtils;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Component
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletResponse
;
...
...
@@ -95,6 +97,19 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
@Resource
private
RedisService
redisService
;
@Override
public
BizAgentApplicationInfoEntity
saveOrUpdate
(
BizAgentApplicationInfoEntity
entity
)
throws
Exception
{
// 如果存在agentId,则判断变量结构是否有变化,如果有变化,则删除redis中的数据
if
(
StringUtils
.
isNotBlank
(
entity
.
getAgentId
()))
{
String
contentKey
=
SetValueMemoryConstants
.
REDIS_PREFIX
+
entity
.
getAgentId
()
+
":"
+
entity
.
getMemberId
();
redisService
.
del
(
contentKey
);
}
// 保存或更新
return
StringUtils
.
isEmpty
(
entity
.
getAgentId
())
?
bizAgentApplicationInfoService
.
save
(
entity
)
:
bizAgentApplicationInfoService
.
update
(
entity
);
}
@Override
public
boolean
updateAndPublish
(
BizAgentApplicationInfoEntity
bizAgentApplicationInfoEntity
)
throws
Exception
{
UserBaseEntity
userBaseEntity
=
BlContext
.
getCurrentUserNotException
();
...
...
@@ -126,6 +141,21 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
return
true
;
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
boolean
deletedAgentApplication
(
String
agentId
)
throws
Exception
{
bizAgentApplicationInfoService
.
deletedByAgentId
(
agentId
);
// 删除应用
BizAgentApplicationPublishEntity
publishEntity
=
bizAgentApplicationPublishService
.
getByAgentId
(
agentId
);
if
(
publishEntity
!=
null
)
{
// 删除应用市场表中的应用
bizAgentApplicationMallService
.
deletedByAgentPublishId
(
publishEntity
.
getId
());
// 删除发布表中的应用
bizAgentApplicationPublishService
.
deleteByAgentId
(
agentId
);
}
return
true
;
}
@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
{
logger
.
info
(
"--------- Call Agent Application large model:{},unitIds:{},agentSystem:{},knowledgeIds:{}"
+
" communicationTurn:{},topP:{},messages:{}--------------"
,
largeModel
,
unitIds
,
agentSystem
,
kdIds
,
communicationTurn
,
topP
,
messages
);
...
...
src/main/java/cn/com/poc/agent_application/rest/impl/AgentApplicationInfoRestImpl.java
View file @
0cd9e782
...
...
@@ -76,6 +76,7 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
return
AgentApplicationInfoConvert
.
entityToDto
(
bizAgentApplicationInfoEntity
);
}
@Override
public
List
<
AgentApplicationInfoDto
>
getListByMember
(
AgentApplicationInfoSearchDto
dto
,
PagingInfo
pagingInfo
)
throws
Exception
{
UserBaseEntity
userBaseEntity
=
BlContext
.
getCurrentUserNotException
();
Long
userId
=
userBaseEntity
.
getUserId
();
...
...
@@ -99,7 +100,7 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
// 如果符合条件,则把值加入
if
(
collect
!=
null
&&
collect
.
getIsCollect
().
equals
(
dto
.
getIsCollect
()))
{
infoDto
.
setIsCollect
(
collect
.
getIsCollect
());
}
else
if
(
(
collect
==
null
&&
CommonConstant
.
IsDeleted
.
N
.
equals
(
dto
.
getIsCollect
()
)))
{
}
else
if
(
collect
==
null
&&
CommonConstant
.
IsDeleted
.
N
.
equals
(
dto
.
getIsCollect
(
)))
{
infoDto
.
setIsCollect
(
CommonConstant
.
IsDeleted
.
N
);
}
else
{
// 如果不符合条件,则continue
...
...
@@ -140,25 +141,23 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
}
@Override
public
AgentApplicationInfoDto
saveOrUpdate
(
AgentApplicationInfoDto
dto
)
throws
Exception
{
Assert
.
notNull
(
dto
);
Assert
.
notNull
(
dto
.
getBaseInfo
());
Assert
.
notNull
(
dto
.
getCommConfig
());
Assert
.
notNull
(
dto
.
getCommModelConfig
());
Assert
.
notNull
(
dto
.
getKnowledgeConfig
());
UserBaseEntity
userBaseEntity
=
BlContext
.
getCurrentUserNotException
();
if
(
userBaseEntity
==
null
)
{
throw
new
I18nMessageException
(
"exception/user.does.not.exist"
);
}
Long
userId
=
userBaseEntity
.
getUserId
();
dto
.
getBaseInfo
().
setMemberId
(
userId
.
intValue
());
BizAgentApplicationInfoEntity
entity
=
AgentApplicationInfoConvert
.
dtoToEntity
(
dto
);
// 如果存在agentId,则判断变量结构是否有变化,如果有变化,则删除redis中的数据
if
(
StringUtils
.
isNotBlank
(
entity
.
getAgentId
()))
{
String
contentKey
=
SetValueMemoryConstants
.
REDIS_PREFIX
+
dto
.
getBaseInfo
().
getAgentId
()
+
":"
+
BlContext
.
getCurrentUserNotException
().
getUserId
().
toString
();
redisService
.
del
(
contentKey
);
}
return
AgentApplicationInfoConvert
.
entityToDto
(
StringUtils
.
isEmpty
(
entity
.
getAgentId
())
?
bizAgentApplicationInfoService
.
save
(
entity
)
:
bizAgentApplicationInfoService
.
update
(
entity
));
return
AgentApplicationInfoConvert
.
entityToDto
(
agentApplicationInfoService
.
saveOrUpdate
(
entity
));
}
...
...
@@ -186,15 +185,7 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
@Override
public
void
delete
(
String
agentId
)
throws
Exception
{
Assert
.
notNull
(
agentId
);
bizAgentApplicationInfoService
.
deletedByAgentId
(
agentId
);
// 删除应用
BizAgentApplicationPublishEntity
publishEntity
=
bizAgentApplicationPublishService
.
getByAgentId
(
agentId
);
if
(
publishEntity
!=
null
)
{
// 删除应用市场表中的应用
bizAgentApplicationMallService
.
deletedByAgentPublishId
(
publishEntity
.
getId
());
// 删除发布表中的应用
bizAgentApplicationPublishService
.
deleteByAgentId
(
agentId
);
}
agentApplicationInfoService
.
deletedAgentApplication
(
agentId
);
}
@Override
...
...
@@ -319,12 +310,12 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
}
@Override
public
List
<
String
>
createFeaturedQuestions
(
AgentApplicationGCDto
dto
)
throws
Exception
{
public
List
<
String
>
createFeaturedQuestions
(
AgentApplicationGCDto
dto
){
return
agentApplicationInfoService
.
createFeaturedQuestions
(
dto
.
getAgentTitle
(),
dto
.
getAgentDesc
());
}
@Override
public
String
createPreamble
(
AgentApplicationGCDto
dto
)
throws
Exception
{
public
String
createPreamble
(
AgentApplicationGCDto
dto
){
return
agentApplicationInfoService
.
createPreamble
(
dto
.
getAgentTitle
(),
dto
.
getAgentDesc
(),
dto
.
getAgentSystem
());
}
...
...
@@ -335,7 +326,7 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
}
@Override
public
AgentApplicationGCDto
createAgentTitleAndDesc
(
AgentApplicationGCDto
dto
)
throws
Exception
{
public
AgentApplicationGCDto
createAgentTitleAndDesc
(
AgentApplicationGCDto
dto
)
{
Assert
.
notNull
(
dto
.
getInput
());
CreateAgentTitleAndDescEntity
entity
=
agentApplicationInfoService
.
createAgentTitleAndDesc
(
dto
.
getInput
());
if
(
null
==
entity
)
{
...
...
@@ -383,7 +374,7 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
}
@Override
public
List
<
AgentLongMemoryDto
>
getLongMemoryList
(
String
agentId
)
throws
Exception
{
public
List
<
AgentLongMemoryDto
>
getLongMemoryList
(
String
agentId
){
Assert
.
notNull
(
agentId
);
List
<
AgentLongMemoryDto
>
result
=
new
ArrayList
<>();
String
contentKey
=
SetLongMemoryConstants
.
REDIS_PREFIX
+
agentId
+
":"
+
BlContext
.
getCurrentUserNotException
().
getUserId
().
toString
();
...
...
@@ -400,7 +391,7 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
}
@Override
public
void
deleteLongMemoryByKey
(
String
agentId
,
String
timestamp
)
throws
Exception
{
public
void
deleteLongMemoryByKey
(
String
agentId
,
String
timestamp
)
{
Assert
.
notNull
(
agentId
);
Assert
.
notNull
(
timestamp
);
String
contentKey
=
SetLongMemoryConstants
.
REDIS_PREFIX
+
agentId
+
":"
+
BlContext
.
getCurrentUserNotException
().
getUserId
().
toString
();
...
...
@@ -408,7 +399,7 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
}
@Override
public
void
deleteLongMemory
(
String
agentId
)
throws
Exception
{
public
void
deleteLongMemory
(
String
agentId
){
Assert
.
notNull
(
agentId
);
String
contentKey
=
SetLongMemoryConstants
.
REDIS_PREFIX
+
agentId
+
":"
+
BlContext
.
getCurrentUserNotException
().
getUserId
().
toString
();
redisService
.
del
(
contentKey
);
...
...
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