[improvement](chat) Unified vector-related interfaces to go through EmbeddingUtils. (#476)

This commit is contained in:
lexluo09
2023-12-06 14:50:57 +08:00
committed by GitHub
parent 9aa5c93d9d
commit ed0f856438
9 changed files with 168 additions and 208 deletions

View File

@@ -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;
}

View File

@@ -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());
}