+
-
@@ -179,6 +179,27 @@ const handleClose = () => {
}
}
+// 监听初始导航设置
+watch(() => uiStore.settingsInitialSection, (section) => {
+ if (section && visible.value) {
+ currentSection.value = section
+ if (uiStore.settingsInitialSubSection) {
+ currentSubSection.value = uiStore.settingsInitialSubSection
+ // 展开对应的父菜单
+ if (!expandedMenus.value.includes(section)) {
+ expandedMenus.value.push(section)
+ }
+ // 滚动到对应区域
+ setTimeout(() => {
+ const element = document.querySelector(`[data-model-type="${uiStore.settingsInitialSubSection}"]`)
+ if (element) {
+ element.scrollIntoView({ behavior: 'smooth', block: 'start' })
+ }
+ }, 300)
+ }
+ }
+}, { immediate: true })
+
// ESC 键关闭
const handleEscape = (e: KeyboardEvent) => {
if (e.key === 'Escape' && visible.value) {
@@ -221,7 +242,7 @@ onUnmounted(() => {
.settings-overlay {
position: fixed;
inset: 0;
- z-index: 999;
+ z-index: 1000;
background: transparent;
display: flex;
align-items: center;
@@ -235,9 +256,9 @@ onUnmounted(() => {
width: 100%;
max-width: 900px;
height: 700px;
- background: #ffffff;
+ background: var(--td-bg-color-container);
border-radius: 12px;
- box-shadow: 0 6px 28px rgba(15, 23, 42, 0.08);
+ box-shadow: var(--td-shadow-3);
overflow: hidden;
display: flex;
flex-direction: column;
@@ -252,7 +273,7 @@ onUnmounted(() => {
height: 32px;
border: none;
background: transparent;
- color: #666666;
+ color: var(--td-text-color-secondary);
cursor: pointer;
border-radius: 6px;
display: flex;
@@ -262,8 +283,8 @@ onUnmounted(() => {
z-index: 10;
&:hover {
- background: #f5f5f5;
- color: #333333;
+ background: var(--td-bg-color-container-hover);
+ color: var(--td-text-color-primary);
}
}
@@ -277,8 +298,8 @@ onUnmounted(() => {
/* 左侧导航栏 */
.settings-sidebar {
width: 220px;
- background-color: #f8f9fa;
- border-right: 1px solid #e5e7eb;
+ background-color: var(--td-bg-color-secondarycontainer);
+ border-right: 1px solid var(--td-component-border);
flex-shrink: 0;
overflow-y: auto;
display: flex;
@@ -287,13 +308,13 @@ onUnmounted(() => {
.sidebar-header {
padding: 24px 16px 16px;
- border-bottom: 1px solid #e5e7eb;
+ border-bottom: 1px solid var(--td-component-border);
}
.sidebar-title {
font-size: 18px;
font-weight: 600;
- color: #333333;
+ color: var(--td-text-color-primary);
margin: 0;
}
@@ -309,19 +330,19 @@ onUnmounted(() => {
margin-bottom: 4px;
border-radius: 6px;
cursor: pointer;
- color: #666666;
+ color: var(--td-text-color-secondary);
font-size: 14px;
transition: all 0.2s ease;
user-select: none;
&:hover {
- background-color: #e8f5ed;
- color: #333333;
+ background-color: var(--td-bg-color-container-hover);
+ color: var(--td-text-color-primary);
}
&.active {
- background-color: rgba(7, 192, 95, 0.1);
- color: #07C05F;
+ background-color: var(--td-brand-color-light);
+ color: var(--td-brand-color);
font-weight: 500;
}
}
@@ -358,19 +379,19 @@ onUnmounted(() => {
margin-bottom: 2px;
border-radius: 4px;
cursor: pointer;
- color: #666666;
+ color: var(--td-text-color-secondary);
font-size: 13px;
transition: all 0.2s ease;
user-select: none;
&:hover {
- background-color: #f5f7fa;
- color: #333333;
+ background-color: var(--td-bg-color-component-hover);
+ color: var(--td-text-color-primary);
}
&.active {
- background-color: rgba(7, 192, 95, 0.08);
- color: #07C05F;
+ background-color: var(--td-brand-color-light);
+ color: var(--td-brand-color);
font-weight: 500;
}
}
@@ -409,7 +430,7 @@ onUnmounted(() => {
.settings-content {
flex: 1;
overflow-y: auto;
- background-color: #ffffff;
+ background-color: var(--td-bg-color-container);
}
.content-wrapper {
@@ -461,29 +482,29 @@ onUnmounted(() => {
}
.settings-sidebar::-webkit-scrollbar-track {
- background: #f8f9fa;
+ background: var(--td-bg-color-secondarycontainer);
}
.settings-sidebar::-webkit-scrollbar-thumb {
- background: #d0d0d0;
+ background: var(--td-bg-color-component);
border-radius: 3px;
}
.settings-sidebar::-webkit-scrollbar-thumb:hover {
- background: #b0b0b0;
+ background: var(--td-bg-color-component-hover);
}
.settings-content::-webkit-scrollbar-track {
- background: #ffffff;
+ background: var(--td-bg-color-container);
}
.settings-content::-webkit-scrollbar-thumb {
- background: #d0d0d0;
+ background: var(--td-bg-color-component);
border-radius: 3px;
}
.settings-content::-webkit-scrollbar-thumb:hover {
- background: #b0b0b0;
+ background: var(--td-bg-color-component-hover);
}
diff --git a/frontend/src/views/settings/SystemInfo.vue b/frontend/src/views/settings/SystemInfo.vue
index 258e9b96..0b4878f7 100644
--- a/frontend/src/views/settings/SystemInfo.vue
+++ b/frontend/src/views/settings/SystemInfo.vue
@@ -411,13 +411,13 @@ onMounted(() => {
h2 {
font-size: 20px;
font-weight: 600;
- color: #333333;
+ color: var(--td-text-color-primary);
margin: 0 0 8px 0;
}
.section-description {
font-size: 14px;
- color: #666666;
+ color: var(--td-text-color-secondary);
margin: 0;
line-height: 1.5;
}
@@ -429,7 +429,7 @@ onMounted(() => {
gap: 12px;
padding: 40px 0;
justify-content: center;
- color: #666666;
+ color: var(--td-text-color-secondary);
font-size: 14px;
}
@@ -448,7 +448,7 @@ onMounted(() => {
align-items: flex-start;
justify-content: space-between;
padding: 20px 0;
- border-bottom: 1px solid #e5e7eb;
+ border-bottom: 1px solid var(--td-component-border);
&:last-child {
border-bottom: none;
@@ -463,14 +463,14 @@ onMounted(() => {
label {
font-size: 15px;
font-weight: 500;
- color: #333333;
+ color: var(--td-text-color-primary);
display: block;
margin-bottom: 4px;
}
.desc {
font-size: 13px;
- color: #666666;
+ color: var(--td-text-color-secondary);
margin: 0;
line-height: 1.5;
}
@@ -485,12 +485,12 @@ onMounted(() => {
.info-value {
font-size: 14px;
- color: #333333;
+ color: var(--td-text-color-primary);
text-align: right;
word-break: break-word;
.commit-info {
- color: #999999;
+ color: var(--td-text-color-placeholder);
font-size: 12px;
margin-left: 6px;
}
@@ -512,8 +512,8 @@ onMounted(() => {
.usage-text {
font-size: 14px;
- font-weight: 500;
- color: #333333;
+ font-weight: 500;
+ color: var(--td-text-color-primary);
min-width: 50px;
text-align: right;
}
@@ -522,7 +522,7 @@ onMounted(() => {
.info-section-title {
font-size: 14px;
font-weight: 600;
- color: #333333;
+ color: var(--td-text-color-primary);
margin-top: 24px;
margin-bottom: 12px;
diff --git a/internal/handler/initialization.go b/internal/handler/initialization.go
index a78bef0c..22471df3 100644
--- a/internal/handler/initialization.go
+++ b/internal/handler/initialization.go
@@ -83,6 +83,49 @@ func NewInitializationHandler(
}
}
+// KBModelConfigRequest 知识库模型配置请求(简化版,只传模型ID)
+type KBModelConfigRequest struct {
+ LLMModelID string `json:"llmModelId" binding:"required"`
+ EmbeddingModelID string `json:"embeddingModelId" binding:"required"`
+ RerankModelID string `json:"rerankModelId"` // 可选
+ VLLMModelID string `json:"vllmModelId"` // 可选
+
+ // 文档分块配置
+ DocumentSplitting struct {
+ ChunkSize int `json:"chunkSize"`
+ ChunkOverlap int `json:"chunkOverlap"`
+ Separators []string `json:"separators"`
+ } `json:"documentSplitting"`
+
+ // 多模态配置
+ Multimodal struct {
+ Enabled bool `json:"enabled"`
+ StorageType string `json:"storageType"` // "cos" or "minio"
+ COS *struct {
+ SecretID string `json:"secretId"`
+ SecretKey string `json:"secretKey"`
+ Region string `json:"region"`
+ BucketName string `json:"bucketName"`
+ AppID string `json:"appId"`
+ PathPrefix string `json:"pathPrefix"`
+ } `json:"cos"`
+ Minio *struct {
+ BucketName string `json:"bucketName"`
+ UseSSL bool `json:"useSSL"`
+ PathPrefix string `json:"pathPrefix"`
+ } `json:"minio"`
+ } `json:"multimodal"`
+
+ // 知识图谱配置
+ NodeExtract struct {
+ Enabled bool `json:"enabled"`
+ Text string `json:"text"`
+ Tags []string `json:"tags"`
+ Nodes []types.GraphNode `json:"nodes"`
+ Relations []types.GraphRelation `json:"relations"`
+ } `json:"nodeExtract"`
+}
+
// InitializationRequest 初始化请求结构
type InitializationRequest struct {
LLM struct {
@@ -152,6 +195,164 @@ type InitializationRequest struct {
} `json:"nodeExtract"`
}
+// UpdateKBConfig 根据知识库ID和模型ID更新配置(简化版)
+func (h *InitializationHandler) UpdateKBConfig(c *gin.Context) {
+ ctx := c.Request.Context()
+ kbIdStr := c.Param("kbId")
+
+ var req KBModelConfigRequest
+ if err := c.ShouldBindJSON(&req); err != nil {
+ logger.Error(ctx, "Failed to parse KB config request", err)
+ c.Error(errors.NewBadRequestError(err.Error()))
+ return
+ }
+ logger.Infof(ctx, "Starting KB configuration update with model IDs, kbId: %s", kbIdStr)
+
+ // 获取知识库信息
+ kb, err := h.kbService.GetKnowledgeBaseByID(ctx, kbIdStr)
+ if err != nil || kb == nil {
+ logger.ErrorWithFields(ctx, err, map[string]interface{}{"kbId": kbIdStr})
+ c.Error(errors.NewNotFoundError("知识库不存在"))
+ return
+ }
+
+ // 检查Embedding模型是否可以修改
+ if kb.EmbeddingModelID != "" && kb.EmbeddingModelID != req.EmbeddingModelID {
+ // 检查是否已有文件
+ knowledgeList, err := h.knowledgeService.ListPagedKnowledgeByKnowledgeBaseID(ctx,
+ kbIdStr, &types.Pagination{
+ Page: 1,
+ PageSize: 1,
+ })
+ if err == nil && knowledgeList != nil && knowledgeList.Total > 0 {
+ logger.Error(ctx, "Cannot change embedding model when files exist")
+ c.Error(errors.NewBadRequestError("知识库中已有文件,无法修改Embedding模型"))
+ return
+ }
+ }
+
+ // 从数据库获取模型详情并验证
+ llmModel, err := h.modelService.GetModelByID(ctx, req.LLMModelID)
+ if err != nil || llmModel == nil {
+ logger.Error(ctx, "LLM model not found", "modelId", req.LLMModelID)
+ c.Error(errors.NewBadRequestError("LLM模型不存在"))
+ return
+ }
+
+ embeddingModel, err := h.modelService.GetModelByID(ctx, req.EmbeddingModelID)
+ if err != nil || embeddingModel == nil {
+ logger.Error(ctx, "Embedding model not found", "modelId", req.EmbeddingModelID)
+ c.Error(errors.NewBadRequestError("Embedding模型不存在"))
+ return
+ }
+
+ // 更新知识库的模型ID
+ kb.SummaryModelID = req.LLMModelID
+ kb.EmbeddingModelID = req.EmbeddingModelID
+
+ // 处理可选的Rerank模型
+ if req.RerankModelID != "" {
+ rerankModel, err := h.modelService.GetModelByID(ctx, req.RerankModelID)
+ if err != nil || rerankModel == nil {
+ logger.Warn(ctx, "Rerank model not found", "modelId", req.RerankModelID)
+ } else {
+ kb.RerankModelID = req.RerankModelID
+ }
+ } else {
+ kb.RerankModelID = ""
+ }
+
+ // 处理可选的VLLM模型
+ if req.VLLMModelID != "" {
+ vllmModel, err := h.modelService.GetModelByID(ctx, req.VLLMModelID)
+ if err != nil || vllmModel == nil {
+ logger.Warn(ctx, "VLLM model not found", "modelId", req.VLLMModelID)
+ } else {
+ // 只存储模型ID
+ kb.VLMModelID = req.VLLMModelID
+ }
+ } else {
+ kb.VLMModelID = ""
+ }
+
+ // 更新文档分块配置
+ if req.DocumentSplitting.ChunkSize > 0 {
+ kb.ChunkingConfig.ChunkSize = req.DocumentSplitting.ChunkSize
+ }
+ if req.DocumentSplitting.ChunkOverlap >= 0 {
+ kb.ChunkingConfig.ChunkOverlap = req.DocumentSplitting.ChunkOverlap
+ }
+ if len(req.DocumentSplitting.Separators) > 0 {
+ kb.ChunkingConfig.Separators = req.DocumentSplitting.Separators
+ }
+
+ // 更新多模态配置
+ if req.Multimodal.Enabled {
+ switch strings.ToLower(req.Multimodal.StorageType) {
+ case "cos":
+ if req.Multimodal.COS != nil {
+ kb.StorageConfig = types.StorageConfig{
+ SecretID: req.Multimodal.COS.SecretID,
+ SecretKey: req.Multimodal.COS.SecretKey,
+ Region: req.Multimodal.COS.Region,
+ BucketName: req.Multimodal.COS.BucketName,
+ AppID: req.Multimodal.COS.AppID,
+ PathPrefix: req.Multimodal.COS.PathPrefix,
+ Provider: "cos",
+ }
+ }
+ case "minio":
+ if req.Multimodal.Minio != nil {
+ kb.StorageConfig = types.StorageConfig{
+ BucketName: req.Multimodal.Minio.BucketName,
+ PathPrefix: req.Multimodal.Minio.PathPrefix,
+ Provider: "minio",
+ SecretID: os.Getenv("MINIO_ACCESS_KEY_ID"),
+ SecretKey: os.Getenv("MINIO_SECRET_ACCESS_KEY"),
+ }
+ }
+ }
+ } else {
+ // 多模态未启用时,清空存储配置
+ kb.StorageConfig = types.StorageConfig{}
+ }
+
+ // 更新知识图谱配置
+ if req.NodeExtract.Enabled {
+ // 转换 Nodes 和 Relations 为指针类型
+ nodes := make([]*types.GraphNode, len(req.NodeExtract.Nodes))
+ for i := range req.NodeExtract.Nodes {
+ nodes[i] = &req.NodeExtract.Nodes[i]
+ }
+ relations := make([]*types.GraphRelation, len(req.NodeExtract.Relations))
+ for i := range req.NodeExtract.Relations {
+ relations[i] = &req.NodeExtract.Relations[i]
+ }
+
+ kb.ExtractConfig = &types.ExtractConfig{
+ Text: req.NodeExtract.Text,
+ Tags: req.NodeExtract.Tags,
+ Nodes: nodes,
+ Relations: relations,
+ }
+ } else {
+ kb.ExtractConfig = nil
+ }
+
+ // 保存更新后的知识库
+ if err := h.kbRepository.UpdateKnowledgeBase(ctx, kb); err != nil {
+ logger.Error(ctx, "Failed to update knowledge base", err)
+ c.Error(errors.NewInternalServerError("更新知识库失败: " + err.Error()))
+ return
+ }
+
+ logger.Info(ctx, "KB configuration updated successfully", "kbId", kbIdStr)
+ c.JSON(http.StatusOK, gin.H{
+ "success": true,
+ "message": "配置更新成功",
+ })
+}
+
// InitializeByKB 根据知识库ID执行配置更新
func (h *InitializationHandler) InitializeByKB(c *gin.Context) {
ctx := c.Request.Context()
@@ -989,19 +1190,22 @@ func (h *InitializationHandler) buildConfigResponse(ctx context.Context, models
}
multimodal := config["multimodal"].(map[string]interface{})
multimodal["vlm"] = map[string]interface{}{
- "modelName": model.Name,
- "baseUrl": model.Parameters.BaseURL,
- "apiKey": model.Parameters.APIKey,
- "interfaceType": kb.VLMConfig.InterfaceType,
+ "modelName": model.Name,
+ "baseUrl": model.Parameters.BaseURL,
+ "apiKey": model.Parameters.APIKey,
}
}
}
- // 如果没有VLM模型,设置multimodal为disabled
+ // 判断多模态是否启用:有VLM模型ID或有存储配置
+ hasMultimodal := (kb.VLMModelID != "" || kb.StorageConfig.SecretID != "" || kb.StorageConfig.BucketName != "")
if config["multimodal"] == nil {
config["multimodal"] = map[string]interface{}{
- "enabled": false,
+ "enabled": hasMultimodal,
}
+ } else {
+ // 如果已经设置过 multimodal,更新 enabled 状态
+ config["multimodal"].(map[string]interface{})["enabled"] = hasMultimodal
}
// 如果没有Rerank模型,设置rerank为disabled
diff --git a/internal/handler/tenant.go b/internal/handler/tenant.go
index 8516c9b3..d5b92432 100644
--- a/internal/handler/tenant.go
+++ b/internal/handler/tenant.go
@@ -334,7 +334,7 @@ func (h *TenantHandler) UpdateTenantAgentConfig(c *gin.Context) {
// Validate configuration
if req.Enabled {
- if req.MaxIterations <= 0 || req.MaxIterations > 20 {
+ if req.MaxIterations <= 0 || req.MaxIterations > 30 {
c.Error(errors.NewAgentInvalidMaxIterationsError())
return
}
diff --git a/internal/router/router.go b/internal/router/router.go
index 35754c63..0365b95f 100644
--- a/internal/router/router.go
+++ b/internal/router/router.go
@@ -264,6 +264,7 @@ func RegisterInitializationRoutes(r *gin.RouterGroup, handler *handler.Initializ
// 初始化接口
r.GET("/initialization/config/:kbId", handler.GetCurrentConfigByKB)
r.POST("/initialization/initialize/:kbId", handler.InitializeByKB)
+ r.PUT("/initialization/config/:kbId", handler.UpdateKBConfig) // 新的简化版接口,只传模型ID
// Ollama相关接口
r.GET("/initialization/ollama/status", handler.CheckOllamaStatus)