Commit 6b57c794 authored by alex yao's avatar alex yao

feat:Agent应用 追问接口调整

parent bef92269
...@@ -50,6 +50,16 @@ public interface AgentApplicationInfoService { ...@@ -50,6 +50,16 @@ public interface AgentApplicationInfoService {
*/ */
List<String> createFeaturedQuestions(String agentTitle, String agentDesc); List<String> createFeaturedQuestions(String agentTitle, String agentDesc);
/**
* AGENT 应用图标生成
*
* @param agentTitle 应用标题
* @param agentDesc 应用描述
* @return Agent 应用图标URL
*/
String createAgentIcon(String agentTitle, String agentDesc);
/**
* Agent 应用标题,描述生成
*/
} }
...@@ -27,6 +27,7 @@ import org.apache.commons.lang3.StringUtils; ...@@ -27,6 +27,7 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
...@@ -164,6 +165,11 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ ...@@ -164,6 +165,11 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
largeModelResponse.setUser("POC-CREATE-PREAMBLE"); largeModelResponse.setUser("POC-CREATE-PREAMBLE");
LargeModelDemandResult largeModelDemandResult = llmService.chat(largeModelResponse); 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(); return largeModelDemandResult.getMessage();
} }
...@@ -207,6 +213,47 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ ...@@ -207,6 +213,47 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
}.getType()); }.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) { private String buildDialogsPrompt(List<Message> messages, String agentSystem, String[] knowledgeIds) {
// todo 获取提示词模板 // todo 获取提示词模板
......
...@@ -11,5 +11,7 @@ public interface AgentApplicationGCConfigConstants { ...@@ -11,5 +11,7 @@ public interface AgentApplicationGCConfigConstants {
String AGENT_CONTINUE_QUESTIONS = "AgentContinueQuestions"; String AGENT_CONTINUE_QUESTIONS = "AgentContinueQuestions";
String AGENT_ICON = "AgentIcon";
} }
...@@ -9,10 +9,6 @@ public class AgentApplicationCreateContinueQuesDto implements Serializable { ...@@ -9,10 +9,6 @@ public class AgentApplicationCreateContinueQuesDto implements Serializable {
*/ */
private String input; private String input;
/**
* 应用ID
*/
private String agentId;
public String getInput() { public String getInput() {
return input; return input;
...@@ -22,11 +18,4 @@ public class AgentApplicationCreateContinueQuesDto implements Serializable { ...@@ -22,11 +18,4 @@ public class AgentApplicationCreateContinueQuesDto implements Serializable {
this.input = input; this.input = input;
} }
public String getAgentId() {
return agentId;
}
public void setAgentId(String agentId) {
this.agentId = agentId;
}
} }
...@@ -16,9 +16,8 @@ public interface AgentApplicationService { ...@@ -16,9 +16,8 @@ public interface AgentApplicationService {
* 追问AI生成 * 追问AI生成
* *
* @param input 问题输入 * @param input 问题输入
* @param agentId 应用id
* @return * @return
*/ */
List<String> createContinueQuestions(String input, String agentId); List<String> createContinueQuestions(String input);
} }
...@@ -108,7 +108,7 @@ public class AgentApplicationServiceImpl implements AgentApplicationService { ...@@ -108,7 +108,7 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
} }
@Override @Override
public List<String> createContinueQuestions(String input, String agentId) { public List<String> createContinueQuestions(String input) {
BizAgentApplicationGcConfigEntity configEntity = bizAgentApplicationGcConfigService.getByConfigCode(AgentApplicationGCConfigConstants.AGENT_CONTINUE_QUESTIONS); BizAgentApplicationGcConfigEntity configEntity = bizAgentApplicationGcConfigService.getByConfigCode(AgentApplicationGCConfigConstants.AGENT_CONTINUE_QUESTIONS);
if (null == configEntity) { if (null == configEntity) {
throw new BusinessException("创建[开场白]配置不存在"); throw new BusinessException("创建[开场白]配置不存在");
......
...@@ -70,8 +70,7 @@ public class AgentApplicationRestImpl implements AgentApplicationRest { ...@@ -70,8 +70,7 @@ public class AgentApplicationRestImpl implements AgentApplicationRest {
@Override @Override
public List<String> createContinueQuestions(AgentApplicationCreateContinueQuesDto dto) throws Exception { 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.getInput(), "input不能为空");
cn.com.poc.common.utils.Assert.notNull(dto.getAgentId(), "input不能为空"); return agentApplicationService.createContinueQuestions(dto.getInput());
return agentApplicationService.createContinueQuestions(dto.getInput(), dto.getAgentId());
} }
} }
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