[improvement][chat]Rename SemanticLayer to SemanticInterpreter

This commit is contained in:
jerryjzhang
2023-10-08 09:30:10 +08:00
parent 99ac17a5e4
commit b565b9c4e5
27 changed files with 86 additions and 86 deletions

View File

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

View File

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

View File

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

View File

@@ -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() {

View File

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

View File

@@ -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) {