From cd053194a905a9b579ef79bda21d420e019ed40e Mon Sep 17 00:00:00 2001 From: AskaEth Date: Mon, 22 Jun 2026 20:26:28 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20RAG=20IngestDirectory=20=E8=B7=B3?= =?UTF-8?q?=E8=BF=87=20persona.md=20=E5=92=8C=20=5Findex.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 避免人格文档在RAG检索中重复出现,persona.md已通过系统提示注入。 Co-Authored-By: Claude --- backend/ai-core/internal/rag/knowledge_store.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backend/ai-core/internal/rag/knowledge_store.go b/backend/ai-core/internal/rag/knowledge_store.go index cf7e16a..13be8a8 100644 --- a/backend/ai-core/internal/rag/knowledge_store.go +++ b/backend/ai-core/internal/rag/knowledge_store.go @@ -64,6 +64,12 @@ func (ks *KnowledgeStore) IngestDirectory(ctx context.Context) (int, error) { if !isSupportedFile(ext) { return nil } + // Skip files that are injected elsewhere (persona.md → system prompt, + // _index.md → metadata only, not story content). + base := filepath.Base(path) + if base == "persona.md" || base == "_index.md" { + return nil + } n, err := ks.IngestFile(ctx, path) if err != nil { return fmt.Errorf("ingest %s: %w", path, err)