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
c90bc2be
Commit
c90bc2be
authored
Sep 23, 2024
by
alex yao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:修改开场白AI生成流程
parent
4c803b86
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
13 deletions
+39
-13
AgentApplicationInfoService.java
...nt_application/aggregate/AgentApplicationInfoService.java
+4
-3
AgentApplicationInfoServiceImpl.java
...ation/aggregate/impl/AgentApplicationInfoServiceImpl.java
+24
-9
AgentApplicationGCDto.java
.../com/poc/agent_application/dto/AgentApplicationGCDto.java
+10
-0
AgentApplicationInfoRestImpl.java
...t_application/rest/impl/AgentApplicationInfoRestImpl.java
+1
-1
No files found.
src/main/java/cn/com/poc/agent_application/aggregate/AgentApplicationInfoService.java
View file @
c90bc2be
...
...
@@ -36,9 +36,10 @@ public interface AgentApplicationInfoService {
*
* @param agentTitle 应用标题
* @param agentDesc 应用描述
* @param agentSystem 应用角色指令
* @return
*/
String
createPreamble
(
String
agentTitle
,
String
agentDesc
);
String
createPreamble
(
String
agentTitle
,
String
agentDesc
,
String
agentSystem
);
/**
...
...
src/main/java/cn/com/poc/agent_application/aggregate/impl/AgentApplicationInfoServiceImpl.java
View file @
c90bc2be
...
...
@@ -138,7 +138,7 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
}
@Override
public
String
createPreamble
(
String
agentTitle
,
String
agentDesc
)
{
public
String
createPreamble
(
String
agentTitle
,
String
agentDesc
,
String
agentSystem
)
{
BizAgentApplicationGcConfigEntity
configEntity
=
bizAgentApplicationGcConfigService
.
getByConfigCode
(
AgentApplicationGCConfigConstants
.
AGENT_PREAMBLE
);
if
(
null
==
configEntity
||
StringUtils
.
isBlank
(
configEntity
.
getConfigSystem
()))
{
throw
new
BusinessException
(
"创建[开场白]配置不存在"
);
...
...
@@ -147,12 +147,8 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
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
);
}
configSystem
=
buildPreambleConfigSystem
(
configSystem
,
agentTitle
,
agentDesc
,
agentSystem
);
setText
(
configSystem
);
setType
(
"text"
);
}});
...
...
@@ -178,6 +174,23 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
return
largeModelDemandResult
.
getMessage
();
}
private
static
String
buildPreambleConfigSystem
(
String
configSystem
,
String
agentTitle
,
String
agentDesc
,
String
agentSystem
)
{
//若 name desc prompt 都为空,传入默认参数 name 入参 智能问答机器人 desc 随时为你解答问题
if
(
StringUtils
.
isBlank
(
configSystem
)
&&
StringUtils
.
isBlank
(
agentTitle
)
&&
StringUtils
.
isBlank
(
agentDesc
))
{
return
configSystem
.
replace
(
"${agent_name}"
,
"智能问答机器人"
).
replace
(
"${agent_desc}"
,
" 随时为你解答问题"
);
}
//若 name desc 其中一项不为空则入参 不传入prompt
if
(
StringUtils
.
isNotBlank
(
agentTitle
)
||
(
StringUtils
.
isNotBlank
(
agentDesc
)))
{
return
configSystem
.
replace
(
"${agent_title}"
,
agentTitle
).
replace
(
"${agent_desc}"
,
agentDesc
);
}
// 若 name desc 都空 prompt 有内容,则把prompt 传入desc
if
(
StringUtils
.
isNotBlank
(
agentSystem
))
{
return
configSystem
.
replace
(
"${agent_desc}"
,
agentSystem
).
replace
(
"${agent_name}"
,
"智能问答机器人"
);
}
return
configSystem
;
}
@Override
public
List
<
String
>
createFeaturedQuestions
(
String
agentTitle
,
String
agentDesc
)
{
BizAgentApplicationGcConfigEntity
configEntity
=
bizAgentApplicationGcConfigService
.
getByConfigCode
(
AgentApplicationGCConfigConstants
.
AGENT_FEATURED_QUESTIONS
);
...
...
@@ -361,7 +374,8 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
* @param bufferedReader
* @throws IOException
*/
private
String
textOutput
(
HttpServletResponse
httpServletResponse
,
BufferedReader
bufferedReader
)
throws
IOException
{
private
String
textOutput
(
HttpServletResponse
httpServletResponse
,
BufferedReader
bufferedReader
)
throws
IOException
{
String
res
=
""
;
httpServletResponse
.
setContentType
(
TEXT_EVENT_STREAM_CHARSET_UTF_8
);
PrintWriter
writer
=
httpServletResponse
.
getWriter
();
...
...
@@ -396,7 +410,8 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
* @param promptTemplate
* @return
*/
private
static
Message
[]
buildMessages
(
List
<
Message
>
messages
,
Integer
communicationTurn
,
String
promptTemplate
)
{
private
static
Message
[]
buildMessages
(
List
<
Message
>
messages
,
Integer
communicationTurn
,
String
promptTemplate
)
{
int
messLength
=
messages
.
size
()
-
1
;
int
skip
=
communicationTurn
*
2
;
if
(
skip
<
messLength
)
{
...
...
src/main/java/cn/com/poc/agent_application/dto/AgentApplicationGCDto.java
View file @
c90bc2be
...
...
@@ -10,6 +10,8 @@ public class AgentApplicationGCDto implements Serializable {
private
String
agentDesc
;
private
String
agentSystem
;
public
String
getInput
()
{
return
input
;
}
...
...
@@ -34,4 +36,12 @@ public class AgentApplicationGCDto implements Serializable {
public
void
setAgentDesc
(
String
agentDesc
)
{
this
.
agentDesc
=
agentDesc
;
}
public
String
getAgentSystem
()
{
return
agentSystem
;
}
public
void
setAgentSystem
(
String
agentSystem
)
{
this
.
agentSystem
=
agentSystem
;
}
}
src/main/java/cn/com/poc/agent_application/rest/impl/AgentApplicationInfoRestImpl.java
View file @
c90bc2be
...
...
@@ -159,7 +159,7 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
@Override
public
String
createPreamble
(
AgentApplicationGCDto
dto
)
throws
Exception
{
return
agentApplicationInfoService
.
createPreamble
(
dto
.
getAgentTitle
(),
dto
.
getAgentDesc
());
return
agentApplicationInfoService
.
createPreamble
(
dto
.
getAgentTitle
(),
dto
.
getAgentDesc
()
,
dto
.
getAgentSystem
()
);
}
@Override
...
...
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