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.
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -626,6 +626,12 @@ export default {
|
||||
buildTimeDescription: 'Время, когда система была собрана',
|
||||
goVersionLabel: 'Версия Go',
|
||||
goVersionDescription: 'Версия языка Go, используемая backend',
|
||||
keywordIndexEngineLabel: 'Движок индексации ключевых слов',
|
||||
keywordIndexEngineDescription: 'Используемый в настоящее время движок индексации ключевых слов',
|
||||
vectorStoreEngineLabel: 'Движок векторного хранилища',
|
||||
vectorStoreEngineDescription: 'Используемый в настоящее время движок векторного хранилища',
|
||||
graphDatabaseEngineLabel: 'Движок графовой базы данных',
|
||||
graphDatabaseEngineDescription: 'Используемый в настоящее время движок графовой базы данных',
|
||||
unknown: 'Неизвестно',
|
||||
messages: {
|
||||
fetchFailed: 'Не удалось получить информацию о системе',
|
||||
|
||||
@@ -708,6 +708,12 @@ export default {
|
||||
buildTimeDescription: "系统构建的时间",
|
||||
goVersionLabel: "Go 版本",
|
||||
goVersionDescription: "后端使用的 Go 语言版本",
|
||||
keywordIndexEngineLabel: "关键词索引引擎",
|
||||
keywordIndexEngineDescription: "当前使用的关键词索引引擎",
|
||||
vectorStoreEngineLabel: "向量存储引擎",
|
||||
vectorStoreEngineDescription: "当前使用的向量存储引擎",
|
||||
graphDatabaseEngineLabel: "图数据库引擎",
|
||||
graphDatabaseEngineDescription: "当前使用的图数据库引擎",
|
||||
unknown: "未知",
|
||||
messages: {
|
||||
fetchFailed: "获取系统信息失败",
|
||||
|
||||
@@ -60,6 +60,39 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Keyword Index Engine -->
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>{{ $t('system.keywordIndexEngineLabel') }}</label>
|
||||
<p class="desc">{{ $t('system.keywordIndexEngineDescription') }}</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<span class="info-value">{{ systemInfo?.keyword_index_engine || $t('system.unknown') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Vector Store Engine -->
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>{{ $t('system.vectorStoreEngineLabel') }}</label>
|
||||
<p class="desc">{{ $t('system.vectorStoreEngineDescription') }}</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<span class="info-value">{{ systemInfo?.vector_store_engine || $t('system.unknown') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Graph Database Engine -->
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>{{ $t('system.graphDatabaseEngineLabel') }}</label>
|
||||
<p class="desc">{{ $t('system.graphDatabaseEngineDescription') }}</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<span class="info-value">{{ systemInfo?.graph_database_engine || $t('system.unknown') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
+95
-11
@@ -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 "未启用"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user