Commit f1f5ed94 authored by Roger Wu's avatar Roger Wu

编辑器需求

parent a090f157
......@@ -4,6 +4,7 @@ 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.request.ArticleRewriteRequest;
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;
......@@ -141,4 +142,17 @@ public interface AgentApplicationService {
* @param memberId 用户id
*/
boolean hasPublishAgentPermission(String agentId, Long memberId);
/**
* 编辑器编辑功能
* @param agentGcConfigCode
* @param articleContent
* @param editorRequired
* @param httpServletResponse
* @return
* @throws Exception
*/
String editorFunction(String agentGcConfigCode, String articleContent, String editorRequired, HttpServletResponse httpServletResponse) throws Exception;
}
package cn.com.poc.agent_application.aggregate.impl;
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;
import cn.com.poc.agent_application.constant.AgentApplicationKnowledgeConstants;
import cn.com.poc.agent_application.constant.*;
import cn.com.poc.agent_application.domain.FunctionResult;
import cn.com.poc.agent_application.entity.*;
import cn.com.poc.agent_application.query.DialogsIdsQueryByAgentIdQueryItem;
......@@ -543,6 +540,54 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
return false;
}
/**
* 编辑器编辑功能
*
* @param agentGcConfigCode
* @param articleContent
* @param editorRequired
* @param httpServletResponse
* @return
* @throws Exception
*/
@Override
public String editorFunction(String agentGcConfigCode, String articleContent, String editorRequired, HttpServletResponse httpServletResponse) throws Exception {
if (StringUtils.isBlank(agentGcConfigCode)) {
throw new I18nMessageException("exception/agentGcConfigCode.does.not.exist");
}
BizAgentApplicationGcConfigEntity configEntity = bizAgentApplicationGcConfigService.getByConfigCode(agentGcConfigCode);
if (null == configEntity || StringUtils.isBlank(configEntity.getConfigSystem())) {
throw new I18nMessageException("exception/create.[opening.statement].configuration.does.not.exist");
}
String configSystem = configEntity.getConfigSystem();
if (StringUtils.isNotBlank(configSystem)) {
configSystem = configSystem.replace("{" + AiGcTemplateConstant.ContentPlaceholder.EXAMPLE + "1}", articleContent);
configSystem = configSystem.replace("{" + AiGcTemplateConstant.ContentPlaceholder.EXAMPLE + "2}", editorRequired);
}
Message message = new Message();
message.setContent(configSystem);
message.setRole(LLMRoleEnum.USER.getRole());
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-PREAMBLE");
BufferedReader bufferedReader = llmService.chatChunk(largeModelResponse);
SSEUtil sseUtil = new SSEUtil(httpServletResponse);
textOutputStream(sseUtil, bufferedReader);
return null;
}
/**
* 执行LLM,并输出结果
*
......
......@@ -17,5 +17,30 @@ public interface AgentApplicationGCConfigConstants {
String AGENT_BASE_SYSTEM = "AgentBaseSystem";
/**
* 编辑器 语气
*/
String EDITOR_ARTICLE_MODIFY_TONE = "EditorArticleModifyTone";
/**
* 编辑器文章润色
*/
String EDITOR_ARTICLE_POLISH = "EditorArticlePolish";
/**
* 编辑器文章扩写
*/
String EDITOR_ARTICLE_EXPAND = "EditorArticleExpand";
/**
* 编辑器文章简写
*/
String EDITOR_ARTICLE_REFINE = "EditorArticleRefine";
/**
* 编辑器文章改写
*/
String EDITOR_ARTICLERE_WRITE = "EditorArticleRewrite";
}
package cn.com.poc.agent_application.constant;
public interface AiGcTemplateConstant {
/**
* AI内容模板占位符
*/
interface ContentPlaceholder {
/**
* 占位符名前缀
*/
String EXAMPLE = "example";
/**
* 完整占位符
*/
String EXAMPLE_PLACEHOLDER = "{example}";
}
}
package cn.com.poc.agent_application.request;
public class ArticleExpandRequest {
/**
* 文章内容
*/
private String articleContent;
public String getArticleContent() {
return articleContent;
}
public void setArticleContent(String articleContent) {
this.articleContent = articleContent;
}
/**
* 要求
*/
private String editorRequired;
public String getEditorRequired() {
return editorRequired;
}
public void setEditorRequired(String editorRequired) {
this.editorRequired = editorRequired;
}
}
package cn.com.poc.agent_application.request;
public class ArticleModificationRequest {
/**
* 文章内容
*/
private String articleContent;
/**
* 修改要求
*/
private String require;
public String getRequire() {
return require;
}
/**
* 要求
*/
private String editorRequired;
public String getEditorRequired() {
return editorRequired;
}
public void setEditorRequired(String editorRequired) {
this.editorRequired = editorRequired;
}
}
package cn.com.poc.agent_application.request;
public class ArticleModifyToneRequest {
/**
* 文章内容
*/
private String articleContent;
public String getArticleContent() {
return articleContent;
}
public void setArticleContent(String articleContent) {
this.articleContent = articleContent;
}
/**
* 要求
*/
private String editorRequired;
public String getEditorRequired() {
return editorRequired;
}
public void setEditorRequired(String editorRequired) {
this.editorRequired = editorRequired;
}
}
package cn.com.poc.agent_application.request;
/**
*
*/
public class ArticlePolishRequest {
/**
* 文章内容
*/
private String articleContent;
public String getArticleContent() {
return articleContent;
}
public void setArticleContent(String articleContent) {
this.articleContent = articleContent;
}
/**
* 要求
*/
private String editorRequired;
public String getEditorRequired() {
return editorRequired;
}
public void setEditorRequired(String editorRequired) {
this.editorRequired = editorRequired;
}
}
package cn.com.poc.agent_application.request;
/**
* @author Zackery
* @create 2023-12-26 10:26
*/
public class ArticleRefineRequest {
/**
* 文章内容
*/
private String articleContent;
public String getArticleContent() {
return articleContent;
}
public void setArticleContent(String articleContent) {
this.articleContent = articleContent;
}
/**
* 要求
*/
private String editorRequired;
public String getEditorRequired() {
return editorRequired;
}
public void setEditorRequired(String editorRequired) {
this.editorRequired = editorRequired;
}
}
package cn.com.poc.agent_application.request;
public class ArticleRewriteRequest {
/**
* 文章内容
*/
private String articleContent;
public String getArticleContent() {
return articleContent;
}
public void setArticleContent(String articleContent) {
this.articleContent = articleContent;
}
/**
* 要求
*/
private String editorRequired;
public String getEditorRequired() {
return editorRequired;
}
public void setEditorRequired(String editorRequired) {
this.editorRequired = editorRequired;
}
}
\ No newline at end of file
package cn.com.poc.agent_application.rest;
import cn.com.poc.agent_application.request.*;
import cn.com.yict.framemax.core.rest.BaseRest;
import cn.com.yict.framemax.web.permission.Access;
import cn.com.yict.framemax.web.permission.Permission;
import org.springframework.web.bind.annotation.RequestBody;
import javax.servlet.http.HttpServletResponse;
@Permission(value = Access.Safety)
public interface AiGcRest extends BaseRest {
void articlePolish(@RequestBody ArticlePolishRequest request, HttpServletResponse httpServletResponse) throws Exception;
void articleRefine(@RequestBody ArticleRefineRequest request, HttpServletResponse httpServletResponse) throws Exception;
void articleExpand(@RequestBody ArticleExpandRequest request, HttpServletResponse httpServletResponse) throws Exception;
void articleModifyTone(@RequestBody ArticleModifyToneRequest request, HttpServletResponse httpServletResponse) throws Exception;
void articleRewrite(@RequestBody ArticleRewriteRequest request, HttpServletResponse httpServletResponse) throws Exception;
}
\ No newline at end of file
package cn.com.poc.agent_application.rest.impl;
import cn.com.poc.agent_application.request.*;
import cn.com.poc.agent_application.rest.AiGcRest;
import cn.com.poc.agent_application.service.AiGcEditorService;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
@Component
public class AiGcRestImpl implements AiGcRest {
@Resource
private AiGcEditorService aiGcEditorService;
@Override
public void articlePolish(@RequestBody ArticlePolishRequest request, HttpServletResponse httpServletResponse) throws Exception{
aiGcEditorService.articlePolish(request, httpServletResponse);
}
@Override
public void articleRefine(@RequestBody ArticleRefineRequest request, HttpServletResponse httpServletResponse) throws Exception{
aiGcEditorService.articleRefine(request, httpServletResponse);
}
@Override
public void articleExpand(@RequestBody ArticleExpandRequest request, HttpServletResponse httpServletResponse) throws Exception{
aiGcEditorService.articleExpand(request, httpServletResponse);
}
@Override
public void articleModifyTone(@RequestBody ArticleModifyToneRequest request, HttpServletResponse httpServletResponse) throws Exception{
aiGcEditorService.articleModifyTone(request, httpServletResponse);
}
@Override
public void articleRewrite(@RequestBody ArticleRewriteRequest request, HttpServletResponse httpServletResponse) throws Exception{
aiGcEditorService.articleRewrite(request, httpServletResponse);
}
}
\ No newline at end of file
package cn.com.poc.agent_application.service;
import cn.com.poc.agent_application.request.*;
import cn.com.yict.framemax.core.service.BaseService;
import javax.servlet.http.HttpServletResponse;
/**
*
*/
public interface AiGcEditorService extends BaseService {
/**
* 文章润色
*
* @param request 请求参数
*/
void articlePolish(ArticlePolishRequest request, HttpServletResponse httpServletResponse) throws Exception;
/**
* 文章简写
*
* @param request 请求参数
*/
void articleRefine(ArticleRefineRequest request, HttpServletResponse httpServletResponse) throws Exception;
/**
* 文章扩写
*
* @param request 请求参数
*/
void articleExpand(ArticleExpandRequest request, HttpServletResponse httpServletResponse) throws Exception;
/**
* 更改语气
*
* @param request 请求参数
*/
void articleModifyTone(ArticleModifyToneRequest request, HttpServletResponse httpServletResponse) throws Exception;
/**
* 文章改写
*
* @param request 请求参数
*/
void articleRewrite(ArticleRewriteRequest request, HttpServletResponse httpServletResponse) throws Exception;
}
package cn.com.poc.agent_application.service.impl;
import cn.com.poc.agent_application.aggregate.AgentApplicationService;
import cn.com.poc.agent_application.constant.AgentApplicationGCConfigConstants;
import cn.com.poc.agent_application.request.*;
import cn.com.poc.agent_application.service.AiGcEditorService;
import cn.com.poc.common.utils.Assert;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
/**
*
*/
@Service
public class AiGcEditorServiceImpl implements AiGcEditorService {
@Resource
private AgentApplicationService agentApplicationService;
@Override
public void articlePolish(ArticlePolishRequest request, HttpServletResponse httpServletResponse) throws Exception {
Assert.notNull(request, "param is not null");
String articleContent = request.getArticleContent();
String editorRequired = request.getEditorRequired();
Assert.notBlank(articleContent, "请选择需要润色的文字");
agentApplicationService.editorFunction(AgentApplicationGCConfigConstants.EDITOR_ARTICLE_POLISH, articleContent, editorRequired, httpServletResponse);
}
@Override
public void articleRefine(ArticleRefineRequest request, HttpServletResponse httpServletResponse) throws Exception {
Assert.notNull(request, "param is not null");
String articleContent = request.getArticleContent();
String editorRequired = request.getEditorRequired();
Assert.notBlank(articleContent, "请选择需要简写的文字");
//调用提问
agentApplicationService.editorFunction(AgentApplicationGCConfigConstants.EDITOR_ARTICLE_REFINE, articleContent, editorRequired, httpServletResponse);
}
@Override
public void articleExpand(ArticleExpandRequest request, HttpServletResponse httpServletResponse) throws Exception {
Assert.notNull(request, "param is not null");
String articleContent = request.getArticleContent();
String editorRequired = request.getEditorRequired();
Assert.notBlank(articleContent, "请选择需要扩写的文字");
//调用提问
agentApplicationService.editorFunction(AgentApplicationGCConfigConstants.EDITOR_ARTICLE_EXPAND, articleContent, editorRequired, httpServletResponse);
}
@Override
public void articleRewrite(ArticleRewriteRequest request, HttpServletResponse httpServletResponse) throws Exception {
Assert.notNull(request, "param is not null");
String articleContent = request.getArticleContent();
String editorRequired = request.getEditorRequired();
Assert.notBlank(articleContent, "请选择需要改写的文字");
//调用提问
agentApplicationService.editorFunction(AgentApplicationGCConfigConstants.EDITOR_ARTICLERE_WRITE, articleContent, editorRequired, httpServletResponse);
}
@Override
public void articleModifyTone(ArticleModifyToneRequest request, HttpServletResponse httpServletResponse) throws Exception {
Assert.notNull(request, "param is not null");
String articleContent = request.getArticleContent();
String editorRequired = request.getEditorRequired();
Assert.notBlank(articleContent, "请选择需要修改的文字");
//调用提问
agentApplicationService.editorFunction(AgentApplicationGCConfigConstants.EDITOR_ARTICLE_MODIFY_TONE, articleContent, editorRequired, httpServletResponse);
}
}
......@@ -85,4 +85,5 @@ qa.knowledge.document.struct.not.consistent=Inconsistent question and answer str
file.rows.more.than.1500=The document exceeds 1500 lines
file.columns.more.than.10=The document exceeds 10 columns
file.cell.content.more.than.850=Cell exceeds 850 characters
file.rows.content.more.than.3000=The document line exceeds 3000 characters
\ No newline at end of file
file.rows.content.more.than.3000=The document line exceeds 3000 characters
exception/agentGcConfigCode.does.not.exist= The agentGcConfigCode no Exist
\ No newline at end of file
......@@ -85,4 +85,5 @@ qa.knowledge.document.struct.not.consistent=文档结构不一致
file.rows.more.than.1500=文档超出1500行
file.columns.more.than.10=文档超出10列
file.cell.content.more.than.850=单元格超出850字符数
file.rows.content.more.than.3000=文档行超出3000字符数
\ No newline at end of file
file.rows.content.more.than.3000=文档行超出3000字符数
exception/agentGcConfigCode.does.not.exist= agentGcConfigCode 不能为空
\ No newline at end of file
......@@ -85,4 +85,5 @@ qa.knowledge.document.struct.not.consistent=文檔結構不一致
file.rows.more.than.1500=文檔超出1500行
file.columns.more.than.10=文檔超出10列
file.cell.content.more.than.850=單元格超出850字符數
file.rows.content.more.than.3000=文檔超出3000字符數
\ No newline at end of file
file.rows.content.more.than.3000=文檔超出3000字符數
exception/agentGcConfigCode.does.not.exist= agentGcConfigCode不能爲空
\ No newline at end of file
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