mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-14 22:25:19 +00:00
[improvement](headless) Optimize the reload embedding interface (#1655)
This commit is contained in:
@@ -12,4 +12,6 @@ public interface ExemplarService {
|
||||
List<Text2SQLExemplar> recallExemplars(String collection, String query, int num);
|
||||
|
||||
List<Text2SQLExemplar> recallExemplars(String query, int num);
|
||||
|
||||
void loadSysExemplars();
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ import org.springframework.core.annotation.Order;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
|
||||
@@ -88,18 +87,18 @@ public class ExemplarServiceImpl implements ExemplarService, CommandLineRunner {
|
||||
|
||||
@Override
|
||||
public void run(String... args) {
|
||||
loadSysExemplars();
|
||||
}
|
||||
|
||||
public void loadSysExemplars() {
|
||||
try {
|
||||
loadSysExemplars();
|
||||
ClassPathResource resource = new ClassPathResource(SYS_EXEMPLAR_FILE);
|
||||
InputStream inputStream = resource.getInputStream();
|
||||
List<Text2SQLExemplar> exemplars = objectMapper.readValue(inputStream, valueTypeRef);
|
||||
String collection = embeddingConfig.getText2sqlCollectionName();
|
||||
exemplars.stream().forEach(e -> storeExemplar(collection, e));
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to load system exemplars", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadSysExemplars() throws IOException {
|
||||
ClassPathResource resource = new ClassPathResource(SYS_EXEMPLAR_FILE);
|
||||
InputStream inputStream = resource.getInputStream();
|
||||
List<Text2SQLExemplar> exemplars = objectMapper.readValue(inputStream, valueTypeRef);
|
||||
String collection = embeddingConfig.getText2sqlCollectionName();
|
||||
exemplars.stream().forEach(e -> storeExemplar(collection, e));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user