Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -486,9 +486,9 @@ Closes #123"
- 5、支持将智能问数项目对外提供OpenAPI的服务;
- 6、支持将智能问数项目对外提供MCP的服务;
- 7、支持seed命令可以将CSV文件初始化加载入数据库;
- 8、基于LLM的数据探查辅助生成语义模型;(TODO)
- 9、数据模型、语义模型、智能问数的单元测试;(TODO)
- 10、SQL问答对、同义词、业务知识等向量化入库与检索;(TODO)
- 8、SQL问答对、同义词、业务知识等向量化入库与检索;
- 9、基于LLM的数据探查辅助生成语义模型;(TODO)
- 10、数据模型、语义模型、智能问数的单元测试;(TODO)
- 11、指标的配置(构建语义模型后可以更进一步添加指标);(TODO)


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
examples:
knowledge:
- |
COVID-19(新型冠状病毒肺炎)是由SARS-CoV-2病毒引起的呼吸道传染病。
主要传播途径为飞沫和密切接触,在相对封闭的环境中可经气溶胶传播。
典型症状包括发热、干咳、乏力等,部分患者可能丧失嗅觉或味觉。值得注意的是,许多感染者症状轻微甚至无症状,但仍具有传染性。
预防措施至关重要:接种疫苗、在人员密集场所佩戴口罩、勤洗手、多通风。若出现症状,应及时进行检测并自我隔离,保护他人。
虽然大多数患者可康复,但对老年人和有基础疾病者威胁较大,仍需保持警惕。
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
examples:
knowledge:
- |
COVID 预防是关键:
接种疫苗:有效降低重症和死亡风险。
良好卫生:勤洗手、戴口罩、常通风。
保持距离:避免人群聚集。
虽然目前毒株毒性减弱,但基础防护对保护高危人群(如老年人、有基础疾病者)仍至关重要。若出现症状请及时就医。
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
examples:
sql_pairs:
- question: 各个国家的平均病例数
sql: |
SELECT country_covid_cases.country, AVG(country_covid_cases.cases_total) AS average_cases
FROM country_covid_cases
GROUP BY country_covid_cases.country
- question: 各个国家的平均病例数
sql: |
SELECT country_covid_cases.country, AVG(country_covid_cases.cases_total) AS average_cases
FROM country_covid_cases
GROUP BY country_covid_cases.country
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
examples:
synonyms_pairs:
- word: COVID-19
synonyms:
- 新型冠状病毒肺炎
- 2019冠状病毒病
- 新冠
- 新冠肺炎
- 冠状病毒/新冠
- word: UnitedStates
synonyms:
- USA
- 美国
- 美利坚合众国
- The United States of America
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ default void removeSql(String id) {

void removeAllSqls();

// ---------------名词和同义词对-------------------
// ---------------词和同义词对-------------------

default String addSyn(WordSynonymPair synonymPair) {
return addSyns(List.of(synonymPair)).get(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,47 +20,28 @@
@JsonInclude(JsonInclude.Include.NON_NULL)
public class WordSynonymPair {
@NonNull
private final String noun;
private final String word;

@NonNull
private final List<String> synonyms;

private String description;

@JsonCreator
private WordSynonymPair(@JsonProperty("noun") @NonNull String noun,
private WordSynonymPair(@JsonProperty("word") @NonNull String word,
@JsonProperty("synonyms") @NonNull List<String> synonyms) {
this.noun = noun;
this.synonyms = synonyms;
}

@JsonCreator
private WordSynonymPair(@JsonProperty("noun") @NonNull String noun,
@JsonProperty("synonyms") @NonNull List<String> synonyms,
@JsonProperty("description") String description) {
this.noun = noun;
this.word = word;
this.synonyms = synonyms;
this.description = description;
}

public static WordSynonymPair from(@NonNull String noun, @NonNull String synonym, String description) {
return new WordSynonymPair(noun, Collections.singletonList(synonym), description);
}

public static WordSynonymPair from(@NonNull String noun, @NonNull List<String> synonyms, String description) {
return new WordSynonymPair(noun, synonyms, description);
}

public static WordSynonymPair from(@NonNull String noun, @NonNull String synonym) {
return new WordSynonymPair(noun, Collections.singletonList(synonym));
public static WordSynonymPair from(@NonNull String word, @NonNull String synonym) {
return new WordSynonymPair(word, Collections.singletonList(synonym));
}

public static WordSynonymPair from(@NonNull String noun, @NonNull List<String> synonyms) {
return new WordSynonymPair(noun, synonyms);
public static WordSynonymPair from(@NonNull String word, @NonNull List<String> synonyms) {
return new WordSynonymPair(word, synonyms);
}

public static WordSynonymPair from(@NonNull String noun, @NonNull String... synonyms) {
return new WordSynonymPair(noun, Arrays.asList(synonyms));
public static WordSynonymPair from(@NonNull String word, @NonNull String... synonyms) {
return new WordSynonymPair(word, Arrays.asList(synonyms));
}

public void add(@NonNull String synonym) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ SQL: {{ item.sql }}
{% endif %}

{% if synonyms %}
### NOUN AND SYNONYMS ###
### WORD AND SYNONYMS ###
{% for item in synonyms %}
Noun: {{ item.noun }} Synonyms: {{ item.synonyms|join(', ') }}
Word: {{ item.noun }} Synonyms: {{ item.synonyms|join(', ') }}
{% endfor %}
{% endif %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ SQL: {{ item.sql }}
{% endif %}

{% if synonyms %}
### NOUN AND SYNONYMS ###
### WORD AND SYNONYMS ###
{% for item in synonyms %}
Noun: {{ item.noun }} Synonyms: {{ item.synonyms|join(', ') }}
Word: {{ item.noun }} Synonyms: {{ item.synonyms|join(', ') }}
{% endfor %}
{% endif %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ SQL: {{ item.sql }}
{% endif %}

{% if synonyms %}
### NOUN AND SYNONYMS ###
### WORD AND SYNONYMS ###
{% for item in synonyms %}
Noun: {{ item.noun }} Synonyms: {{ item.synonyms|join(', ') }}
Word: {{ item.noun }} Synonyms: {{ item.synonyms|join(', ') }}
{% endfor %}
{% endif %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ SQL: {{ item.sql }}
{% endif %}

{% if synonyms %}
### NOUN AND SYNONYMS ###
### WORD AND SYNONYMS ###
{% for item in synonyms %}
Noun: {{ item.noun }} Synonyms: {{ item.synonyms|join(', ') }}
Word: {{ item.noun }} Synonyms: {{ item.synonyms|join(', ') }}
{% endfor %}
{% endif %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ SQL:
{% endif %}

{% if synonyms %}
### NOUN AND SYNONYMS ###
### WORD AND SYNONYMS ###
{% for item in synonyms %}
Noun: {{ item.noun }} Synonyms: {{ item.synonyms|join(', ') }}
Word: {{ item.noun }} Synonyms: {{ item.synonyms|join(', ') }}
{% endfor %}
{% endif %}

Expand Down
2 changes: 1 addition & 1 deletion dat-sdk/src/main/java/ai/dat/boot/BuildStateManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* @Date 2025/7/17
*/
@Slf4j
public class BuildStateManager {
class BuildStateManager {

private static final String STATE_FILE_PREFIX = "build_state_";
private static final String STATE_FILE_SUFFIX = ".json";
Expand Down
54 changes: 54 additions & 0 deletions dat-sdk/src/main/java/ai/dat/boot/ChangeKnowledgeCacheUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package ai.dat.boot;

import lombok.NonNull;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* 变化的业务知识缓存工具
*
* @Author JunjieM
* @Date 2025/9/26
*/
class ChangeKnowledgeCacheUtil {

private ChangeKnowledgeCacheUtil() {
}

// Map<projectId, Map<yamlFileRelativePath, List<String>>>
private final static Map<String, Map<String, List<String>>> CACHE = new HashMap<>();

public static void add(@NonNull String projectId,
@NonNull String relativePath,
@NonNull List<String> knowledge) {
Map<String, List<String>> listMap = new HashMap<>();
if (CACHE.containsKey(projectId)) {
listMap = CACHE.get(projectId);
}
listMap.put(relativePath, knowledge);
CACHE.put(projectId, listMap);
}

public static List<String> get(@NonNull String projectId,
@NonNull String relativePath) {
Map<String, List<String>> listMap = new HashMap<>();
if (CACHE.containsKey(projectId)) {
listMap = CACHE.get(projectId);
}
return listMap.get(relativePath);
}

public static Map<String, List<String>> get(String projectId) {
if (CACHE.containsKey(projectId)) {
return CACHE.get(projectId);
}
return Collections.emptyMap();
}

public static Map<String, List<String>> remove(String projectId) {
return CACHE.remove(projectId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package ai.dat.boot;

import ai.dat.core.contentstore.data.QuestionSqlPair;
import lombok.NonNull;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* 变化的问答SQL对缓存工具
*
* @Author JunjieM
* @Date 2025/9/26
*/
class ChangeQuestionSqlPairsCacheUtil {

private ChangeQuestionSqlPairsCacheUtil() {
}

// Map<projectId, Map<yamlFileRelativePath, List<QuestionSqlPair>>>
private final static Map<String, Map<String, List<QuestionSqlPair>>> CACHE = new HashMap<>();

public static void add(@NonNull String projectId,
@NonNull String relativePath,
@NonNull List<QuestionSqlPair> questionSqlPairs) {
Map<String, List<QuestionSqlPair>> listMap = new HashMap<>();
if (CACHE.containsKey(projectId)) {
listMap = CACHE.get(projectId);
}
listMap.put(relativePath, questionSqlPairs);
CACHE.put(projectId, listMap);
}

public static List<QuestionSqlPair> get(@NonNull String projectId,
@NonNull String relativePath) {
Map<String, List<QuestionSqlPair>> listMap = new HashMap<>();
if (CACHE.containsKey(projectId)) {
listMap = CACHE.get(projectId);
}
return listMap.get(relativePath);
}

public static Map<String, List<QuestionSqlPair>> get(String projectId) {
if (CACHE.containsKey(projectId)) {
return CACHE.get(projectId);
}
return Collections.emptyMap();
}

public static Map<String, List<QuestionSqlPair>> remove(String projectId) {
return CACHE.remove(projectId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class ChangeSemanticModelsCacheUtil {
private ChangeSemanticModelsCacheUtil() {
}

// Map<projectId, Map<yamlFileRelativePath, List<SemanticModel>>>
private final static Map<String, Map<String, List<SemanticModel>>> CACHE = new HashMap<>();

public static void add(@NonNull String projectId,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package ai.dat.boot;

import ai.dat.core.contentstore.data.WordSynonymPair;
import lombok.NonNull;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* 变化的同义词对缓存工具
*
* @Author JunjieM
* @Date 2025/9/26
*/
class ChangeWordSynonymPairsCacheUtil {

private ChangeWordSynonymPairsCacheUtil() {
}

// Map<projectId, Map<yamlFileRelativePath, List<WordSynonymPair>>>
private final static Map<String, Map<String, List<WordSynonymPair>>> CACHE = new HashMap<>();

public static void add(@NonNull String projectId,
@NonNull String relativePath,
@NonNull List<WordSynonymPair> wordSynonymPairs) {
Map<String, List<WordSynonymPair>> listMap = new HashMap<>();
if (CACHE.containsKey(projectId)) {
listMap = CACHE.get(projectId);
}
listMap.put(relativePath, wordSynonymPairs);
CACHE.put(projectId, listMap);
}

public static List<WordSynonymPair> get(@NonNull String projectId,
@NonNull String relativePath) {
Map<String, List<WordSynonymPair>> listMap = new HashMap<>();
if (CACHE.containsKey(projectId)) {
listMap = CACHE.get(projectId);
}
return listMap.get(relativePath);
}

public static Map<String, List<WordSynonymPair>> get(String projectId) {
if (CACHE.containsKey(projectId)) {
return CACHE.get(projectId);
}
return Collections.emptyMap();
}

public static Map<String, List<WordSynonymPair>> remove(String projectId) {
return CACHE.remove(projectId);
}
}
Loading