[improvement][chat]Introduce AppModule to classify chat apps.

This commit is contained in:
jerryjzhang
2024-10-14 14:21:41 +08:00
parent 6a28a49d31
commit 0b71390fde
13 changed files with 50 additions and 19 deletions

View File

@@ -7,6 +7,7 @@ import com.tencent.supersonic.chat.server.pojo.ExecuteContext;
import com.tencent.supersonic.chat.server.service.AgentService;
import com.tencent.supersonic.chat.server.service.ChatManageService;
import com.tencent.supersonic.common.pojo.ChatApp;
import com.tencent.supersonic.common.pojo.enums.AppModule;
import com.tencent.supersonic.common.util.ChatAppManager;
import com.tencent.supersonic.common.util.ContextUtils;
import com.tencent.supersonic.headless.api.pojo.response.QueryState;
@@ -32,7 +33,7 @@ public class PlainTextExecutor implements ChatQueryExecutor {
public PlainTextExecutor() {
ChatAppManager.register(APP_KEY, ChatApp.builder().prompt(INSTRUCTION).name("闲聊对话")
.description("直接将原始输入透传大模型").enable(false).build());
.appModule(AppModule.CHAT).description("直接将原始输入透传大模型").enable(false).build());
}
@Override

View File

@@ -7,6 +7,7 @@ import com.tencent.supersonic.chat.server.service.AgentService;
import com.tencent.supersonic.chat.server.service.MemoryService;
import com.tencent.supersonic.chat.server.util.ModelConfigHelper;
import com.tencent.supersonic.common.pojo.ChatApp;
import com.tencent.supersonic.common.pojo.enums.AppModule;
import com.tencent.supersonic.common.util.ChatAppManager;
import dev.langchain4j.model.chat.ChatLanguageModel;
import dev.langchain4j.model.input.Prompt;
@@ -49,8 +50,9 @@ public class MemoryReviewTask {
private AgentService agentService;
public MemoryReviewTask() {
ChatAppManager.register(APP_KEY, ChatApp.builder().prompt(INSTRUCTION).name("记忆启用评估")
.description("通过大模型对记忆做正确性评估以决定是否启用").enable(false).build());
ChatAppManager.register(APP_KEY,
ChatApp.builder().prompt(INSTRUCTION).name("记忆启用评估").appModule(AppModule.CHAT)
.description("通过大模型对记忆做正确性评估以决定是否启用").enable(false).build());
}
@Scheduled(fixedDelay = 60 * 1000)

View File

@@ -11,6 +11,7 @@ import com.tencent.supersonic.chat.server.util.QueryReqConverter;
import com.tencent.supersonic.common.config.EmbeddingConfig;
import com.tencent.supersonic.common.pojo.ChatApp;
import com.tencent.supersonic.common.pojo.Text2SQLExemplar;
import com.tencent.supersonic.common.pojo.enums.AppModule;
import com.tencent.supersonic.common.service.impl.ExemplarServiceImpl;
import com.tencent.supersonic.common.util.ChatAppManager;
import com.tencent.supersonic.common.util.ContextUtils;
@@ -79,11 +80,13 @@ public class NL2SQLParser implements ChatQueryParser {
public NL2SQLParser() {
ChatAppManager.register(APP_KEY_MULTI_TURN,
ChatApp.builder().prompt(REWRITE_MULTI_TURN_INSTRUCTION).name("多轮对话改写")
.description("通过大模型根据历史对话来改写本轮对话").enable(false).build());
.appModule(AppModule.CHAT).description("通过大模型根据历史对话来改写本轮对话").enable(false)
.build());
ChatAppManager.register(APP_KEY_ERROR_MESSAGE,
ChatApp.builder().prompt(REWRITE_ERROR_MESSAGE_INSTRUCTION).name("异常提示改写")
.description("通过大模型将异常信息改写为更友好和引导性的提示用语").enable(false).build());
.appModule(AppModule.CHAT).description("通过大模型将异常信息改写为更友好和引导性的提示用语")
.enable(false).build());
}
@Override

View File

@@ -12,6 +12,7 @@ import com.tencent.supersonic.chat.server.util.ModelConfigHelper;
import com.tencent.supersonic.common.pojo.ChatApp;
import com.tencent.supersonic.common.pojo.ChatModelConfig;
import com.tencent.supersonic.common.pojo.Parameter;
import com.tencent.supersonic.common.pojo.enums.AppModule;
import com.tencent.supersonic.common.util.ChatAppManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -52,7 +53,7 @@ public class ChatModelController {
@RequestMapping("/getModelAppList")
public Map<String, ChatApp> getChatAppList() {
return ChatAppManager.getAllApps();
return ChatAppManager.getAllApps(AppModule.CHAT);
}
@RequestMapping("/getModelParameters")