(fix)(chat) 修复做embedding检索时,出现重复数据的问题 (#1643)

This commit is contained in:
yudong
2024-09-11 22:07:23 +08:00
committed by GitHub
parent 989ae3c128
commit 51e7a9bcd7

View File

@@ -59,6 +59,7 @@ public class EmbeddingServiceImpl implements EmbeddingService {
continue; continue;
} }
embeddingStore.add(embedding, query); embeddingStore.add(embedding, query);
cache.put(TextSegmentConvert.getQueryId(query), true);
} catch (Exception e) { } catch (Exception e) {
log.error( log.error(
"embeddingModel embed error question: {}, embeddingStore: {}", "embeddingModel embed error question: {}, embeddingStore: {}",
@@ -117,6 +118,9 @@ public class EmbeddingServiceImpl implements EmbeddingService {
new MetadataFilterBuilder(TextSegmentConvert.QUERY_ID); new MetadataFilterBuilder(TextSegmentConvert.QUERY_ID);
Filter filter = filterBuilder.isIn(queryIds); Filter filter = filterBuilder.isIn(queryIds);
inMemoryEmbeddingStore.removeAll(filter); inMemoryEmbeddingStore.removeAll(filter);
for (String queryId : queryIds) {
cache.put(queryId, false);
}
} }
} else { } else {
throw new RuntimeException("Not supported yet."); throw new RuntimeException("Not supported yet.");