From 667239a62505c7e1c80125610b42486a2dfb7b18 Mon Sep 17 00:00:00 2001 From: wizardchen Date: Sun, 16 Nov 2025 23:46:33 +0800 Subject: [PATCH] feat: Add system information fields and localization for new engines - Introduced new fields for keyword index engine, vector store engine, and graph database engine in the system info API response. - Updated localization files in English, Russian, and Chinese to include labels and descriptions for the new system information fields. - Enhanced the SystemInfo.vue component to display the new engine information in the settings view. --- frontend/src/api/system/index.ts | 3 + frontend/src/i18n/locales/en-US.ts | 6 ++ frontend/src/i18n/locales/ru-RU.ts | 6 ++ frontend/src/i18n/locales/zh-CN.ts | 6 ++ frontend/src/views/settings/SystemInfo.vue | 33 +++++++ internal/handler/system.go | 106 ++++++++++++++++++--- 6 files changed, 149 insertions(+), 11 deletions(-) diff --git a/frontend/src/api/system/index.ts b/frontend/src/api/system/index.ts index bd9bfe53..49af717c 100644 --- a/frontend/src/api/system/index.ts +++ b/frontend/src/api/system/index.ts @@ -5,6 +5,9 @@ export interface SystemInfo { commit_id?: string build_time?: string go_version?: string + keyword_index_engine?: string + vector_store_engine?: string + graph_database_engine?: string } export interface ToolDefinition { diff --git a/frontend/src/i18n/locales/en-US.ts b/frontend/src/i18n/locales/en-US.ts index 2f03b7f4..2d56bf1e 100644 --- a/frontend/src/i18n/locales/en-US.ts +++ b/frontend/src/i18n/locales/en-US.ts @@ -1089,6 +1089,12 @@ export default { buildTimeDescription: 'Time when the system was built', goVersionLabel: 'Go Version', goVersionDescription: 'Go language version used by the backend', + keywordIndexEngineLabel: 'Keyword Index Engine', + keywordIndexEngineDescription: 'Currently used keyword index engine', + vectorStoreEngineLabel: 'Vector Store Engine', + vectorStoreEngineDescription: 'Currently used vector store engine', + graphDatabaseEngineLabel: 'Graph Database Engine', + graphDatabaseEngineDescription: 'Currently used graph database engine', unknown: 'Unknown', messages: { fetchFailed: 'Failed to fetch system information', diff --git a/frontend/src/i18n/locales/ru-RU.ts b/frontend/src/i18n/locales/ru-RU.ts index fcf3b8b6..2d853e51 100644 --- a/frontend/src/i18n/locales/ru-RU.ts +++ b/frontend/src/i18n/locales/ru-RU.ts @@ -626,6 +626,12 @@ export default { buildTimeDescription: 'Время, когда система была собрана', goVersionLabel: 'Версия Go', goVersionDescription: 'Версия языка Go, используемая backend', + keywordIndexEngineLabel: 'Движок индексации ключевых слов', + keywordIndexEngineDescription: 'Используемый в настоящее время движок индексации ключевых слов', + vectorStoreEngineLabel: 'Движок векторного хранилища', + vectorStoreEngineDescription: 'Используемый в настоящее время движок векторного хранилища', + graphDatabaseEngineLabel: 'Движок графовой базы данных', + graphDatabaseEngineDescription: 'Используемый в настоящее время движок графовой базы данных', unknown: 'Неизвестно', messages: { fetchFailed: 'Не удалось получить информацию о системе', diff --git a/frontend/src/i18n/locales/zh-CN.ts b/frontend/src/i18n/locales/zh-CN.ts index 01a88ccf..4cd8835b 100644 --- a/frontend/src/i18n/locales/zh-CN.ts +++ b/frontend/src/i18n/locales/zh-CN.ts @@ -708,6 +708,12 @@ export default { buildTimeDescription: "系统构建的时间", goVersionLabel: "Go 版本", goVersionDescription: "后端使用的 Go 语言版本", + keywordIndexEngineLabel: "关键词索引引擎", + keywordIndexEngineDescription: "当前使用的关键词索引引擎", + vectorStoreEngineLabel: "向量存储引擎", + vectorStoreEngineDescription: "当前使用的向量存储引擎", + graphDatabaseEngineLabel: "图数据库引擎", + graphDatabaseEngineDescription: "当前使用的图数据库引擎", unknown: "未知", messages: { fetchFailed: "获取系统信息失败", diff --git a/frontend/src/views/settings/SystemInfo.vue b/frontend/src/views/settings/SystemInfo.vue index 606c41e8..b916090b 100644 --- a/frontend/src/views/settings/SystemInfo.vue +++ b/frontend/src/views/settings/SystemInfo.vue @@ -60,6 +60,39 @@ + +
+
+ +

{{ $t('system.keywordIndexEngineDescription') }}

+
+
+ {{ systemInfo?.keyword_index_engine || $t('system.unknown') }} +
+
+ + +
+
+ +

{{ $t('system.vectorStoreEngineDescription') }}

+
+
+ {{ systemInfo?.vector_store_engine || $t('system.unknown') }} +
+
+ + +
+
+ +

{{ $t('system.graphDatabaseEngineDescription') }}

+
+
+ {{ systemInfo?.graph_database_engine || $t('system.unknown') }} +
+
+ diff --git a/internal/handler/system.go b/internal/handler/system.go index 43329d95..327b437b 100644 --- a/internal/handler/system.go +++ b/internal/handler/system.go @@ -1,24 +1,35 @@ package handler import ( + "os" + "strings" + + "github.com/Tencent/WeKnora/internal/config" "github.com/Tencent/WeKnora/internal/logger" "github.com/gin-gonic/gin" ) // SystemHandler handles system-related requests -type SystemHandler struct{} +type SystemHandler struct { + cfg *config.Config +} // NewSystemHandler creates a new system handler -func NewSystemHandler() *SystemHandler { - return &SystemHandler{} +func NewSystemHandler(cfg *config.Config) *SystemHandler { + return &SystemHandler{ + cfg: cfg, + } } // GetSystemInfoResponse defines the response structure for system info type GetSystemInfoResponse struct { - Version string `json:"version"` - CommitID string `json:"commit_id,omitempty"` - BuildTime string `json:"build_time,omitempty"` - GoVersion string `json:"go_version,omitempty"` + Version string `json:"version"` + CommitID string `json:"commit_id,omitempty"` + BuildTime string `json:"build_time,omitempty"` + GoVersion string `json:"go_version,omitempty"` + KeywordIndexEngine string `json:"keyword_index_engine,omitempty"` + VectorStoreEngine string `json:"vector_store_engine,omitempty"` + GraphDatabaseEngine string `json:"graph_database_engine,omitempty"` } // 编译时注入的版本信息 @@ -33,11 +44,23 @@ var ( func (h *SystemHandler) GetSystemInfo(c *gin.Context) { ctx := logger.CloneContext(c.Request.Context()) + // Get keyword index engine from RETRIEVE_DRIVER + keywordIndexEngine := h.getKeywordIndexEngine() + + // Get vector store engine from config or RETRIEVE_DRIVER + vectorStoreEngine := h.getVectorStoreEngine() + + // Get graph database engine from NEO4J_ENABLE + graphDatabaseEngine := h.getGraphDatabaseEngine() + response := GetSystemInfoResponse{ - Version: Version, - CommitID: CommitID, - BuildTime: BuildTime, - GoVersion: GoVersion, + Version: Version, + CommitID: CommitID, + BuildTime: BuildTime, + GoVersion: GoVersion, + KeywordIndexEngine: keywordIndexEngine, + VectorStoreEngine: vectorStoreEngine, + GraphDatabaseEngine: graphDatabaseEngine, } logger.Info(ctx, "System info retrieved successfully") @@ -47,3 +70,64 @@ func (h *SystemHandler) GetSystemInfo(c *gin.Context) { "data": response, }) } + +// getKeywordIndexEngine returns the keyword index engine name +func (h *SystemHandler) getKeywordIndexEngine() string { + retrieveDriver := os.Getenv("RETRIEVE_DRIVER") + if retrieveDriver == "" { + return "未配置" + } + + drivers := strings.Split(retrieveDriver, ",") + // Filter out engines that support keyword retrieval + keywordEngines := []string{} + for _, driver := range drivers { + driver = strings.TrimSpace(driver) + if driver == "postgres" || driver == "elasticsearch_v7" || driver == "elasticsearch_v8" { + keywordEngines = append(keywordEngines, driver) + } + } + + if len(keywordEngines) == 0 { + return "未配置" + } + return strings.Join(keywordEngines, ", ") +} + +// getVectorStoreEngine returns the vector store engine name +func (h *SystemHandler) getVectorStoreEngine() string { + // First check config.yaml + if h.cfg != nil && h.cfg.VectorDatabase != nil && h.cfg.VectorDatabase.Driver != "" { + return h.cfg.VectorDatabase.Driver + } + + // Fallback to RETRIEVE_DRIVER for vector support + retrieveDriver := os.Getenv("RETRIEVE_DRIVER") + if retrieveDriver == "" { + return "未配置" + } + + drivers := strings.Split(retrieveDriver, ",") + // Filter out engines that support vector retrieval + vectorEngines := []string{} + for _, driver := range drivers { + driver = strings.TrimSpace(driver) + if driver == "postgres" || driver == "elasticsearch_v8" { + vectorEngines = append(vectorEngines, driver) + } + } + + if len(vectorEngines) == 0 { + return "未配置" + } + return strings.Join(vectorEngines, ", ") +} + +// getGraphDatabaseEngine returns the graph database engine name +func (h *SystemHandler) getGraphDatabaseEngine() string { + neo4jEnable := strings.ToLower(os.Getenv("NEO4J_ENABLE")) + if neo4jEnable == "true" { + return "Neo4j" + } + return "未启用" +}