[improvement][chat]Sort parses in NL2SQLParser right after rule-based parsing.

This commit is contained in:
jerryjzhang
2024-10-29 23:31:02 +08:00
parent 847505b293
commit 53ddc67262
12 changed files with 23 additions and 59 deletions

View File

@@ -104,6 +104,7 @@ public class NL2SQLParser implements ChatQueryParser {
.collect(Collectors.toList());
parseContext.getResponse().getSelectedParses().addAll(sortedParses);
}
SemanticParseInfo.sort(parseContext.getResponse().getSelectedParses());
}
// next go with llm-based parsers unless LLM is disabled or use feedback is needed.

View File

@@ -1,26 +0,0 @@
package com.tencent.supersonic.chat.server.processor.parse;
import com.tencent.supersonic.chat.server.pojo.ParseContext;
import com.tencent.supersonic.headless.api.pojo.SemanticParseInfo;
import lombok.extern.slf4j.Slf4j;
import java.util.*;
/**
* ParseInfoSortProcessor sorts candidate parse info based on certain algorithm. \
**/
@Slf4j
public class ParseInfoSortProcessor implements ParseResultProcessor {
@Override
public void process(ParseContext parseContext) {
List<SemanticParseInfo> selectedParses = parseContext.getResponse().getSelectedParses();
selectedParses.sort(new SemanticParseInfo.SemanticParseComparator());
// re-assign parseId
for (int i = 0; i < selectedParses.size(); i++) {
SemanticParseInfo parseInfo = selectedParses.get(i);
parseInfo.setId(i + 1);
}
}
}