Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.
Go agentagenticaichatbotdsh-pluginembeddingsevaluationgenerative-aigolangknowledge-basellmmulti-tenantollamaopenaiquestion-answeringragrerankingsemantic-searchvector-searchwiki
fix(models): protect auto-tag model references
hujiaxinfc2c12e8ec08
diff --git a/docs/api/model.md b/docs/api/model.mdindex 9a8b16e7c..a21deecd6 100644--- a/docs/api/model.md+++ b/docs/api/model.md@@ -458,7 +458,7 @@ curl --location --request DELETE 'http://localhost:8080/api/v1/models/8fdc464d-8}```-`bindings` 是稳定的配置类型标识:知识库可能返回 `embedding_model`、`summary_model`、`image_processing_model`、`vlm_model`、`asr_model`、`wiki_synthesis_model`;智能体可能返回 `chat_model`、`rerank_model`、`vlm_model`、`asr_model`、`query_understand_model`、`follow_up_model`;长期记忆可能返回 `embedding_model`、`extract_model`。同一对象的多处引用会合并到一个 `bindings` 数组。`knowledge_bases` / `agents` 最多各返回 50 条;未截断的引用数在 `knowledge_base_total` / `agent_total`。404 表示模型不存在。+`bindings` 是稳定的配置类型标识:知识库可能返回 `embedding_model`、`summary_model`、`image_processing_model`、`vlm_model`、`asr_model`、`wiki_synthesis_model`、`auto_tag_model`;智能体可能返回 `chat_model`、`rerank_model`、`vlm_model`、`asr_model`、`query_understand_model`、`follow_up_model`;长期记忆可能返回 `embedding_model`、`extract_model`。同一对象的多处引用会合并到一个 `bindings` 数组。`knowledge_bases` / `agents` 最多各返回 50 条;未截断的引用数在 `knowledge_base_total` / `agent_total`。404 表示模型不存在。## 参数说明diff --git a/frontend/src/api/model/modelUsage.test.ts b/frontend/src/api/model/modelUsage.test.tsindex bbd195b9e..a6e0c3fc9 100644--- a/frontend/src/api/model/modelUsage.test.ts+++ b/frontend/src/api/model/modelUsage.test.ts@@ -118,6 +118,7 @@ test('maps knowledge-base bindings to the configuration section that owns them',assert.equal(modelUsageKnowledgeBaseSection(['embedding_model']), 'models')assert.equal(modelUsageKnowledgeBaseSection(['summary_model']), 'models')assert.equal(modelUsageKnowledgeBaseSection(['wiki_synthesis_model']), 'models')+ assert.equal(modelUsageKnowledgeBaseSection(['auto_tag_model']), 'models')assert.equal(modelUsageKnowledgeBaseSection(['image_processing_model']), 'multimodal')assert.equal(modelUsageKnowledgeBaseSection(['vlm_model']), 'multimodal')assert.equal(modelUsageKnowledgeBaseSection(['asr_model']), 'asr')diff --git a/frontend/src/api/model/modelUsage.ts b/frontend/src/api/model/modelUsage.tsindex 94bc22716..0850e8e59 100644--- a/frontend/src/api/model/modelUsage.ts+++ b/frontend/src/api/model/modelUsage.ts@@ -7,6 +7,7 @@ export const KNOWN_MODEL_USAGE_BINDINGS = ['vlm_model','asr_model','wiki_synthesis_model',+ 'auto_tag_model','chat_model','rerank_model','query_understand_model',@@ -133,6 +134,7 @@ const knowledgeBaseUsageSections: Partial<Record<KnownModelUsageBinding, Knowledembedding_model: 'models',summary_model: 'models',wiki_synthesis_model: 'models',+ auto_tag_model: 'models',image_processing_model: 'multimodal',vlm_model: 'multimodal',asr_model: 'asr',diff --git a/frontend/src/i18n/locales/en-US.ts b/frontend/src/i18n/locales/en-US.tsindex a7c085186..b546d3b3a 100755--- a/frontend/src/i18n/locales/en-US.ts+++ b/frontend/src/i18n/locales/en-US.ts@@ -4977,6 +4977,7 @@ export default {vlm_model: 'Vision model',asr_model: 'Speech recognition model',wiki_synthesis_model: 'Wiki synthesis model',+ auto_tag_model: 'Auto-tagging model',chat_model: 'Chat model',rerank_model: 'Re-ranking model',query_understand_model: 'Query understanding model',diff --git a/frontend/src/i18n/locales/ja-JP.ts b/frontend/src/i18n/locales/ja-JP.tsindex 4f24fd5f7..c4ab3dc7a 100644--- a/frontend/src/i18n/locales/ja-JP.ts+++ b/frontend/src/i18n/locales/ja-JP.ts@@ -4977,6 +4977,7 @@ export default {vlm_model: '視覚モデル',asr_model: '音声認識モデル',wiki_synthesis_model: 'Wiki生成モデル',+ auto_tag_model: '自動タグ付けモデル',chat_model: 'チャットモデル',rerank_model: 'リランクモデル',query_understand_model: 'クエリ理解モデル',diff --git a/frontend/src/i18n/locales/ko-KR.ts b/frontend/src/i18n/locales/ko-KR.tsindex 58ee3e8f5..7e7f553b5 100755--- a/frontend/src/i18n/locales/ko-KR.ts+++ b/frontend/src/i18n/locales/ko-KR.ts@@ -2207,6 +2207,7 @@ export default {vlm_model: '비전 모델',asr_model: '음성 인식 모델',wiki_synthesis_model: 'Wiki 종합 모델',+ auto_tag_model: '자동 태그 모델',chat_model: '대화 모델',rerank_model: '재정렬 모델',query_understand_model: '질의 이해 모델',diff --git a/frontend/src/i18n/locales/ru-RU.ts b/frontend/src/i18n/locales/ru-RU.tsindex 4192693b3..d1a717d8b 100755--- a/frontend/src/i18n/locales/ru-RU.ts+++ b/frontend/src/i18n/locales/ru-RU.ts@@ -2207,6 +2207,7 @@ export default {vlm_model: 'Модель компьютерного зрения',asr_model: 'Модель распознавания речи',wiki_synthesis_model: 'Модель синтеза Wiki',+ auto_tag_model: 'Модель автоматической разметки',chat_model: 'Диалоговая модель',rerank_model: 'Модель реранжирования',query_understand_model: 'Модель понимания запроса',diff --git a/frontend/src/i18n/locales/zh-CN.ts b/frontend/src/i18n/locales/zh-CN.tsindex 1b8c8516b..d629bc30c 100755--- a/frontend/src/i18n/locales/zh-CN.ts+++ b/frontend/src/i18n/locales/zh-CN.ts@@ -2209,6 +2209,7 @@ export default {vlm_model: '视觉理解模型',asr_model: '语音识别模型',wiki_synthesis_model: 'Wiki 综合模型',+ auto_tag_model: '自动标签模型',chat_model: '对话模型',rerank_model: '重排序模型',query_understand_model: '问题理解模型',diff --git a/internal/application/repository/knowledgebase.go b/internal/application/repository/knowledgebase.goindex b3f279679..ffab77085 100644--- a/internal/application/repository/knowledgebase.go+++ b/internal/application/repository/knowledgebase.go@@ -229,7 +229,7 @@ func (r *knowledgeBaseRepository) ListModelUsages(Model(&types.KnowledgeBase{}).Select("id", "name", "embedding_model_id", "summary_model_id",- "image_processing_config", "vlm_config", "asr_config", "wiki_config",+ "image_processing_config", "vlm_config", "asr_config", "wiki_config", "auto_tag_config",).Where("tenant_id = ?", tenantID)query = scopeKnowledgeBasesByModelID(query, modelID)diff --git a/internal/application/repository/model_usage.go b/internal/application/repository/model_usage.goindex 1e522ecf8..af15966ab 100644--- a/internal/application/repository/model_usage.go+++ b/internal/application/repository/model_usage.go@@ -6,7 +6,7 @@ import ()func knowledgeBaseModelUsageBindings(kb *types.KnowledgeBase, modelID string) []types.ModelUsageBinding {- bindings := make([]types.ModelUsageBinding, 0, 6)+ bindings := make([]types.ModelUsageBinding, 0, 7)if kb.EmbeddingModelID == modelID {bindings = append(bindings, types.ModelUsageBindingEmbeddingModel)}@@ -25,6 +25,9 @@ func knowledgeBaseModelUsageBindings(kb *types.KnowledgeBase, modelID string) []if kb.WikiConfig != nil && kb.WikiConfig.SynthesisModelID == modelID {bindings = append(bindings, types.ModelUsageBindingWikiSynthesisModel)}+ if kb.AutoTagConfig != nil && kb.AutoTagConfig.ModelID == modelID {+ bindings = append(bindings, types.ModelUsageBindingAutoTagModel)+ }return bindings}@@ -61,8 +64,9 @@ func scopeKnowledgeBasesByModelID(db *gorm.DB, modelID string) *gorm.DB {"image_processing_config->>'model_id' = ? OR "+"vlm_config->>'model_id' = ? OR "+"asr_config->>'model_id' = ? OR "+- "wiki_config->>'synthesis_model_id' = ?",- modelID, modelID, modelID, modelID, modelID, modelID,+ "wiki_config->>'synthesis_model_id' = ? OR "++ "auto_tag_config->>'model_id' = ?",+ modelID, modelID, modelID, modelID, modelID, modelID, modelID,)}return db.Where(@@ -70,8 +74,9 @@ func scopeKnowledgeBasesByModelID(db *gorm.DB, modelID string) *gorm.DB {"json_extract(image_processing_config, '$.model_id') = ? OR "+"json_extract(vlm_config, '$.model_id') = ? OR "+"json_extract(asr_config, '$.model_id') = ? OR "+- "json_extract(wiki_config, '$.synthesis_model_id') = ?",- modelID, modelID, modelID, modelID, modelID, modelID,+ "json_extract(wiki_config, '$.synthesis_model_id') = ? OR "++ "json_extract(auto_tag_config, '$.model_id') = ?",+ modelID, modelID, modelID, modelID, modelID, modelID, modelID,)}diff --git a/internal/application/repository/model_usage_test.go b/internal/application/repository/model_usage_test.goindex 8698a17ad..597af4ff5 100644--- a/internal/application/repository/model_usage_test.go+++ b/internal/application/repository/model_usage_test.go@@ -83,6 +83,7 @@ func TestListModelUsages_KnowledgeBase(t *testing.T) {allBindings.VLMConfig = types.VLMConfig{Enabled: true, ModelID: modelID}allBindings.ASRConfig = types.ASRConfig{Enabled: true, ModelID: modelID}allBindings.WikiConfig = &types.WikiConfig{SynthesisModelID: modelID}+ allBindings.AutoTagConfig = &types.AutoTagConfig{Enabled: true, ModelID: modelID}require.NoError(t, db.Create(allBindings).Error)vlmOnly := makeKB(nil)@@ -115,9 +116,25 @@ func TestListModelUsages_KnowledgeBase(t *testing.T) {types.ModelUsageBindingVLMModel,types.ModelUsageBindingASRModel,types.ModelUsageBindingWikiSynthesisModel,+ types.ModelUsageBindingAutoTagModel,}, usages[1].Bindings)}+func TestCountByModelID_KnowledgeBaseAutoTag(t *testing.T) {+ ctx := context.Background()+ db := setupModelUsageTestDB(t)+ repo := NewKnowledgeBaseRepository(db)+ modelID := "auto-tag-model"++ kb := makeKB(nil)+ kb.AutoTagConfig = &types.AutoTagConfig{Enabled: true, ModelID: modelID}+ require.NoError(t, db.Create(kb).Error)++ count, err := repo.CountByModelID(ctx, 1, modelID)+ require.NoError(t, err)+ assert.Equal(t, int64(1), count)+}+func TestListModelUsages_KnowledgeBaseRespectsLimit(t *testing.T) {ctx := context.Background()db := setupModelUsageTestDB(t)diff --git a/internal/types/model.go b/internal/types/model.goindex bbacaae15..80f88ffcd 100644--- a/internal/types/model.go+++ b/internal/types/model.go@@ -44,6 +44,7 @@ const (ModelUsageBindingVLMModel ModelUsageBinding = "vlm_model"ModelUsageBindingASRModel ModelUsageBinding = "asr_model"ModelUsageBindingWikiSynthesisModel ModelUsageBinding = "wiki_synthesis_model"+ ModelUsageBindingAutoTagModel ModelUsageBinding = "auto_tag_model"ModelUsageBindingChatModel ModelUsageBinding = "chat_model"ModelUsageBindingRerankModel ModelUsageBinding = "rerank_model"ModelUsageBindingQueryUnderstandModel ModelUsageBinding = "query_understand_model"diff --git a/website-docs/04-api/02-api-model-system.md b/website-docs/04-api/02-api-model-system.mdindex f83234472..831a6d980 100644--- a/website-docs/04-api/02-api-model-system.md+++ b/website-docs/04-api/02-api-model-system.md@@ -107,7 +107,7 @@ curl -X PUT $BASE/api/v1/models/m-1 -H "Authorization: Bearer $TOKEN" \}```-知识库绑定值:`embedding_model`、`summary_model`、`image_processing_model`、`vlm_model`、`asr_model`、`wiki_synthesis_model`;智能体绑定值:`chat_model`、`rerank_model`、`vlm_model`、`asr_model`、`query_understand_model`、`follow_up_model`;长期记忆绑定值:`embedding_model`、`extract_model`。详情包含对象 `id`、`name`、合并后的 `bindings`,以及 `knowledge_base_total` / `agent_total`。列表最多各 50 条,删除守卫以总数为准。+知识库绑定值:`embedding_model`、`summary_model`、`image_processing_model`、`vlm_model`、`asr_model`、`wiki_synthesis_model`、`auto_tag_model`;智能体绑定值:`chat_model`、`rerank_model`、`vlm_model`、`asr_model`、`query_understand_model`、`follow_up_model`;长期记忆绑定值:`embedding_model`、`extract_model`。详情包含对象 `id`、`name`、合并后的 `bindings`,以及 `knowledge_base_total` / `agent_total`。列表最多各 50 条,删除守卫以总数为准。```bashcurl -X DELETE $BASE/api/v1/models/m-1 -H "Authorization: Bearer $TOKEN"