(fix)(common)fix duplication when adding data to the vector library (#1433)

This commit is contained in:
SuperLiChaoRen
2024-07-20 10:02:29 +08:00
committed by GitHub
parent ef44954e1e
commit b319f4682a

View File

@@ -59,6 +59,7 @@ public class EmbeddingServiceImpl implements EmbeddingService {
continue;
}
embeddingStore.add(embedding, query);
cache.put(TextSegmentConvert.getQueryId(query), true);
} catch (Exception e) {
log.error("embeddingModel embed error question: {}, embeddingStore: {}", question,
embeddingStore.getClass().getSimpleName(), e);
@@ -85,7 +86,6 @@ public class EmbeddingServiceImpl implements EmbeddingService {
EmbeddingSearchResult result = embeddingStore.search(request);
List<EmbeddingMatch<TextSegment>> relevant = result.matches();
boolean exists = CollectionUtils.isNotEmpty(relevant);
cache.put(queryId, exists);
return exists;
}