Skip to content

Commit

Permalink
[feature][chat]Support creation of chat memory via REST API.#1603
Browse files Browse the repository at this point in the history
  • Loading branch information
jerryjzhang committed Oct 12, 2024
1 parent aebb6b7 commit 551c9e6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ 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());
ChatApp.builder().prompt(REWRITE_MULTI_TURN_INSTRUCTION).name("多轮对话改写")
.description("通过大模型根据历史对话来改写本轮对话").enable(false).build());

ChatAppManager.register(APP_KEY_ERROR_MESSAGE,
ChatApp.builder().prompt(REWRITE_ERROR_MESSAGE_INSTRUCTION)
.name("异常提示改写").description("通过大模型将异常信息改写为更友好和引导性的提示用语").enable(false).build());
ChatApp.builder().prompt(REWRITE_ERROR_MESSAGE_INSTRUCTION).name("异常提示改写")
.description("通过大模型将异常信息改写为更友好和引导性的提示用语").enable(false).build());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,13 @@ public class MemoryController {

@PostMapping("/createMemory")
public Boolean createMemory(@RequestBody ChatMemoryCreateReq chatMemoryCreateReq,
HttpServletRequest request, HttpServletResponse response) {
HttpServletRequest request, HttpServletResponse response) {
User user = UserHolder.findUser(request, response);
memoryService.createMemory(ChatMemoryDO.builder()
.agentId(chatMemoryCreateReq.getAgentId())
.s2sql(chatMemoryCreateReq.getS2sql())
.question(chatMemoryCreateReq.getQuestion())
.dbSchema(chatMemoryCreateReq.getDbSchema())
.status(chatMemoryCreateReq.getStatus())
.humanReviewRet(MemoryReviewResult.POSITIVE)
.createdBy(user.getName())
.createdAt(new Date())
.build());
memoryService.createMemory(ChatMemoryDO.builder().agentId(chatMemoryCreateReq.getAgentId())
.s2sql(chatMemoryCreateReq.getS2sql()).question(chatMemoryCreateReq.getQuestion())
.dbSchema(chatMemoryCreateReq.getDbSchema()).status(chatMemoryCreateReq.getStatus())
.humanReviewRet(MemoryReviewResult.POSITIVE).createdBy(user.getName())
.createdAt(new Date()).build());
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ private ParseContext buildParseContext(ChatParseReq chatParseReq) {
ParseContext parseContext = new ParseContext();
BeanMapper.mapper(chatParseReq, parseContext);
Agent agent = agentService.getAgent(chatParseReq.getAgentId());
agent.getChatAppConfig().values().forEach(c -> c.setChatModelConfig(
chatModelService.getChatModel(c.getChatModelId()).getConfig()));
agent.getChatAppConfig().values().forEach(c -> c
.setChatModelConfig(chatModelService.getChatModel(c.getChatModelId()).getConfig()));
parseContext.setAgent(agent);
return parseContext;
}
Expand Down

0 comments on commit 551c9e6

Please sign in to comment.