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
05de9276
Commit
05de9276
authored
Mar 04, 2025
by
alex yao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
style: service命名优化
parent
9a52e406
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
89 additions
and
140 deletions
+89
-140
AgentApplicationService.java
.../agent_application/aggregate/AgentApplicationService.java
+1
-30
AgentApplicationServiceImpl.java
...plication/aggregate/impl/AgentApplicationServiceImpl.java
+40
-55
AgentApplicationInfoRestImpl.java
...t_application/rest/impl/AgentApplicationInfoRestImpl.java
+12
-12
RecommendQuestionScheduler.java
...ent_application/scheduler/RecommendQuestionScheduler.java
+3
-3
AgentApplicationExposeService.java
...m/poc/expose/aggregate/AgentApplicationExposeService.java
+1
-3
AgentApplicationApiServiceImpl.java
...expose/aggregate/impl/AgentApplicationApiServiceImpl.java
+3
-3
AgentApplicationExposeServiceImpl.java
...ose/aggregate/impl/AgentApplicationExposeServiceImpl.java
+7
-7
AgentApplicationRestImpl.java
...cn/com/poc/expose/rest/impl/AgentApplicationRestImpl.java
+13
-13
AgentDataAnalyzeRestImpl.java
...cn/com/poc/expose/rest/impl/AgentDataAnalyzeRestImpl.java
+3
-6
AgentApplicationApiProfileTest.java
...poc/agent_application/AgentApplicationApiProfileTest.java
+3
-3
AgentApplicationExposeServiceTest.java
...c/expose/aggregate/AgentApplicationExposeServiceTest.java
+3
-5
No files found.
src/main/java/cn/com/poc/agent_application/aggregate/AgentApplication
Info
Service.java
→
src/main/java/cn/com/poc/agent_application/aggregate/AgentApplicationService.java
View file @
05de9276
package
cn
.
com
.
poc
.
agent_application
.
aggregate
;
import
cn.com.poc.agent_application.domain.FunctionResult
;
import
cn.com.poc.agent_application.entity.AgentResultEntity
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationInfoEntity
;
import
cn.com.poc.agent_application.entity.CreateAgentTitleAndDescEntity
;
import
cn.com.poc.agent_application.entity.KnowledgeSuperclassProblemConfig
;
import
cn.com.poc.agent_application.entity.call_agent.CallAgentApplicationKnowledgeConfig
;
import
cn.com.poc.agent_application.entity.call_agent.CallAgentApplicationModelConfig
;
import
cn.com.poc.thirdparty.resource.demand.ai.constants.KnowledgeSearchTypeEnum
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.dialogue.Message
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.dialogue.Tool
;
...
...
@@ -15,7 +12,7 @@ import cn.com.poc.thirdparty.resource.demand.ai.entity.function.FunctionCallResu
import
javax.servlet.http.HttpServletResponse
;
import
java.util.List
;
public
interface
AgentApplication
Info
Service
{
public
interface
AgentApplicationService
{
/**
* 创建/更新应用
...
...
@@ -39,32 +36,6 @@ public interface AgentApplicationInfoService {
*/
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 文件URLs
* @param imageUrls 图片URLs
* @param stream 是否流式传输
* @param score 知识库参数score
* @param topK 知识库参数topK
* @param knowledgeSearchType 知识库参数知识搜索类型
*/
@Deprecated
AgentResultEntity
callAgentApplication
(
String
agentId
,
String
identifier
,
String
largeModel
,
String
agentSystem
,
Integer
[]
knowledgeIds
,
Integer
communicationTurn
,
Float
topP
,
Float
temperature
,
List
<
Message
>
messages
,
List
<
Tool
>
tools
,
List
<
String
>
fileUrls
,
boolean
stream
,
List
<
String
>
imageUrls
,
Double
score
,
Integer
topK
,
KnowledgeSearchTypeEnum
knowledgeSearchType
,
HttpServletResponse
httpServletResponse
)
throws
Exception
;
/**
* Agent应用对话
*
...
...
src/main/java/cn/com/poc/agent_application/aggregate/impl/AgentApplication
Info
ServiceImpl.java
→
src/main/java/cn/com/poc/agent_application/aggregate/impl/AgentApplicationServiceImpl.java
View file @
05de9276
package
cn
.
com
.
poc
.
agent_application
.
aggregate
.
impl
;
import
cn.com.poc.agent_application.aggregate.AgentApplication
Info
Service
;
import
cn.com.poc.agent_application.aggregate.AgentApplicationService
;
import
cn.com.poc.agent_application.constant.AgentApplicationConstants
;
import
cn.com.poc.agent_application.constant.AgentApplicationDialoguesRecordConstants
;
import
cn.com.poc.agent_application.constant.AgentApplicationGCConfigConstants
;
...
...
@@ -65,13 +65,13 @@ import java.util.stream.Collectors;
import
static
cn
.
com
.
poc
.
common
.
constant
.
XLangConstant
.*;
@Component
public
class
AgentApplication
InfoServiceImpl
implements
AgentApplicationInfo
Service
{
public
class
AgentApplication
ServiceImpl
implements
AgentApplication
Service
{
final
private
String
TEXT_EVENT_STREAM_CHARSET_UTF_8
=
"text/event-stream;charset=UTF-8"
;
final
private
String
EVENT_STREAM_PREFIX
=
"data: "
;
final
private
Logger
logger
=
LoggerFactory
.
getLogger
(
AgentApplication
Info
Service
.
class
);
final
private
Logger
logger
=
LoggerFactory
.
getLogger
(
AgentApplicationService
.
class
);
@Resource
private
BizKnowledgeDocumentService
bizKnowledgeDocumentService
;
...
...
@@ -173,66 +173,57 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
return
true
;
}
@Override
public
AgentResultEntity
callAgentApplication
(
String
agentId
,
String
dialogueId
,
String
largeModel
,
String
agentSystem
,
Integer
[]
kdIds
,
Integer
communicationTurn
,
Float
topP
,
Float
temperature
,
List
<
Message
>
messages
,
List
<
Tool
>
tools
,
List
<
String
>
fileUrls
,
boolean
stream
,
List
<
String
>
imageUrls
,
Double
score
,
Integer
topK
,
KnowledgeSearchTypeEnum
knowledgeSearchType
,
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
);
Tool
[]
toolArray
=
tools
.
toArray
(
new
Tool
[
0
]);
FunctionResult
functionResult
=
functionCall
(
dialogueId
,
messages
,
toolArray
,
agentId
,
fileUrls
,
imageUrls
);
List
<
KnowledgeContentResult
>
knowledgeResult
=
knowledge
(
kdIds
,
messages
,
topK
,
score
,
knowledgeSearchType
);
String
promptTemplate
=
buildDialogsPrompt
(
functionResult
,
agentSystem
,
toolArray
,
dialogueId
,
agentId
,
knowledgeResult
);
Message
[]
messageArray
=
buildMessages
(
messages
,
communicationTurn
,
promptTemplate
);
return
llmExecutorAndOutput
(
topP
,
stream
,
model
,
messageArray
,
functionResult
,
knowledgeResult
,
httpServletResponse
);
}
@Override
public
AgentResultEntity
callAgentApplication
(
String
agentId
,
String
dialogueId
,
String
largeModel
,
String
agentSystem
,
Integer
[]
kdIds
,
Integer
communicationTurn
,
Float
topP
,
Float
temperature
,
List
<
Message
>
messages
,
List
<
Tool
>
tools
,
FunctionCallResult
functionCallResult
,
List
<
String
>
fileUrls
,
boolean
stream
,
List
<
String
>
imageUrls
,
Double
score
,
Integer
topK
,
KnowledgeSearchTypeEnum
knowledgeSearchType
,
KnowledgeSuperclassProblemConfig
superclassProblemConfig
,
HttpServletResponse
httpServletResponse
)
throws
Exception
{
String
model
=
modelConvert
(
largeModel
);
Tool
[]
toolArray
=
tools
.
toArray
(
new
Tool
[
0
]);
List
<
KnowledgeContentResult
>
knowledgeResult
=
knowledge
(
kdIds
,
messages
,
topK
,
score
,
knowledgeSearchType
);
if
(
superclassProblem
(
superclassProblemConfig
,
kdIds
,
knowledgeResult
))
{
String
mess
=
superclassProblemConfig
.
getKnowledgeCustomResponse
()[
0
];
logger
.
info
(
"触发知识库超纲回答,mess{}"
,
mess
);
if
(
stream
)
{
PrintWriter
writer
=
httpServletResponse
.
getWriter
();
LargeModelDemandResult
result
=
new
LargeModelDemandResult
();
result
.
setCode
(
"0"
);
result
.
setMessage
(
mess
);
result
.
setFinish_reason
(
"finish"
);
writer
.
write
(
EVENT_STREAM_PREFIX
+
JsonUtils
.
serialize
(
result
)
+
"\n\n"
);
writer
.
write
(
EVENT_STREAM_PREFIX
+
"[DONE]"
+
"\n\n"
);
writer
.
flush
();
writer
.
close
();
}
AgentResultEntity
agentResultEntity
=
new
AgentResultEntity
();
agentResultEntity
.
setMessage
(
mess
);
return
agentResultEntity
;
}
Tool
[]
toolArray
=
tools
.
toArray
(
new
Tool
[
0
]);
return
sendProblemMess
(
stream
,
superclassProblemConfig
,
httpServletResponse
);
}
else
{
FunctionResult
functionResult
=
functionCall
(
dialogueId
,
functionCallResult
,
agentId
);
FunctionResult
functionResult
=
functionCall
(
dialogueId
,
functionCallResult
,
agentId
);
String
promptTemplate
=
buildDialogsPrompt
(
functionResult
,
agentSystem
,
toolArray
,
dialogueId
,
agentId
,
knowledgeResult
);
String
promptTemplate
=
buildDialogsPrompt
(
functionResult
,
agentSystem
,
toolArray
,
dialogueId
,
agentId
,
knowledgeResult
);
Message
[]
messageArray
=
buildMessages
(
messages
,
communicationTurn
,
promptTemplate
);
Message
[]
messageArray
=
buildMessages
(
messages
,
communicationTurn
,
promptTemplate
);
return
llmExecutorAndOutput
(
topP
,
stream
,
model
,
messageArray
,
functionResult
,
knowledgeResult
,
httpServletResponse
);
return
llmExecutorAndOutput
(
topP
,
stream
,
model
,
messageArray
,
functionResult
,
knowledgeResult
,
httpServletResponse
);
}
}
/**
* 发送知识库超纲回答
*
* @param stream
* @param superclassProblemConfig
* @param httpServletResponse
* @return
* @throws IOException
*/
private
AgentResultEntity
sendProblemMess
(
boolean
stream
,
KnowledgeSuperclassProblemConfig
superclassProblemConfig
,
HttpServletResponse
httpServletResponse
)
throws
IOException
{
String
mess
=
superclassProblemConfig
.
getKnowledgeCustomResponse
()[
0
];
logger
.
info
(
"触发知识库超纲回答,mess{}"
,
mess
);
if
(
stream
)
{
SSEUtil
sseUtil
=
new
SSEUtil
(
httpServletResponse
);
LargeModelDemandResult
result
=
new
LargeModelDemandResult
();
result
.
setCode
(
"0"
);
result
.
setMessage
(
mess
);
result
.
setFinish_reason
(
"finish"
);
sseUtil
.
send
(
JsonUtils
.
serialize
(
result
));
sseUtil
.
send
(
"[DONE]"
);
sseUtil
.
complete
();
}
AgentResultEntity
agentResultEntity
=
new
AgentResultEntity
();
agentResultEntity
.
setMessage
(
mess
);
return
agentResultEntity
;
}
...
...
@@ -563,15 +554,11 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
private
AgentResultEntity
llmExecutorAndOutput
(
Float
topP
,
boolean
stream
,
String
model
,
Message
[]
messageArray
,
FunctionResult
functionResult
,
List
<
KnowledgeContentResult
>
knowledgeResult
,
HttpServletResponse
httpServletResponse
)
throws
Exception
{
if
(
stream
)
{
SSEUtil
sseUtil
=
new
SSEUtil
(
httpServletResponse
);
// httpServletResponse.setContentType(TEXT_EVENT_STREAM_CHARSET_UTF_8);
// PrintWriter writer = httpServletResponse.getWriter();
if
(
CollectionUtils
.
isNotEmpty
(
knowledgeResult
))
{
LargeModelDemandResult
result
=
new
LargeModelDemandResult
();
result
.
setCode
(
"0"
);
result
.
setKnowledgeContentResult
(
knowledgeResult
);
sseUtil
.
send
(
JsonUtils
.
serialize
(
result
));
// writer.write(EVENT_STREAM_PREFIX + JsonUtils.serialize(result) + "\n\n");
// writer.flush();
}
if
(
ObjectUtil
.
isNotNull
(
functionResult
)
&&
StringUtils
.
isNotBlank
(
functionResult
.
getFunctionName
()))
{
LargeModelDemandResult
result
=
new
LargeModelDemandResult
();
...
...
@@ -579,8 +566,6 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
ToolFunction
toolFunction
=
functionResultConvertToolFunction
(
functionResult
);
result
.
setFunction
(
toolFunction
);
sseUtil
.
send
(
JsonUtils
.
serialize
(
result
));
// writer.write(EVENT_STREAM_PREFIX + JsonUtils.serialize(result) + "\n\n");
// writer.flush();
}
BufferedReader
bufferedReader
=
invokeLLMStream
(
model
,
messageArray
,
topP
);
return
textOutputStream
(
sseUtil
,
bufferedReader
);
...
...
src/main/java/cn/com/poc/agent_application/rest/impl/AgentApplicationInfoRestImpl.java
View file @
05de9276
package
cn
.
com
.
poc
.
agent_application
.
rest
.
impl
;
import
cn.com.poc.agent_application.aggregate.AgentApplication
Info
Service
;
import
cn.com.poc.agent_application.aggregate.AgentApplicationService
;
import
cn.com.poc.agent_application.convert.AgentApplicationInfoConvert
;
import
cn.com.poc.agent_application.domain.LargeModelInfo
;
import
cn.com.poc.agent_application.dto.*
;
...
...
@@ -57,7 +57,7 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
private
BizAgentApplicationInfoService
bizAgentApplicationInfoService
;
@Resource
private
AgentApplication
InfoService
agentApplicationInfo
Service
;
private
AgentApplication
Service
agentApplication
Service
;
@Resource
private
BizAgentApplicationPublishService
bizAgentApplicationPublishService
;
...
...
@@ -184,7 +184,7 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
throw
new
I18nMessageException
(
"exception/create.num.limit"
);
}
}
return
AgentApplicationInfoConvert
.
entityToDto
(
agentApplication
Info
Service
.
saveOrUpdate
(
entity
));
return
AgentApplicationInfoConvert
.
entityToDto
(
agentApplicationService
.
saveOrUpdate
(
entity
));
}
...
...
@@ -212,7 +212,7 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
@Override
public
void
delete
(
String
agentId
)
throws
Exception
{
Assert
.
notNull
(
agentId
);
agentApplication
Info
Service
.
deletedAgentApplication
(
agentId
);
agentApplicationService
.
deletedAgentApplication
(
agentId
);
}
@Override
...
...
@@ -225,7 +225,7 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
Assert
.
notNull
(
dto
.
getCommModelConfig
());
Assert
.
notNull
(
dto
.
getKnowledgeConfig
());
BizAgentApplicationInfoEntity
bizAgentApplicationInfoEntity
=
AgentApplicationInfoConvert
.
dtoToEntity
(
dto
);
agentApplication
Info
Service
.
updateAndPublish
(
bizAgentApplicationInfoEntity
);
agentApplicationService
.
updateAndPublish
(
bizAgentApplicationInfoEntity
);
return
true
;
}
...
...
@@ -276,7 +276,7 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
agentUseModifyEventInfo
.
setIsPublish
(
CommonConstant
.
IsDeleted
.
N
);
reduceSn
=
memberEquityService
.
reducePoint
(
userBaseEntity
.
getUserId
(),
pointDeductionNum
,
ModifyEventEnum
.
use
,
agentUseModifyEventInfo
);
//调用应用服务
agentApplication
Info
Service
.
callAgentApplication
(
agentId
,
dialogueId
,
model
,
agentApplicationService
.
callAgentApplication
(
agentId
,
dialogueId
,
model
,
agentSystem
,
kdIds
.
toArray
(
new
Integer
[
0
]),
communicationTurn
,
topP
,
temperature
,
dto
.
getMessages
(),
tools
,
checkPluginUseEntity
.
getFunctionCallResult
(),
dto
.
getFileUrls
(),
true
,
imageUrls
,
infoEntity
.
getKnowledgeSimilarity
(),
infoEntity
.
getKnowledgeNResult
(),
KnowledgeSearchTypeEnum
.
valueOf
(
infoEntity
.
getKnowledgeSearchType
()),
...
...
@@ -411,29 +411,29 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
@Override
public
void
createAgentSystem
(
AgentApplicationGCDto
dto
,
HttpServletResponse
response
)
throws
Exception
{
Assert
.
notNull
(
dto
.
getInput
());
agentApplication
Info
Service
.
createAgentSystem
(
dto
.
getInput
(),
response
);
agentApplicationService
.
createAgentSystem
(
dto
.
getInput
(),
response
);
}
@Override
public
List
<
String
>
createFeaturedQuestions
(
AgentApplicationGCDto
dto
)
{
return
agentApplication
Info
Service
.
createFeaturedQuestions
(
dto
.
getAgentTitle
(),
dto
.
getAgentDesc
());
return
agentApplicationService
.
createFeaturedQuestions
(
dto
.
getAgentTitle
(),
dto
.
getAgentDesc
());
}
@Override
public
String
createPreamble
(
AgentApplicationGCDto
dto
)
{
return
agentApplication
Info
Service
.
createPreamble
(
dto
.
getAgentTitle
(),
dto
.
getAgentDesc
(),
dto
.
getAgentSystem
());
return
agentApplicationService
.
createPreamble
(
dto
.
getAgentTitle
(),
dto
.
getAgentDesc
(),
dto
.
getAgentSystem
());
}
@Override
public
String
createAgentApplicationAvatar
(
AgentApplicationGCDto
dto
)
throws
Exception
{
Assert
.
isTrue
(
StringUtils
.
isNotBlank
(
dto
.
getAgentDesc
())
||
StringUtils
.
isNotBlank
(
dto
.
getAgentTitle
()));
return
agentApplication
Info
Service
.
createAgentIcon
(
dto
.
getAgentTitle
(),
dto
.
getAgentDesc
());
return
agentApplicationService
.
createAgentIcon
(
dto
.
getAgentTitle
(),
dto
.
getAgentDesc
());
}
@Override
public
AgentApplicationGCDto
createAgentTitleAndDesc
(
AgentApplicationGCDto
dto
)
{
Assert
.
notNull
(
dto
.
getInput
());
CreateAgentTitleAndDescEntity
entity
=
agentApplication
Info
Service
.
createAgentTitleAndDesc
(
dto
.
getInput
());
CreateAgentTitleAndDescEntity
entity
=
agentApplicationService
.
createAgentTitleAndDesc
(
dto
.
getInput
());
if
(
null
==
entity
)
{
throw
new
I18nMessageException
(
"exception/generation.failed.please.try.again.later"
);
}
...
...
@@ -447,7 +447,7 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
@RedisLimit
(
key
=
"collect:agent_person"
,
currentUser
=
true
,
count
=
1
,
timeout
=
1
,
exceptionInfo
=
"exception/too.many.requests"
)
public
void
collectOrCancelAgentInPerson
(
String
agentId
)
throws
Exception
{
Assert
.
notNull
(
agentId
);
agentApplication
Info
Service
.
collectOrCancelAgentInPerson
(
agentId
);
agentApplicationService
.
collectOrCancelAgentInPerson
(
agentId
);
}
@Override
...
...
src/main/java/cn/com/poc/agent_application/scheduler/RecommendQuestionScheduler.java
View file @
05de9276
package
cn
.
com
.
poc
.
agent_application
.
scheduler
;
import
cn.com.poc.expose.aggregate.AgentApplicationService
;
import
cn.com.poc.expose.aggregate.AgentApplication
Expose
Service
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
...
...
@@ -11,7 +11,7 @@ import javax.annotation.Resource;
public
class
RecommendQuestionScheduler
{
@Resource
private
AgentApplication
Service
agentApplication
Service
;
private
AgentApplication
ExposeService
agentApplicationExpose
Service
;
/**
* 每日凌晨
...
...
@@ -20,6 +20,6 @@ public class RecommendQuestionScheduler {
*/
@Scheduled
(
cron
=
"0 0 0 * * ?"
)
public
void
knowledgeInfoStatusUpdateScheduler
()
throws
Exception
{
agentApplicationService
.
createRecommendQuestion
();
agentApplication
Expose
Service
.
createRecommendQuestion
();
}
}
src/main/java/cn/com/poc/expose/aggregate/AgentApplicationService.java
→
src/main/java/cn/com/poc/expose/aggregate/AgentApplication
Expose
Service.java
View file @
05de9276
...
...
@@ -2,14 +2,12 @@ package cn.com.poc.expose.aggregate;
import
cn.com.poc.agent_application.entity.BizAgentApplicationApiProfileEntity
;
import
cn.com.poc.agent_application.query.MemberCollectQueryItem
;
import
cn.com.poc.expose.dto.AgentApplicationApiProfileDto
;
import
cn.com.yict.framemax.data.model.PagingInfo
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.List
;
public
interface
AgentApplicationService
{
public
interface
AgentApplication
Expose
Service
{
/**
* 调用 已发布Agent应用
...
...
src/main/java/cn/com/poc/expose/aggregate/impl/AgentApplicationApiServiceImpl.java
View file @
05de9276
package
cn
.
com
.
poc
.
expose
.
aggregate
.
impl
;
import
cn.com.poc.agent_application.aggregate.AgentApplication
Info
Service
;
import
cn.com.poc.agent_application.aggregate.AgentApplicationService
;
import
cn.com.poc.agent_application.constant.AgentApplicationDialoguesRecordConstants
;
import
cn.com.poc.agent_application.entity.*
;
import
cn.com.poc.agent_application.service.*
;
...
...
@@ -55,7 +55,7 @@ public class AgentApplicationApiServiceImpl implements AgentApplicationApiServic
private
BizAgentApplicationPublishService
bizAgentApplicationPublishService
;
@Resource
private
AgentApplication
InfoService
agentApplicationInfo
Service
;
private
AgentApplication
Service
agentApplication
Service
;
@Resource
private
KnowledgeService
knowledgeService
;
...
...
@@ -168,7 +168,7 @@ public class AgentApplicationApiServiceImpl implements AgentApplicationApiServic
//对话
try
{
AgentResultEntity
agentResultEntity
=
agentApplication
Info
Service
.
callAgentApplication
(
agentId
,
conversationId
,
infoEntity
.
getLargeModel
(),
AgentResultEntity
agentResultEntity
=
agentApplicationService
.
callAgentApplication
(
agentId
,
conversationId
,
infoEntity
.
getLargeModel
(),
infoEntity
.
getAgentSystem
(),
kdIdList
.
toArray
(
new
Integer
[
0
]),
infoEntity
.
getCommunicationTurn
(),
infoEntity
.
getTopP
(),
infoEntity
.
getTemperature
(),
messages
,
tools
,
checkPluginUseEntity
.
getFunctionCallResult
(),
fileUrls
,
stream
,
imageUrls
,
infoEntity
.
getKnowledgeSimilarity
(),
infoEntity
.
getKnowledgeNResult
(),
KnowledgeSearchTypeEnum
.
valueOf
(
infoEntity
.
getKnowledgeSearchType
()),
...
...
src/main/java/cn/com/poc/expose/aggregate/impl/AgentApplicationServiceImpl.java
→
src/main/java/cn/com/poc/expose/aggregate/impl/AgentApplication
Expose
ServiceImpl.java
View file @
05de9276
package
cn
.
com
.
poc
.
expose
.
aggregate
.
impl
;
import
cn.com.poc.agent_application.aggregate.AgentApplication
Info
Service
;
import
cn.com.poc.agent_application.aggregate.AgentApplicationService
;
import
cn.com.poc.agent_application.constant.AgentApplicationDialoguesRecordConstants
;
import
cn.com.poc.agent_application.constant.AgentApplicationGCConfigConstants
;
import
cn.com.poc.agent_application.entity.*
;
...
...
@@ -19,7 +19,7 @@ import cn.com.poc.equity.aggregate.MemberEquityService;
import
cn.com.poc.equity.aggregate.PointDeductionRulesService
;
import
cn.com.poc.equity.constants.ModifyEventEnum
;
import
cn.com.poc.equity.domain.modifyEquityInfo.AgentUseModifyEventInfo
;
import
cn.com.poc.expose.aggregate.AgentApplicationService
;
import
cn.com.poc.expose.aggregate.AgentApplication
Expose
Service
;
import
cn.com.poc.knowledge.aggregate.KnowledgeService
;
import
cn.com.poc.support.security.oauth.entity.UserBaseEntity
;
import
cn.com.poc.thirdparty.resource.demand.ai.constants.KnowledgeSearchTypeEnum
;
...
...
@@ -51,9 +51,9 @@ import java.util.Set;
import
java.util.stream.Collectors
;
@Service
public
class
AgentApplication
ServiceImpl
implements
AgentApplication
Service
{
public
class
AgentApplication
ExposeServiceImpl
implements
AgentApplicationExpose
Service
{
final
private
Logger
logger
=
LoggerFactory
.
getLogger
(
AgentApplicationService
.
class
);
final
private
Logger
logger
=
LoggerFactory
.
getLogger
(
AgentApplication
Expose
Service
.
class
);
/**
* 推荐问Key
...
...
@@ -84,7 +84,7 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
private
BizAgentApplicationDialoguesRecordService
bizAgentApplicationDialoguesRecordService
;
@Resource
private
AgentApplication
InfoService
agentApplicationInfo
Service
;
private
AgentApplication
Service
agentApplication
Service
;
@Resource
private
BizAgentApplicationGcConfigService
bizAgentApplicationGcConfigService
;
...
...
@@ -185,7 +185,7 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
}
}
//对话
AgentResultEntity
agentResultEntity
=
agentApplication
Info
Service
.
callAgentApplication
(
agentId
,
dialogsId
,
infoEntity
.
getLargeModel
(),
AgentResultEntity
agentResultEntity
=
agentApplicationService
.
callAgentApplication
(
agentId
,
dialogsId
,
infoEntity
.
getLargeModel
(),
infoEntity
.
getAgentSystem
(),
kdIdList
.
toArray
(
new
Integer
[
0
]),
infoEntity
.
getCommunicationTurn
(),
infoEntity
.
getTopP
(),
infoEntity
.
getTemperature
(),
messages
,
tools
,
checkPluginUseEntity
.
getFunctionCallResult
(),
fileUrls
,
true
,
imageUrls
,
infoEntity
.
getKnowledgeSimilarity
(),
infoEntity
.
getKnowledgeNResult
(),
KnowledgeSearchTypeEnum
.
valueOf
(
infoEntity
.
getKnowledgeSearchType
()),
...
...
@@ -258,7 +258,7 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
String
redisKey
=
AGENT_APPLICATION_RECOMMEND_QUESTIONS
+
xlang
;
if
(!
redisService
.
hasKey
(
redisKey
))
{
synchronized
(
AgentApplication
Info
Service
.
class
)
{
synchronized
(
AgentApplicationService
.
class
)
{
if
(!
redisService
.
hasKey
(
redisKey
))
{
createRecommendQuestion
();
}
...
...
src/main/java/cn/com/poc/expose/rest/impl/AgentApplicationRestImpl.java
View file @
05de9276
package
cn
.
com
.
poc
.
expose
.
rest
.
impl
;
import
cn.com.poc.agent_application.aggregate.AgentApplication
Info
Service
;
import
cn.com.poc.agent_application.aggregate.AgentApplicationService
;
import
cn.com.poc.agent_application.convert.AgentApplicationInfoConvert
;
import
cn.com.poc.agent_application.convert.BizAgentApplicationPublishConvert
;
import
cn.com.poc.agent_application.dto.AgentApplicationCreateContinueQuesDto
;
...
...
@@ -19,7 +19,7 @@ import cn.com.poc.common.utils.StringUtils;
import
cn.com.poc.common.utils.UUIDTool
;
import
cn.com.poc.equity.aggregate.PointDeductionRulesService
;
import
cn.com.poc.equity.entity.BizPointDeductionRulesEntity
;
import
cn.com.poc.expose.aggregate.AgentApplicationService
;
import
cn.com.poc.expose.aggregate.AgentApplication
Expose
Service
;
import
cn.com.poc.expose.dto.*
;
import
cn.com.poc.expose.rest.AgentApplicationRest
;
import
cn.com.poc.message.entity.AgentApplicationClickEventMessage
;
...
...
@@ -50,10 +50,10 @@ public class AgentApplicationRestImpl implements AgentApplicationRest {
private
Logger
logger
=
LoggerFactory
.
getLogger
(
AgentApplicationRest
.
class
);
@Resource
private
AgentApplication
Service
agentApplication
Service
;
private
AgentApplication
ExposeService
agentApplicationExpose
Service
;
@Resource
private
AgentApplication
InfoService
agentApplicationInfo
Service
;
private
AgentApplication
Service
agentApplication
Service
;
@Resource
private
BizAgentApplicationPublishService
bizAgentApplicationPublishService
;
...
...
@@ -70,7 +70,7 @@ public class AgentApplicationRestImpl implements AgentApplicationRest {
@Override
public
List
<
String
>
getRecommendQuestions
(
HttpServletRequest
httpServletRequest
)
throws
Exception
{
UserBaseEntity
userBaseEntity
=
BlContext
.
getCurrentUserNotException
();
return
agentApplicationService
.
getRecommendQuestions
(
httpServletRequest
.
getHeader
(
"x-lang"
),
userBaseEntity
.
getUserId
());
return
agentApplication
Expose
Service
.
getRecommendQuestions
(
httpServletRequest
.
getHeader
(
"x-lang"
),
userBaseEntity
.
getUserId
());
}
@Override
...
...
@@ -80,7 +80,7 @@ public class AgentApplicationRestImpl implements AgentApplicationRest {
throw
new
I18nMessageException
(
"exception/user.not.login"
);
}
Long
memberId
=
userBaseEntity
.
getUserId
();
List
<
MemberCollectQueryItem
>
collectedApplications
=
agentApplicationService
.
getCollectedApplications
(
memberId
,
pagingInfo
);
List
<
MemberCollectQueryItem
>
collectedApplications
=
agentApplication
Expose
Service
.
getCollectedApplications
(
memberId
,
pagingInfo
);
List
<
UserCollectDto
>
result
=
new
ArrayList
<>();
if
(
CollectionUtils
.
isNotEmpty
(
collectedApplications
))
{
for
(
MemberCollectQueryItem
item
:
collectedApplications
)
{
...
...
@@ -112,7 +112,7 @@ public class AgentApplicationRestImpl implements AgentApplicationRest {
Assert
.
notNull
(
dto
.
getAgentId
());
Assert
.
notNull
(
dto
.
getDialogsId
());
try
{
agentApplicationService
.
callAgentApplication
(
dto
.
getAgentId
(),
dto
.
getDialogsId
(),
dto
.
getInput
(),
dto
.
getFileUrls
(),
dto
.
getChannel
(),
dto
.
getImageUrl
(),
httpServletResponse
);
agentApplication
Expose
Service
.
callAgentApplication
(
dto
.
getAgentId
(),
dto
.
getDialogsId
(),
dto
.
getInput
(),
dto
.
getFileUrls
(),
dto
.
getChannel
(),
dto
.
getImageUrl
(),
httpServletResponse
);
}
catch
(
Exception
e
)
{
httpServletResponse
.
setContentType
(
"text/event-stream"
);
PrintWriter
writer
=
httpServletResponse
.
getWriter
();
...
...
@@ -181,13 +181,13 @@ public class AgentApplicationRestImpl implements AgentApplicationRest {
@Override
public
void
unPublish
(
String
agentId
)
throws
Exception
{
Assert
.
notBlank
(
agentId
);
agentApplication
Info
Service
.
unPublish
(
agentId
);
agentApplicationService
.
unPublish
(
agentId
);
}
@Override
public
List
<
String
>
createContinueQuestions
(
AgentApplicationCreateContinueQuesDto
dto
)
throws
Exception
{
Assert
.
notNull
(
dto
.
getInput
());
return
agentApplicationService
.
createContinueQuestions
(
dto
.
getInput
());
return
agentApplication
Expose
Service
.
createContinueQuestions
(
dto
.
getInput
());
}
@Override
...
...
@@ -257,7 +257,7 @@ public class AgentApplicationRestImpl implements AgentApplicationRest {
public
String
autoPlayByAgentId
(
String
agentId
)
{
Assert
.
notBlank
(
agentId
);
UserBaseEntity
currentUser
=
BlContext
.
getCurrentUser
();
return
agentApplicationService
.
autoPlayByAgentId
(
currentUser
.
getUserId
(),
agentId
);
return
agentApplication
Expose
Service
.
autoPlayByAgentId
(
currentUser
.
getUserId
(),
agentId
);
}
@Override
...
...
@@ -266,13 +266,13 @@ public class AgentApplicationRestImpl implements AgentApplicationRest {
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
);
return
agentApplication
Expose
Service
.
enableAutoPlay
(
currentUser
.
getUserId
(),
agentId
,
autoPlay
);
}
@Override
public
AgentApplicationApiProfileDto
getApiProfile
()
{
UserBaseEntity
userBaseEntity
=
BlContext
.
getCurrentUser
();
BizAgentApplicationApiProfileEntity
apiProfileEntity
=
agentApplicationService
.
getApiProfile
(
userBaseEntity
.
getUserId
());
BizAgentApplicationApiProfileEntity
apiProfileEntity
=
agentApplication
Expose
Service
.
getApiProfile
(
userBaseEntity
.
getUserId
());
AgentApplicationApiProfileDto
result
=
new
AgentApplicationApiProfileDto
();
result
.
setApiKey
(
apiProfileEntity
.
getApiKey
());
result
.
setApiSecret
(
apiProfileEntity
.
getApiSecret
());
...
...
@@ -282,7 +282,7 @@ public class AgentApplicationRestImpl implements AgentApplicationRest {
@Override
public
AgentApplicationApiProfileDto
resetApiProfile
()
throws
Exception
{
UserBaseEntity
userBaseEntity
=
BlContext
.
getCurrentUser
();
BizAgentApplicationApiProfileEntity
apiProfileEntity
=
agentApplicationService
.
resetApiProfile
(
userBaseEntity
.
getUserId
());
BizAgentApplicationApiProfileEntity
apiProfileEntity
=
agentApplication
Expose
Service
.
resetApiProfile
(
userBaseEntity
.
getUserId
());
AgentApplicationApiProfileDto
result
=
new
AgentApplicationApiProfileDto
();
result
.
setApiKey
(
apiProfileEntity
.
getApiKey
());
result
.
setApiSecret
(
apiProfileEntity
.
getApiSecret
());
...
...
src/main/java/cn/com/poc/expose/rest/impl/AgentDataAnalyzeRestImpl.java
View file @
05de9276
package
cn
.
com
.
poc
.
expose
.
rest
.
impl
;
import
cn.com.poc.agent_application.aggregate.AgentApplication
Info
Service
;
import
cn.com.poc.agent_application.aggregate.AgentApplicationService
;
import
cn.com.poc.common.utils.BlContext
;
import
cn.com.poc.common.utils.ListUtils
;
import
cn.com.poc.data_analyze.constants.DataAnalyzeChannelEnum
;
import
cn.com.poc.data_analyze.entity.*
;
import
cn.com.poc.expose.aggregate.AgentDataAnalyzeService
;
import
cn.com.poc.expose.dto.agent_data_analyze.*
;
import
cn.com.poc.expose.rest.AgentDataAnalyzeRest
;
import
cn.com.poc.support.security.oauth.entity.UserBaseEntity
;
import
cn.com.yict.framemax.core.i18n.I18nMessageException
;
import
cn.hutool.core.collection.ListUtil
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.springframework.stereotype.Component
;
...
...
@@ -31,7 +28,7 @@ public class AgentDataAnalyzeRestImpl implements AgentDataAnalyzeRest {
private
AgentDataAnalyzeService
agentDataAnalyzeService
;
@Resource
private
AgentApplication
InfoService
agentApplicationInfo
Service
;
private
AgentApplication
Service
agentApplication
Service
;
@Override
public
List
<
AgentDataAnalyzeGeneralDto
>
getGeneralUsageData
(
String
agentId
,
List
<
String
>
channel
)
{
...
...
@@ -128,7 +125,7 @@ public class AgentDataAnalyzeRestImpl implements AgentDataAnalyzeRest {
if
(
userBaseEntity
==
null
)
{
throw
new
I18nMessageException
(
"exception/user.does.not.exist"
);
}
if
(!
agentApplication
Info
Service
.
hasPublishAgentPermission
(
agentId
,
userBaseEntity
.
getUserId
()))
{
if
(!
agentApplicationService
.
hasPublishAgentPermission
(
agentId
,
userBaseEntity
.
getUserId
()))
{
throw
new
I18nMessageException
(
"exception/no.permission"
);
}
}
...
...
src/test/java/cn/com/poc/agent_application/AgentApplicationApiProfileTest.java
View file @
05de9276
...
...
@@ -3,7 +3,7 @@ package cn.com.poc.agent_application;
import
cn.com.poc.agent_application.entity.BizAgentApplicationApiProfileEntity
;
import
cn.com.poc.agent_application.service.BizAgentApplicationApiProfileService
;
import
cn.com.poc.common.utils.JsonUtils
;
import
cn.com.poc.expose.aggregate.AgentApplicationService
;
import
cn.com.poc.expose.aggregate.AgentApplication
Expose
Service
;
import
cn.com.poc.expose.dto.AgentApplicationApiProfileDto
;
import
cn.com.yict.framemax.core.spring.SingleContextInitializer
;
import
org.junit.Test
;
...
...
@@ -34,12 +34,12 @@ public class AgentApplicationApiProfileTest {
}
@Resource
private
AgentApplication
Service
agentApplication
Service
;
private
AgentApplication
ExposeService
agentApplicationExpose
Service
;
@Test
public
void
test_getApiProfile
()
{
String
agentId
=
"d37d4a9b2fe0421ea991127c247fbbf3"
;
BizAgentApplicationApiProfileEntity
apiProfileEntity
=
agentApplicationService
.
getApiProfile
(
197L
);
BizAgentApplicationApiProfileEntity
apiProfileEntity
=
agentApplication
Expose
Service
.
getApiProfile
(
197L
);
AgentApplicationApiProfileDto
result
=
new
AgentApplicationApiProfileDto
();
result
.
setApiKey
(
apiProfileEntity
.
getApiKey
());
result
.
setApiSecret
(
apiProfileEntity
.
getApiSecret
());
...
...
src/test/java/cn/com/poc/expose/aggregate/AgentApplicationServiceTest.java
→
src/test/java/cn/com/poc/expose/aggregate/AgentApplication
Expose
ServiceTest.java
View file @
05de9276
...
...
@@ -4,14 +4,12 @@ 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.poc.expose.aggregate.impl.AgentApplication
Expose
ServiceImpl
;
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
;
...
...
@@ -27,11 +25,11 @@ import static org.mockito.Mockito.when;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@ContextConfiguration
(
initializers
=
SingleContextInitializer
.
class
)
@WebAppConfiguration
public
class
AgentApplicationServiceTest
{
public
class
AgentApplication
Expose
ServiceTest
{
private
BizMemberAgentApplicationCollectService
bizMemberAgentApplicationCollectService
;
@Resource
private
AgentApplicationServiceImpl
agentApplicationService
;
private
AgentApplication
Expose
ServiceImpl
agentApplicationService
;
private
Long
memberId
;
private
PagingInfo
pagingInfo
;
...
...
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