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
6b57c794
Commit
6b57c794
authored
Sep 18, 2024
by
alex yao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:Agent应用 追问接口调整
parent
bef92269
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
64 additions
and
18 deletions
+64
-18
AgentApplicationInfoService.java
...nt_application/aggregate/AgentApplicationInfoService.java
+11
-1
AgentApplicationInfoServiceImpl.java
...ation/aggregate/impl/AgentApplicationInfoServiceImpl.java
+47
-0
AgentApplicationGCConfigConstants.java
...plication/constant/AgentApplicationGCConfigConstants.java
+2
-0
AgentApplicationCreateContinueQuesDto.java
...pplication/dto/AgentApplicationCreateContinueQuesDto.java
+0
-11
AgentApplicationService.java
.../cn/com/poc/expose/aggregate/AgentApplicationService.java
+1
-2
AgentApplicationServiceImpl.java
...oc/expose/aggregate/impl/AgentApplicationServiceImpl.java
+1
-1
AgentApplicationRestImpl.java
...cn/com/poc/expose/rest/impl/AgentApplicationRestImpl.java
+2
-3
No files found.
src/main/java/cn/com/poc/agent_application/aggregate/AgentApplicationInfoService.java
View file @
6b57c794
...
...
@@ -50,6 +50,16 @@ public interface AgentApplicationInfoService {
*/
List
<
String
>
createFeaturedQuestions
(
String
agentTitle
,
String
agentDesc
);
/**
* AGENT 应用图标生成
*
* @param agentTitle 应用标题
* @param agentDesc 应用描述
* @return Agent 应用图标URL
*/
String
createAgentIcon
(
String
agentTitle
,
String
agentDesc
);
/**
* Agent 应用标题,描述生成
*/
}
src/main/java/cn/com/poc/agent_application/aggregate/impl/AgentApplicationInfoServiceImpl.java
View file @
6b57c794
...
...
@@ -27,6 +27,7 @@ import org.apache.commons.lang3.StringUtils;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.Assert
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletResponse
;
...
...
@@ -164,6 +165,11 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
largeModelResponse
.
setUser
(
"POC-CREATE-PREAMBLE"
);
LargeModelDemandResult
largeModelDemandResult
=
llmService
.
chat
(
largeModelResponse
);
if
(
largeModelDemandResult
==
null
||
!
"0"
.
equals
(
largeModelDemandResult
.
getCode
()))
{
logger
.
error
(
"create preamble error, largeModelResponse:{}"
,
largeModelResponse
);
throw
new
BusinessException
(
"创建[开场白]失败"
);
}
return
largeModelDemandResult
.
getMessage
();
}
...
...
@@ -207,6 +213,47 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
}.
getType
());
}
@Override
public
String
createAgentIcon
(
String
agentTitle
,
String
agentDesc
)
{
Assert
.
isTrue
(
StringUtils
.
isNotBlank
(
agentTitle
)
||
StringUtils
.
isNotBlank
(
agentDesc
),
"请输入标题或者描述再生成应用头像"
);
BizAgentApplicationGcConfigEntity
configEntity
=
bizAgentApplicationGcConfigService
.
getByConfigCode
(
AgentApplicationGCConfigConstants
.
AGENT_ICON
);
if
(
null
==
configEntity
||
StringUtils
.
isBlank
(
configEntity
.
getConfigSystem
()))
{
throw
new
BusinessException
(
"创建[头像]配置不存在"
);
}
List
<
MultiContent
>
multiContents
=
new
ArrayList
<>();
multiContents
.
add
(
new
MultiContent
()
{{
String
configSystem
=
configEntity
.
getConfigSystem
();
if
(
StringUtils
.
isNotBlank
(
agentTitle
))
{
configSystem
=
configSystem
.
replace
(
"${agent_title}"
,
agentTitle
);
}
if
(
StringUtils
.
isNotBlank
(
agentDesc
))
{
configSystem
=
configSystem
.
replace
(
"${agent_desc}"
,
agentDesc
);
}
setText
(
configSystem
);
setType
(
"text"
);
}});
Message
message
=
new
Message
();
message
.
setContent
(
multiContents
);
message
.
setRole
(
AgentApplicationDialoguesRecordConstants
.
ROLE
.
USER
);
List
<
Message
>
messages
=
new
ArrayList
<
Message
>()
{{
add
(
message
);
}};
LargeModelResponse
largeModelResponse
=
new
LargeModelResponse
();
largeModelResponse
.
setModel
(
configEntity
.
getLargeModel
());
largeModelResponse
.
setMessages
(
messages
.
toArray
(
new
Message
[
1
]));
largeModelResponse
.
setTopP
(
configEntity
.
getTopP
());
largeModelResponse
.
setUser
(
"POC-CREATE-AGENT-PROMPT"
);
LargeModelDemandResult
largeModelDemandResult
=
llmService
.
chat
(
largeModelResponse
);
if
(
largeModelDemandResult
==
null
||
!
"0"
.
equals
(
largeModelDemandResult
.
getCode
()))
{
logger
.
error
(
"create preamble error, largeModelResponse:{}"
,
largeModelResponse
);
throw
new
BusinessException
(
"创建[开场白]失败"
);
}
return
null
;
}
private
String
buildDialogsPrompt
(
List
<
Message
>
messages
,
String
agentSystem
,
String
[]
knowledgeIds
)
{
// todo 获取提示词模板
...
...
src/main/java/cn/com/poc/agent_application/constant/AgentApplicationGCConfigConstants.java
View file @
6b57c794
...
...
@@ -11,5 +11,7 @@ public interface AgentApplicationGCConfigConstants {
String
AGENT_CONTINUE_QUESTIONS
=
"AgentContinueQuestions"
;
String
AGENT_ICON
=
"AgentIcon"
;
}
src/main/java/cn/com/poc/agent_application/dto/AgentApplicationCreateContinueQuesDto.java
View file @
6b57c794
...
...
@@ -9,10 +9,6 @@ public class AgentApplicationCreateContinueQuesDto implements Serializable {
*/
private
String
input
;
/**
* 应用ID
*/
private
String
agentId
;
public
String
getInput
()
{
return
input
;
...
...
@@ -22,11 +18,4 @@ public class AgentApplicationCreateContinueQuesDto implements Serializable {
this
.
input
=
input
;
}
public
String
getAgentId
()
{
return
agentId
;
}
public
void
setAgentId
(
String
agentId
)
{
this
.
agentId
=
agentId
;
}
}
src/main/java/cn/com/poc/expose/aggregate/AgentApplicationService.java
View file @
6b57c794
...
...
@@ -16,9 +16,8 @@ public interface AgentApplicationService {
* 追问AI生成
*
* @param input 问题输入
* @param agentId 应用id
* @return
*/
List
<
String
>
createContinueQuestions
(
String
input
,
String
agentId
);
List
<
String
>
createContinueQuestions
(
String
input
);
}
src/main/java/cn/com/poc/expose/aggregate/impl/AgentApplicationServiceImpl.java
View file @
6b57c794
...
...
@@ -108,7 +108,7 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
}
@Override
public
List
<
String
>
createContinueQuestions
(
String
input
,
String
agentId
)
{
public
List
<
String
>
createContinueQuestions
(
String
input
)
{
BizAgentApplicationGcConfigEntity
configEntity
=
bizAgentApplicationGcConfigService
.
getByConfigCode
(
AgentApplicationGCConfigConstants
.
AGENT_CONTINUE_QUESTIONS
);
if
(
null
==
configEntity
)
{
throw
new
BusinessException
(
"创建[开场白]配置不存在"
);
...
...
src/main/java/cn/com/poc/expose/rest/impl/AgentApplicationRestImpl.java
View file @
6b57c794
...
...
@@ -70,8 +70,7 @@ public class AgentApplicationRestImpl implements AgentApplicationRest {
@Override
public
List
<
String
>
createContinueQuestions
(
AgentApplicationCreateContinueQuesDto
dto
)
throws
Exception
{
cn
.
com
.
poc
.
common
.
utils
.
Assert
.
notNull
(
dto
.
getInput
(),
"agentId不能为空"
);
cn
.
com
.
poc
.
common
.
utils
.
Assert
.
notNull
(
dto
.
getAgentId
(),
"input不能为空"
);
return
agentApplicationService
.
createContinueQuestions
(
dto
.
getInput
(),
dto
.
getAgentId
());
cn
.
com
.
poc
.
common
.
utils
.
Assert
.
notNull
(
dto
.
getInput
(),
"input不能为空"
);
return
agentApplicationService
.
createContinueQuestions
(
dto
.
getInput
());
}
}
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