mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-14 05:43:51 +00:00
[improvement](chat) Unified vector-related interfaces to go through EmbeddingUtils. (#476)
This commit is contained in:
@@ -14,22 +14,21 @@ public class EmbeddingConfig {
|
||||
@Value("${embedding.recognize.path:/preset_query_retrival}")
|
||||
private String recognizePath;
|
||||
|
||||
@Value("${embedding.delete.path:/preset_delete_by_ids}")
|
||||
private String deletePath;
|
||||
|
||||
@Value("${embedding.add.path:/preset_query_add}")
|
||||
private String addPath;
|
||||
@Value("${embedding.preset.collection:preset_query_collection}")
|
||||
private String presetCollection;
|
||||
|
||||
@Value("${embedding.nResult:1}")
|
||||
private String nResult;
|
||||
private int nResult;
|
||||
|
||||
@Value("${embedding.solvedQuery.recall.path:/solved_query_retrival}")
|
||||
private String solvedQueryRecallPath;
|
||||
|
||||
@Value("${embedding.solvedQuery.add.path:/solved_query_add}")
|
||||
private String solvedQueryAddPath;
|
||||
@Value("${embedding.solved.query.collection:solved_query_collection}")
|
||||
private String solvedQueryCollection;
|
||||
|
||||
@Value("${embedding.solved.query.nResult:5}")
|
||||
private String solvedQueryResultNum;
|
||||
private int solvedQueryResultNum;
|
||||
|
||||
@Value("${embedding.metric.analyzeQuery.collection:solved_query_collection}")
|
||||
private String metricAnalyzeQueryCollection;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class EmbeddingUtils {
|
||||
return embeddingCollections.stream().map(EmbeddingCollection::getName).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private ResponseEntity doRequest(String url, String jsonBody, HttpMethod httpMethod) {
|
||||
public ResponseEntity doRequest(String url, String jsonBody, HttpMethod httpMethod) {
|
||||
try {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
@@ -94,11 +94,12 @@ public class EmbeddingUtils {
|
||||
entity = new HttpEntity<>(jsonBody, headers);
|
||||
}
|
||||
ResponseEntity<String> responseEntity = restTemplate.exchange(requestUrl,
|
||||
httpMethod, entity, new ParameterizedTypeReference<String>() {});
|
||||
httpMethod, entity, new ParameterizedTypeReference<String>() {
|
||||
});
|
||||
log.info("[embedding] url :{} result body:{}", url, responseEntity);
|
||||
return responseEntity;
|
||||
} catch (Throwable e) {
|
||||
log.warn("connect to embedding service failed, url:{}", url);
|
||||
log.warn("doRequest service failed, url:" + url, e);
|
||||
}
|
||||
return ResponseEntity.of(Optional.empty());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user