feat: Add warning message for disabled knowledge graph database and provide guidance on enabling it

This commit is contained in:
begoniezhao
2025-11-25 17:06:26 +08:00
parent c1f3a0df2d
commit 9c3d4ec922
4 changed files with 53 additions and 2 deletions
+2
View File
@@ -315,6 +315,8 @@ export default {
extractFailed: 'Entity-relationship extraction failed',
exampleLoaded: 'Example loaded',
exampleCleared: 'Example cleared',
disabledWarning: 'Knowledge graph database is not enabled, entity-relationship extraction will not be available',
howToEnable: 'How to enable knowledge graph?',
saveSuccess: 'Graph configuration saved',
saveFailed: 'Failed to save configuration: {message}',
errors: {
+2
View File
@@ -314,6 +314,8 @@ export default {
extractFailed: 'Не удалось извлечь сущности и отношения',
exampleLoaded: 'Пример загружен',
exampleCleared: 'Пример очищен',
disabledWarning: 'База данных графа знаний не включена, извлечение сущностей и отношений будет недоступно',
howToEnable: 'Как включить граф знаний?',
saveSuccess: 'Настройки графа сохранены',
saveFailed: 'Не удалось сохранить настройки: {message}',
errors: {
+2
View File
@@ -417,6 +417,8 @@ export default {
extractFailed: "实体关系提取失败",
exampleLoaded: "示例已加载",
exampleCleared: "示例已清除",
disabledWarning: "知识图谱数据库未启用,实体关系提取功能将无法使用",
howToEnable: "如何启用知识图谱?",
saveSuccess: "图谱配置已保存",
saveFailed: "保存配置失败: {message}",
errors: {
@@ -3,6 +3,20 @@
<div class="section-header">
<h2>{{ t('graphSettings.title') }}</h2>
<p class="section-description">{{ t('graphSettings.description') }}</p>
<!-- Warning message when graph database is not enabled -->
<t-alert
v-if="!isGraphDatabaseEnabled"
theme="warning"
style="margin-top: 16px;"
>
<template #message>
<div>{{ t('graphSettings.disabledWarning') }}</div>
<t-link class="graph-guide-link" theme="primary" @click="handleOpenGraphGuide">
{{ t('graphSettings.howToEnable') }}
</t-link>
</template>
</t-alert>
</div>
<div class="settings-group">
@@ -279,11 +293,12 @@
</template>
<script setup lang="ts">
import { ref, watch, onMounted } from 'vue'
import { ref, watch, onMounted, computed } from 'vue'
import { MessagePlugin } from 'tdesign-vue-next'
import { useI18n } from 'vue-i18n'
import { extractTextRelations, fabriText, fabriTag, type Node, type Relation, type LLMConfig } from '@/api/initialization'
import { listModels } from '@/api/model'
import { getSystemInfo } from '@/api/system'
const { t } = useI18n()
@@ -326,6 +341,14 @@ const modelStatus = ref({
}
})
// 系统信息
const systemInfo = ref<any>(null)
// 计算图数据库是否启用
const isGraphDatabaseEnabled = computed(() => {
return systemInfo.value?.graph_database_engine && systemInfo.value.graph_database_engine !== '未启用'
})
// Watch for prop changes
watch(() => props.graphExtract, (newVal) => {
localGraphExtract.value = {
@@ -542,9 +565,31 @@ const loadModelStatus = async () => {
}
}
// 加载系统信息
const loadSystemInfo = async () => {
try {
const response = await getSystemInfo()
systemInfo.value = response.data
} catch (error: any) {
console.error('Failed to load system info:', error)
}
}
const graphGuideUrl =
import.meta.env.VITE_KG_GUIDE_URL ||
'https://github.com/Tencent/WeKnora/blob/main/docs/KnowledgeGraph.md'
// Open guide documentation to show how to enable graph database
const handleOpenGraphGuide = () => {
window.open(graphGuideUrl, '_blank', 'noopener')
}
// 初始化
onMounted(async () => {
await loadModelStatus()
await Promise.all([
loadModelStatus(),
loadSystemInfo()
])
})
</script>