fix(知识图谱): 修正节点和关系统计方法,排除知识库自动构建的图谱
更新 GraphView.vue 中的统计描述,明确说明不包含知识库创建的图谱 修改 graphbase.py 中的查询逻辑,只统计带有特定标签的节点和关系 更新 changelog 中相关问题的状态 #236
This commit is contained in:
parent
9481117000
commit
24f3d03c8e
@ -4,10 +4,10 @@
|
|||||||
### v2.0 PreRelease
|
### v2.0 PreRelease
|
||||||
|
|
||||||
💭 **Features Todo**
|
💭 **Features Todo**
|
||||||
- [x] 知识库使用 LightRAG(GraphRAG 轻量版)重构(🌟🌟🌟🌟🌟)
|
- [x] 知识库使用 LightRAG(GraphRAG 轻量版)重构
|
||||||
- [x] 集成 MinerU 处理 PDF 文件。(🌟🌟🌟)
|
- [x] 集成 MinerU 处理 PDF 文件
|
||||||
- [x] 优化现有向量模型的逻辑,全局配置的向量模型作为新建知识库的默认模型,但是查询的时候,使用对应数据库的向量模型查询(单例模式)(🌟🌟🌟)
|
- [x] 优化现有向量模型的逻辑,全局配置的向量模型作为新建知识库的默认模型,但是查询的时候,使用对应数据库的向量模型查询(单例模式)
|
||||||
- [x] 多类型知识库支持(🌟🌟🌟🌟🌟)
|
- [x] 多类型知识库支持
|
||||||
- [x] 设计问答知识库,支持针对问答对的调优
|
- [x] 设计问答知识库,支持针对问答对的调优
|
||||||
- [x] 添加了批量上传文件的脚本,并优化文件信息
|
- [x] 添加了批量上传文件的脚本,并优化文件信息
|
||||||
|
|
||||||
@ -18,7 +18,7 @@
|
|||||||
- [x] 与最新的 LightRAG 版本兼容性存在问题 #233
|
- [x] 与最新的 LightRAG 版本兼容性存在问题 #233
|
||||||
- [x] 切换知识库之后,检索结果没有刷新
|
- [x] 切换知识库之后,检索结果没有刷新
|
||||||
- [x] 文件上传模块 UI的边距、配色有问题
|
- [x] 文件上传模块 UI的边距、配色有问题
|
||||||
- [ ] 知识图谱页面的节点数量统计方法 #236
|
- [x] 知识图谱页面的节点数量统计方法 #236
|
||||||
- [ ] 当没有手动添加节点的时候,尝试检索,会出现为创建索引的情况 #236
|
- [ ] 当没有手动添加节点的时候,尝试检索,会出现为创建索引的情况 #236
|
||||||
|
|
||||||
# 💯 More:
|
# 💯 More:
|
||||||
|
|||||||
@ -343,7 +343,7 @@ class GraphDatabase:
|
|||||||
def query_by_vector(tx, text, threshold):
|
def query_by_vector(tx, text, threshold):
|
||||||
# 首先检查索引是否存在
|
# 首先检查索引是否存在
|
||||||
if not _index_exists(tx, "entityEmbeddings"):
|
if not _index_exists(tx, "entityEmbeddings"):
|
||||||
raise Exception("向量索引不存在,请先创建索引")
|
raise Exception("向量索引不存在,请先创建索引,或当前图谱中未上传任何三元组(知识库中自动构建的,不会在此处展示和检索)。")
|
||||||
|
|
||||||
embedding = self.get_embedding(text)
|
embedding = self.get_embedding(text)
|
||||||
result = tx.run("""
|
result = tx.run("""
|
||||||
@ -437,9 +437,11 @@ class GraphDatabase:
|
|||||||
assert self.driver is not None, "Database is not connected"
|
assert self.driver is not None, "Database is not connected"
|
||||||
self.use_database(graph_name)
|
self.use_database(graph_name)
|
||||||
def query(tx):
|
def query(tx):
|
||||||
entity_count = tx.run("MATCH (n) RETURN count(n) AS count").single()["count"]
|
# 只统计包含Entity标签的节点
|
||||||
relationship_count = tx.run("MATCH ()-[r]->() RETURN count(r) AS count").single()["count"]
|
entity_count = tx.run("MATCH (n:Entity) RETURN count(n) AS count").single()["count"]
|
||||||
triples_count = tx.run("MATCH (n)-[r]->(m) RETURN count(n) AS count").single()["count"]
|
# 只统计包含RELATION标签的关系
|
||||||
|
relationship_count = tx.run("MATCH ()-[r:RELATION]->() RETURN count(r) AS count").single()["count"]
|
||||||
|
triples_count = tx.run("MATCH (n:Entity)-[r:RELATION]->(m:Entity) RETURN count(n) AS count").single()["count"]
|
||||||
|
|
||||||
# 获取所有标签
|
# 获取所有标签
|
||||||
labels = tx.run("CALL db.labels() YIELD label RETURN collect(label) AS labels").single()["labels"]
|
labels = tx.run("CALL db.labels() YIELD label RETURN collect(label) AS labels").single()["labels"]
|
||||||
|
|||||||
@ -351,7 +351,7 @@ const graphDescription = computed(() => {
|
|||||||
const modelName = graphInfo.value?.embed_model_name || '未上传文件';
|
const modelName = graphInfo.value?.embed_model_name || '未上传文件';
|
||||||
const unindexed = unindexedCount.value > 0 ? `,${unindexedCount.value}个节点未索引` : '';
|
const unindexed = unindexedCount.value > 0 ? `,${unindexedCount.value}个节点未索引` : '';
|
||||||
|
|
||||||
return `${dbName} - 共 ${entityCount} 实体,${relationCount} 个关系。向量模型:${modelName}${unindexed}`;
|
return `${dbName} - 共 ${entityCount} 实体,${relationCount} 个关系(不含知识库创建的图谱)。向量模型:${modelName}${unindexed}`;
|
||||||
});
|
});
|
||||||
|
|
||||||
// 为未索引节点添加索引
|
// 为未索引节点添加索引
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user