Skip to content

Commit

Permalink
[improvement][chat] Optimize the MemoryReviewTask task by adding indi…
Browse files Browse the repository at this point in the history
…vidual exception handling (#1788)
  • Loading branch information
lexluo09 authored Oct 11, 2024
1 parent 0a86a63 commit 72d01bb
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,14 @@ public class MemoryReviewTask {

@Scheduled(fixedDelay = 60 * 1000)
public void review() {
try {
memoryService.getMemoriesForLlmReview().stream().forEach(this::processMemory);
} catch (Exception e) {
log.error("Exception occurred during memory review task", e);
}
memoryService.getMemoriesForLlmReview().stream().forEach(memory -> {
try {
processMemory(memory);
} catch (Exception e) {
log.error("Exception occurred while processing memory with id {}: {}",
memory.getId(), e.getMessage(), e);
}
});
}

private void processMemory(ChatMemoryDO m) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ private void executeAgentExamplesAsync(Agent agent) {
}

private synchronized void doExecuteAgentExamples(Agent agent) {
if (!agent.containsDatasetTool()
|| !agent.enableMemoryReview()
if (!agent.containsDatasetTool() || !agent.enableMemoryReview()
|| !ModelConfigHelper.testConnection(
ModelConfigHelper.getChatModelConfig(agent, ChatModelType.TEXT_TO_SQL))
|| CollectionUtils.isEmpty(agent.getExamples())) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.tencent.supersonic.headless.api.pojo;

import java.util.List;
import lombok.Data;

import java.util.List;

@Data
public class ModelSchema {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ public void doCorrect(ChatQueryContext chatQueryContext, SemanticParseInfo seman
return;
}

ChatLanguageModel chatLanguageModel = ModelProvider.getChatModel(chatQueryContext.getModelConfig());
ChatLanguageModel chatLanguageModel =
ModelProvider.getChatModel(chatQueryContext.getModelConfig());
SemanticSqlExtractor extractor =
AiServices.create(SemanticSqlExtractor.class, chatLanguageModel);
Prompt prompt = generatePrompt(chatQueryContext.getQueryText(), semanticParseInfo);
Expand Down

0 comments on commit 72d01bb

Please sign in to comment.