Commit 0f0d2481 authored by alex yao's avatar alex yao

feat: 优化角色指令生成

parent 2b741d07
...@@ -76,10 +76,11 @@ public interface AgentApplicationService { ...@@ -76,10 +76,11 @@ public interface AgentApplicationService {
* 角色指令AI生成 * 角色指令AI生成
* *
* @param input 用户输入内容 * @param input 用户输入内容
* @param optimizationSuggestions 优化建议
* @param httpServletResponse * @param httpServletResponse
* @return * @return
*/ */
void createAgentSystem(String input, HttpServletResponse httpServletResponse) throws Exception; void createAgentSystem(String input, String optimizationSuggestions, HttpServletResponse httpServletResponse) throws Exception;
/** /**
* 开场白AI生成 * 开场白AI生成
......
...@@ -229,7 +229,7 @@ public class AgentApplicationServiceImpl implements AgentApplicationService { ...@@ -229,7 +229,7 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
@Override @Override
public void createAgentSystem(String input, HttpServletResponse httpServletResponse) throws Exception { public void createAgentSystem(String input, String optimizationSuggestions, HttpServletResponse httpServletResponse) throws Exception {
BizAgentApplicationGcConfigEntity configEntity = bizAgentApplicationGcConfigService.getByConfigCode(AgentApplicationGCConfigConstants.AGENT_SYSTEM); BizAgentApplicationGcConfigEntity configEntity = bizAgentApplicationGcConfigService.getByConfigCode(AgentApplicationGCConfigConstants.AGENT_SYSTEM);
if (null == configEntity || StringUtils.isBlank(configEntity.getConfigSystem())) { if (null == configEntity || StringUtils.isBlank(configEntity.getConfigSystem())) {
throw new I18nMessageException("exception/create.[role.instruction].configuration.does.not.exist"); throw new I18nMessageException("exception/create.[role.instruction].configuration.does.not.exist");
...@@ -238,8 +238,12 @@ public class AgentApplicationServiceImpl implements AgentApplicationService { ...@@ -238,8 +238,12 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
systemMessage.setContent(configEntity.getConfigSystem()); systemMessage.setContent(configEntity.getConfigSystem());
systemMessage.setRole(LLMRoleEnum.SYSTEM.getRole()); systemMessage.setRole(LLMRoleEnum.SYSTEM.getRole());
String content = "[\" + input + \"]";
if (StringUtils.isNotBlank(optimizationSuggestions)) {
content = content + "\n 优化建议:[" + optimizationSuggestions + "]";
}
Message message = new Message(); Message message = new Message();
message.setContent("[" + input + "]"); message.setContent(content);
message.setRole(LLMRoleEnum.USER.getRole()); message.setRole(LLMRoleEnum.USER.getRole());
List<Message> messages = new ArrayList<Message>() {{ List<Message> messages = new ArrayList<Message>() {{
add(systemMessage); add(systemMessage);
......
...@@ -12,6 +12,8 @@ public class AgentApplicationGCDto implements Serializable { ...@@ -12,6 +12,8 @@ public class AgentApplicationGCDto implements Serializable {
private String agentSystem; private String agentSystem;
private String optimizationSuggestions;
public String getInput() { public String getInput() {
return input; return input;
} }
...@@ -20,6 +22,13 @@ public class AgentApplicationGCDto implements Serializable { ...@@ -20,6 +22,13 @@ public class AgentApplicationGCDto implements Serializable {
this.input = input; this.input = input;
} }
public String getOptimizationSuggestions() {
return optimizationSuggestions;
}
public void setOptimizationSuggestions(String optimizationSuggestions) {
this.optimizationSuggestions = optimizationSuggestions;
}
public String getAgentTitle() { public String getAgentTitle() {
return agentTitle; return agentTitle;
......
...@@ -411,7 +411,7 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest { ...@@ -411,7 +411,7 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
@Override @Override
public void createAgentSystem(AgentApplicationGCDto dto, HttpServletResponse response) throws Exception { public void createAgentSystem(AgentApplicationGCDto dto, HttpServletResponse response) throws Exception {
Assert.notNull(dto.getInput()); Assert.notNull(dto.getInput());
agentApplicationService.createAgentSystem(dto.getInput(), response); agentApplicationService.createAgentSystem(dto.getInput(), dto.getOptimizationSuggestions(), response);
} }
@Override @Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment