mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-12 20:51:48 +00:00
[improvement][chat]Rename SemanticLayer to SemanticInterpreter
This commit is contained in:
@@ -2,7 +2,7 @@ package com.tencent.supersonic.knowledge.semantic;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.tencent.supersonic.chat.api.component.SemanticLayer;
|
||||
import com.tencent.supersonic.chat.api.component.SemanticInterpreter;
|
||||
import com.tencent.supersonic.chat.api.pojo.ModelSchema;
|
||||
import com.tencent.supersonic.semantic.api.model.response.ModelSchemaResp;
|
||||
import java.util.ArrayList;
|
||||
@@ -14,7 +14,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
@Slf4j
|
||||
public abstract class BaseSemanticLayer implements SemanticLayer {
|
||||
public abstract class BaseSemanticInterpreter implements SemanticInterpreter {
|
||||
|
||||
protected final Cache<String, List<ModelSchemaResp>> modelSchemaCache =
|
||||
CacheBuilder.newBuilder().expireAfterWrite(10, TimeUnit.SECONDS).build();
|
||||
@@ -29,7 +29,7 @@ import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class LocalSemanticLayer extends BaseSemanticLayer {
|
||||
public class LocalSemanticInterpreter extends BaseSemanticInterpreter {
|
||||
|
||||
private SchemaService schemaService;
|
||||
private DimensionService dimensionService;
|
||||
@@ -52,7 +52,7 @@ import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
@Slf4j
|
||||
public class RemoteSemanticLayer extends BaseSemanticLayer {
|
||||
public class RemoteSemanticInterpreter extends BaseSemanticInterpreter {
|
||||
|
||||
private S2ThreadContext s2ThreadContext;
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.tencent.supersonic.knowledge.service;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.tencent.supersonic.chat.api.component.SemanticLayer;
|
||||
import com.tencent.supersonic.chat.api.component.SemanticInterpreter;
|
||||
import com.tencent.supersonic.chat.api.pojo.ModelSchema;
|
||||
import com.tencent.supersonic.chat.api.pojo.SemanticSchema;
|
||||
import com.tencent.supersonic.knowledge.utils.ComponentFactory;
|
||||
@@ -19,7 +19,7 @@ public class SchemaService {
|
||||
|
||||
public static final String ALL_CACHE = "all";
|
||||
private static final Integer META_CACHE_TIME = 2;
|
||||
private SemanticLayer semanticLayer = ComponentFactory.getSemanticLayer();
|
||||
private SemanticInterpreter semanticInterpreter = ComponentFactory.getSemanticLayer();
|
||||
|
||||
private LoadingCache<String, SemanticSchema> cache = CacheBuilder.newBuilder()
|
||||
.expireAfterWrite(META_CACHE_TIME, TimeUnit.MINUTES)
|
||||
@@ -28,13 +28,13 @@ public class SchemaService {
|
||||
@Override
|
||||
public SemanticSchema load(String key) {
|
||||
log.info("load getDomainSchemaInfo cache [{}]", key);
|
||||
return new SemanticSchema(semanticLayer.getModelSchema());
|
||||
return new SemanticSchema(semanticInterpreter.getModelSchema());
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
public ModelSchema getModelSchema(Long id) {
|
||||
return semanticLayer.getModelSchema(id, true);
|
||||
return semanticInterpreter.getModelSchema(id, true);
|
||||
}
|
||||
|
||||
public SemanticSchema getSemanticSchema() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.tencent.supersonic.knowledge.service;
|
||||
|
||||
import com.tencent.supersonic.chat.api.component.SemanticLayer;
|
||||
import com.tencent.supersonic.chat.api.component.SemanticInterpreter;
|
||||
import com.tencent.supersonic.chat.api.pojo.SchemaElement;
|
||||
import com.tencent.supersonic.chat.api.pojo.SemanticSchema;
|
||||
import com.tencent.supersonic.knowledge.dictionary.DictWord;
|
||||
@@ -22,8 +22,8 @@ public class WordService {
|
||||
private List<DictWord> preDictWords = new ArrayList<>();
|
||||
|
||||
public List<DictWord> getAllDictWords() {
|
||||
SemanticLayer semanticLayer = ComponentFactory.getSemanticLayer();
|
||||
SemanticSchema semanticSchema = new SemanticSchema(semanticLayer.getModelSchema());
|
||||
SemanticInterpreter semanticInterpreter = ComponentFactory.getSemanticLayer();
|
||||
SemanticSchema semanticSchema = new SemanticSchema(semanticInterpreter.getModelSchema());
|
||||
|
||||
List<DictWord> words = new ArrayList<>();
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.tencent.supersonic.knowledge.utils;
|
||||
|
||||
import com.tencent.supersonic.chat.api.component.SemanticLayer;
|
||||
import com.tencent.supersonic.chat.api.component.SemanticInterpreter;
|
||||
import org.springframework.core.io.support.SpringFactoriesLoader;
|
||||
|
||||
import java.util.List;
|
||||
@@ -8,17 +8,17 @@ import java.util.Objects;
|
||||
|
||||
public class ComponentFactory {
|
||||
|
||||
private static SemanticLayer semanticLayer;
|
||||
private static SemanticInterpreter semanticInterpreter;
|
||||
|
||||
public static SemanticLayer getSemanticLayer() {
|
||||
if (Objects.isNull(semanticLayer)) {
|
||||
semanticLayer = init(SemanticLayer.class);
|
||||
public static SemanticInterpreter getSemanticLayer() {
|
||||
if (Objects.isNull(semanticInterpreter)) {
|
||||
semanticInterpreter = init(SemanticInterpreter.class);
|
||||
}
|
||||
return semanticLayer;
|
||||
return semanticInterpreter;
|
||||
}
|
||||
|
||||
public static void setSemanticLayer(SemanticLayer layer) {
|
||||
semanticLayer = layer;
|
||||
public static void setSemanticLayer(SemanticInterpreter layer) {
|
||||
semanticInterpreter = layer;
|
||||
}
|
||||
|
||||
private static <T> List<T> init(Class<T> factoryType, List list) {
|
||||
|
||||
Reference in New Issue
Block a user