mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-11 12:07:42 +00:00
(improvement)(chat) The embedding model will be uniformly adopted using the textSegment and will be compatible with the queryId parameter. (#1202)
This commit is contained in:
@@ -1,18 +1,19 @@
|
||||
package dev.langchain4j.inmemory.spring;
|
||||
|
||||
import dev.langchain4j.store.embedding.EmbeddingQuery;
|
||||
import dev.langchain4j.data.segment.TextSegment;
|
||||
import dev.langchain4j.store.embedding.EmbeddingStore;
|
||||
import dev.langchain4j.store.embedding.EmbeddingStoreFactory;
|
||||
import dev.langchain4j.store.embedding.inmemory.InMemoryEmbeddingStore;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class InMemoryEmbeddingStoreFactory implements EmbeddingStoreFactory {
|
||||
|
||||
private static Map<String, InMemoryEmbeddingStore<EmbeddingQuery>> collectionNameToStore =
|
||||
private static Map<String, InMemoryEmbeddingStore<TextSegment>> collectionNameToStore =
|
||||
new ConcurrentHashMap<>();
|
||||
private Properties properties;
|
||||
|
||||
@@ -23,14 +24,12 @@ public class InMemoryEmbeddingStoreFactory implements EmbeddingStoreFactory {
|
||||
|
||||
@Override
|
||||
public synchronized EmbeddingStore create(String collectionName) {
|
||||
InMemoryEmbeddingStore<EmbeddingQuery> embeddingStore = collectionNameToStore.get(collectionName);
|
||||
InMemoryEmbeddingStore<TextSegment> embeddingStore = collectionNameToStore.get(collectionName);
|
||||
if (Objects.nonNull(embeddingStore)) {
|
||||
return embeddingStore;
|
||||
}
|
||||
if (Objects.isNull(embeddingStore)) {
|
||||
embeddingStore = new InMemoryEmbeddingStore();
|
||||
collectionNameToStore.putIfAbsent(collectionName, embeddingStore);
|
||||
}
|
||||
embeddingStore = new InMemoryEmbeddingStore();
|
||||
collectionNameToStore.putIfAbsent(collectionName, embeddingStore);
|
||||
return embeddingStore;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user