mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-29 05:18:05 +08:00
[improvement][chat]Sort parses in NL2SQLParser right after rule-based parsing.
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user