RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
Delete toc_enhance (a.k.a. Page Index), it has been moved into knowledge compilation (#21406)
Wang Qi67137224ae1d
diff --git a/internal/agent/component/retrieval_params_test.go b/internal/agent/component/retrieval_params_test.goindex f1736e1f96..159821f6cb 100644--- a/internal/agent/component/retrieval_params_test.go+++ b/internal/agent/component/retrieval_params_test.go@@ -40,7 +40,6 @@ func TestRetrievalComponentAppliesAdvancedNodeParams(t *testing.T) {"dataset_ids": []any{"dataset-1"},"memory_ids": []any{"memory-1", "memory-2"},"cross_languages": []any{"English", "Chinese", "Spanish"},- "toc_enhance": true,"use_kg": true,"meta_data_filter": map[string]any{"method": "manual"},"retrieval_from": "memory",@@ -56,9 +55,6 @@ func TestRetrievalComponentAppliesAdvancedNodeParams(t *testing.T) {if got := merged["cross_languages"]; !reflect.DeepEqual(got, []string{"English", "Chinese", "Spanish"}) {t.Errorf("cross_languages = %#v", got)}- if got := merged["toc_enhance"]; got != true {- t.Errorf("toc_enhance = %#v", got)- }if got := merged["use_kg"]; got != true {t.Errorf("use_kg = %#v", got)}@@ -80,7 +76,6 @@ func TestRetrievalComponentForwardsAdvancedNodeParams(t *testing.T) {"dataset_ids": []any{"dataset-1"},"memory_ids": []any{"memory-1"},"cross_languages": []any{"English", "Chinese", "Spanish"},- "toc_enhance": true,"use_kg": false,"meta_data_filter": map[string]any{"method": "manual"},"retrieval_from": "dataset",@@ -100,9 +95,6 @@ func TestRetrievalComponentForwardsAdvancedNodeParams(t *testing.T) {if !reflect.DeepEqual(request.CrossLanguages, []string{"English", "Chinese", "Spanish"}) {t.Errorf("CrossLanguages = %#v", request.CrossLanguages)}- if !request.TOCEnhance {- t.Error("TOCEnhance = false")- }if request.UseKG {t.Error("UseKG = true")}diff --git a/internal/agent/component/universe_a_wrappers.go b/internal/agent/component/universe_a_wrappers.goindex b6b9932173..81ccd8cf4d 100644--- a/internal/agent/component/universe_a_wrappers.go+++ b/internal/agent/component/universe_a_wrappers.go@@ -80,7 +80,6 @@ type retrievalParams struct {RerankID stringEmptyResponse stringCrossLanguages []string- TOCEnhance boolUseKG boolMetaDataFilter map[string]anyRetrievalFrom string@@ -137,9 +136,6 @@ func parseRetrievalParams(params map[string]any) retrievalParams {out.EmptyResponse = v}out.CrossLanguages = toStringSlice(params["cross_languages"])- if v, ok := params["toc_enhance"].(bool); ok {- out.TOCEnhance = v- }if v, ok := params["use_kg"].(bool); ok {out.UseKG = v}@@ -366,9 +362,6 @@ func (c *retrievalComponent) applyDefaults(inputs map[string]any) map[string]anyif _, ok := out["cross_languages"]; !ok && len(c.params.CrossLanguages) > 0 {out["cross_languages"] = append([]string(nil), c.params.CrossLanguages...)}- if _, ok := out["toc_enhance"]; !ok && c.params.TOCEnhance {- out["toc_enhance"] = true- }if _, ok := out["use_kg"]; !ok && c.params.UseKG {out["use_kg"] = true}diff --git a/internal/agent/dsl/testdata/all.json b/internal/agent/dsl/testdata/all.jsonindex 68a943e55d..60d76f71a7 100644--- a/internal/agent/dsl/testdata/all.json+++ b/internal/agent/dsl/testdata/all.json@@ -523,7 +523,6 @@"rerank_id": "","retrieval_from": "dataset","similarity_threshold": 0.2,- "toc_enhance": false,"top_k": 512,"top_n": 5,"use_kg": false@@ -3308,7 +3307,6 @@"rerank_id": "","retrieval_from": "dataset","similarity_threshold": 0.2,- "toc_enhance": false,"top_k": 512,"top_n": 5,"use_kg": falsediff --git a/internal/agent/retrievalbridge/enhancer.go b/internal/agent/retrievalbridge/enhancer.goindex 4b685daae8..eda89aae3c 100644--- a/internal/agent/retrievalbridge/enhancer.go+++ b/internal/agent/retrievalbridge/enhancer.go@@ -104,38 +104,6 @@ func (e *Enhancer) LabelQuestion(return e.metadataSvc.LabelQuestion(ctx, question, kbs)}-// EnhanceTOC adds or boosts chunks selected through the document table of-// contents. The service enhancer mutates the supplied kbinfos map.-func (e *Enhancer) EnhanceTOC(- ctx context.Context,- chatModel *modelModule.ChatModel,- tenantIDs, kbIDs []string,- question string,- topN int,- chunks []map[string]any,-) ([]map[string]any, error) {- if e == nil {- return nil, fmt.Errorf("retrieval enhancer is not configured")- }- kbinfos := map[string]any{"chunks": chunks}- enhancer := service.NewTOCEnhancer(- e.docEngine,- chatModel,- tenantIDs,- kbIDs,- question,- topN,- )- if _, err := enhancer.Enhance(ctx, kbinfos); err != nil {- return nil, err- }- enhanced, ok := kbinfos["chunks"].([]map[string]any)- if !ok {- return nil, fmt.Errorf("TOC enhancer returned invalid chunks type %T", kbinfos["chunks"])- }- return enhanced, nil-}-// RetrieveByChildren aggregates child chunks under their parent chunks.func (e *Enhancer) RetrieveByChildren(ctx context.Context,diff --git a/internal/agent/runtime/retrieval.go b/internal/agent/runtime/retrieval.goindex ebf87355cf..27bc496fad 100644--- a/internal/agent/runtime/retrieval.go+++ b/internal/agent/runtime/retrieval.go@@ -76,7 +76,6 @@ type RetrievalRequest struct {AllowDenseFallback *boolRerankID stringCrossLanguages []string- TOCEnhance boolMetaDataFilter map[string]anyRetrievalFrom string// DocScope restricts retrieval to a set of document ids (the doc_id listdiff --git a/internal/agent/templates/user_interaction.json b/internal/agent/templates/user_interaction.jsonindex da94c6894b..e06595572b 100644--- a/internal/agent/templates/user_interaction.json+++ b/internal/agent/templates/user_interaction.json@@ -127,7 +127,6 @@},"rerank_id": "","similarity_threshold": 0.2,- "toc_enhance": false,"rerank_candidates_count": 64,"top_n": 8,"use_kg": false@@ -438,7 +437,6 @@},"rerank_id": "","similarity_threshold": 0.2,- "toc_enhance": false,"rerank_candidates_count": 64,"top_n": 8,"use_kg": falsediff --git a/internal/agent/tool/registry.go b/internal/agent/tool/registry.goindex 07f1d1a0d9..0affe02dea 100644--- a/internal/agent/tool/registry.go+++ b/internal/agent/tool/registry.go@@ -409,7 +409,7 @@ func buildRetrievalTool(params map[string]any) (einotool.BaseTool, error) {switch key {case "dataset_ids", "kb_ids", "top_n", "rerank_candidates_count", "top_k", "similarity_threshold","keywords_similarity_weight", "use_kg", "rerank_id", "empty_response",- "toc_enhance", "meta_data_filter", "retrieval_from", "memory_ids",+ "meta_data_filter", "retrieval_from", "memory_ids","kb_vars", "cross_languages", "function_name", "description", "meta","inputs", "outputs", "user_id":default:@@ -458,9 +458,6 @@ func buildRetrievalTool(params map[string]any) (einotool.BaseTool, error) {if v, ok := boolParam(params, "use_kg"); ok {defaults.UseKG = v}- if v, ok := boolParam(params, "toc_enhance"); ok {- defaults.TOCEnhance = v- }if v, ok := floatParam(params, "similarity_threshold"); ok {defaults.SimilarityThreshold = &v}diff --git a/internal/agent/tool/retrieval.go b/internal/agent/tool/retrieval.goindex 9b5a481ac1..3edda0a4db 100644--- a/internal/agent/tool/retrieval.go+++ b/internal/agent/tool/retrieval.go@@ -61,7 +61,6 @@ type retrievalArgs struct {SimilarityThreshold *float64 `json:"similarity_threshold,omitempty"`RerankID string `json:"rerank_id,omitempty"`CrossLanguages []string `json:"cross_languages,omitempty"`- TOCEnhance bool `json:"toc_enhance,omitempty"`MetaDataFilter map[string]any `json:"meta_data_filter,omitempty"`RetrievalFrom string `json:"retrieval_from,omitempty"`EmptyResponse string `json:"empty_response,omitempty"`@@ -210,7 +209,6 @@ func (r *RetrievalTool) InvokableRun(ctx context.Context, argumentsInJSON stringAllowDenseFallback: new(false),RerankID: args.RerankID,CrossLanguages: append([]string(nil), args.CrossLanguages...),- TOCEnhance: args.TOCEnhance,MetaDataFilter: cloneStringAnyMap(args.MetaDataFilter),RetrievalFrom: args.RetrievalFrom,UserID: args.UserID,@@ -315,7 +313,6 @@ func (r *RetrievalTool) mergeDefaults(args retrievalArgs) retrievalArgs {if args.RetrievalFrom == "" && len(args.MemoryIDs) > 0 {args.RetrievalFrom = "memory"}- args.TOCEnhance = args.TOCEnhance || r.defaults.TOCEnhanceargs.UseKG = args.UseKG || r.defaults.UseKGreturn args}diff --git a/internal/agent/tool/retrieval_nlp.go b/internal/agent/tool/retrieval_nlp.goindex 03be424622..f2b63209d2 100644--- a/internal/agent/tool/retrieval_nlp.go+++ b/internal/agent/tool/retrieval_nlp.go@@ -130,14 +130,6 @@ type retrievalEnhancer interface {question string,kbs []*entity.Knowledgebase,) map[string]float64- EnhanceTOC(- ctx context.Context,- chatModel *modelModule.ChatModel,- tenantIDs, kbIDs []string,- question string,- topN int,- chunks []map[string]any,- ) ([]map[string]any, error)RetrieveByChildren(ctx context.Context,chunks []map[string]any,@@ -300,24 +292,6 @@ func (a *NLPRetrievalAdapter) Search(ctx context.Context, db *gorm.DB, req Retrireturn []RetrievalChunk{}, nil}rawChunks := res.Chunks- if req.TOCEnhance {- if a.enhancer == nil {- return nil, fmt.Errorf("retrieval: TOC enhancement service is not configured")- }- rawChunks, err = a.enhancer.EnhanceTOC(- ctx,- chatModel,- datasets.tenantIDs,- datasets.kbIDs,- query,- topN,- rawChunks,- )- if err != nil {- common.Warn("agent retrieval: TOC enhancement failed; using retrieval results", zap.Error(err))- rawChunks = res.Chunks- }- }if a.enhancer != nil {rawChunks = a.enhancer.RetrieveByChildren(ctx, rawChunks, datasets.tenantIDs)}@@ -531,7 +505,7 @@ func (a *NLPRetrievalAdapter) resolveChatModel(tenantID string,) (*modelModule.ChatModel, error) {method, _ := req.MetaDataFilter["method"].(string)- needsChatModel := req.TOCEnhance || method == "auto" || method == "semi_auto"+ needsChatModel := method == "auto" || method == "semi_auto"if !needsChatModel {return nil, nil}diff --git a/internal/agent/tool/retrieval_test.go b/internal/agent/tool/retrieval_test.goindex e86c024b64..c699111bd4 100644--- a/internal/agent/tool/retrieval_test.go+++ b/internal/agent/tool/retrieval_test.go@@ -275,7 +275,6 @@ func TestRetrieval_UsesNodeParamsAsDefaults(t *testing.T) {"similarity_threshold": 0.42,"rerank_id": "rerank@provider","cross_languages": []any{"English", "Chinese"},- "toc_enhance": true,"meta_data_filter": map[string]any{"method": "manual"},})if err != nil {@@ -313,7 +312,7 @@ func TestRetrieval_UsesNodeParamsAsDefaults(t *testing.T) {if len(svc.req.CrossLanguages) != 2 || svc.req.CrossLanguages[1] != "Chinese" {t.Fatalf("CrossLanguages=%#v", svc.req.CrossLanguages)}- if !svc.req.TOCEnhance || svc.req.MetaDataFilter["method"] != "manual" {+ if svc.req.MetaDataFilter["method"] != "manual" {t.Fatalf("enhancement request=%#v", svc.req)}}@@ -349,7 +348,6 @@ func TestRetrieval_ParsesEnhancementNodeParams(t *testing.T) {built, err := BuildByName("retrieval", map[string]any{"rerank_id": "rerank-1",- "toc_enhance": true,"meta_data_filter": map[string]any{"method": "manual"},"empty_response": "empty","retrieval_from": "dataset",@@ -364,7 +362,7 @@ func TestRetrieval_ParsesEnhancementNodeParams(t *testing.T) {if !ok {t.Fatalf("BuildByName(retrieval) returned %T, want *RetrievalTool", built)}- if rt.defaults.RerankID != "rerank-1" || !rt.defaults.TOCEnhance {+ if rt.defaults.RerankID != "rerank-1" {t.Fatalf("enhancement defaults were not parsed: %#v", rt.defaults)}if len(rt.defaults.CrossLanguages) != 1 || rt.defaults.CrossLanguages[0] != "English" {diff --git a/internal/service/ask_service_test.go b/internal/service/ask_service_test.goindex 40a434f007..ee36610644 100644--- a/internal/service/ask_service_test.go+++ b/internal/service/ask_service_test.go@@ -420,3 +420,36 @@ func TestAskService_LLMErrorValueIsRealError(t *testing.T) {t.Errorf("expected real sync error surfaced, got %q", deltas[0].Value)}}++func TestToFloat64Slice(t *testing.T) {+ tests := []struct {+ name string+ v interface{}+ want []float64+ wantOk bool+ }{+ {"valid", []interface{}{1.0, 2.5, 3.0}, []float64{1.0, 2.5, 3.0}, true},+ {"empty", []interface{}{}, []float64{}, true},+ {"wrong type", "not a slice", nil, false},+ {"non-float element", []interface{}{1.0, "x"}, nil, false},+ {"nil", nil, nil, false},+ }+ for _, tt := range tests {+ t.Run(tt.name, func(t *testing.T) {+ got := toFloat64Slice(tt.v)+ if (got != nil) != tt.wantOk {+ t.Errorf("toFloat64Slice() ok = %v, want %v", got != nil, tt.wantOk)+ return+ }+ if len(got) != len(tt.want) {+ t.Errorf("toFloat64Slice() len = %d, want %d", len(got), len(tt.want))+ return+ }+ for i := range got {+ if got[i] != tt.want[i] {+ t.Errorf("toFloat64Slice()[%d] = %v, want %v", i, got[i], tt.want[i])+ }+ }+ })+ }+}diff --git a/internal/service/chat_pipeline.go b/internal/service/chat_pipeline.goindex 41e72cea48..46e5f28e11 100644--- a/internal/service/chat_pipeline.go+++ b/internal/service/chat_pipeline.go@@ -198,7 +198,7 @@ type ThinkEvent struct {// │ → sufficiencyCheck → multiQueriesGen → recurse│// │ NO → Standard vector retrieval │// │ vector/hybrid search → rerank → │-// │ TOC enhance → child chunk retrieval → │+// │ child chunk retrieval → │// │ Web search → KG retrieval (prepend) │// │ │// │ enrichChunksWithMetadata (doc metadata) │@@ -706,7 +706,6 @@ func (s *ChatPipelineService) AsyncChat(}// When hasKnowledgeParam is true, runs standard retrieval, then:- // - TOC enhancement (if toc_enhance is enabled).// - Child chunk retrieval.// - Web search provider (if internet is enabled).// - Knowledge graph retrieval (if use_kg is enabled).@@ -714,7 +713,7 @@ func (s *ChatPipelineService) AsyncChat(// When false, the entire block is skipped.if hasKnowledgeParam {// Regular RAG mirroring Python's async_chat — native docStore- // retrieval, then the TOC / child chunk / web search / KG+ // retrieval, then the child chunk / web search / KG// enhancements below.searchQuestion := strings.Join(questions, " ")if embModel != nil {@@ -785,23 +784,6 @@ func (s *ChatPipelineService) AsyncChat(}}- // TOC enhancement- if useTOC, _ := chat.PromptConfig["toc_enhance"].(bool); useTOC && chatModel != nil && len(kbs) > 0 {- enhancer := NewTOCEnhancer(- engine.Get(),- chatModel,- kbTenantIDStrings(kbs),- kbIDStrings(kbs),- searchQuestion,- int(chat.TopN),- )- if added, err := enhancer.Enhance(ctx, kbinfos); err != nil {- common.Warn("TOC enhance failed", zap.Error(err))- } else if added > 0 {- common.Debug("TOC enhance added chunks", zap.Int("added", added))- }- }-// Child chunk retrievalif existingChunks, ok := kbinfos["chunks"].([]map[string]interface{}); ok && len(existingChunks) > 0 {kbinfos["chunks"] = nlp.RetrievalByChildren(existingChunks, kbTenantIDStrings(kbs), engine.Get(), ctx)diff --git a/internal/service/chat_pipeline_test.go b/internal/service/chat_pipeline_test.goindex afb5150555..1737ec3d22 100644--- a/internal/service/chat_pipeline_test.go+++ b/internal/service/chat_pipeline_test.go@@ -49,7 +49,6 @@ func dialForTest(llmid string) *entity.Chat {"refine_multiturn": false,"keyword": false,"use_kg": false,- "toc_enhance": false,},KBIDs: []interface{}{},VectorSimilarityWeight: 0.3,diff --git a/internal/service/chunk_types_test.go b/internal/service/chunk_types_test.goindex 356480f62f..a14218a61a 100644--- a/internal/service/chunk_types_test.go+++ b/internal/service/chunk_types_test.go@@ -300,3 +300,24 @@ func TestGetPageSize_Valid(t *testing.T) {t.Errorf("CoalesceInt(&50, 20) = %d, want 50", got)}}++func TestGetFloat(t *testing.T) {+ tests := []struct {+ name string+ m map[string]interface{}+ key string+ want float64+ }{+ {"present", map[string]interface{}{"score": 3.5}, "score", 3.5},+ {"missing", map[string]interface{}{}, "score", 0},+ {"wrong type", map[string]interface{}{"score": "3.5"}, "score", 0},+ {"nil value", map[string]interface{}{"score": nil}, "score", 0},+ }+ for _, tt := range tests {+ t.Run(tt.name, func(t *testing.T) {+ if got := getFloat(tt.m, tt.key); got != tt.want {+ t.Errorf("getFloat() = %v, want %v", got, tt.want)+ }+ })+ }+}diff --git a/internal/service/toc_enhancer.go b/internal/service/toc_enhancer.godeleted file mode 100644index b7f72b937c..0000000000--- a/internal/service/toc_enhancer.go+++ /dev/null@@ -1,600 +0,0 @@-//-// Copyright 2026 The InfiniFlow Authors. All Rights Reserved.-//-// Licensed under the Apache License, Version 2.0 (the "License");-// you may not use this file except in compliance with the License.-// You may obtain a copy of the License at-//-// http://www.apache.org/licenses/LICENSE-2.0-//-// Unless required by applicable law or agreed to in writing, software-// distributed under the License is distributed on an "AS IS" BASIS,-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.-// See the License for the specific language governing permissions and-// limitations under the License.-//--package service--import (- "context"- "encoding/json"- "fmt"- "sort"- "strconv"- "strings"-- "ragflow/internal/common"- "ragflow/internal/engine"- "ragflow/internal/engine/types"- modelModule "ragflow/internal/entity/models"-- "github.com/kaptinlin/jsonrepair"- "go.uber.org/zap"-)--// flexInt is an int that can unmarshal from either a JSON number or a JSON string.-// This handles the mismatch between DB-stored TOC entries (level as string "1")-// and LLM-emitted scores (level as number 1).-type flexInt int--func (f *flexInt) UnmarshalJSON(data []byte) error {- var i int- if err := json.Unmarshal(data, &i); err == nil {- *f = flexInt(i)- return nil- }- var s string- if err := json.Unmarshal(data, &s); err == nil {- i, err := strconv.Atoi(s)- if err != nil {- return fmt.Errorf("flexInt: invalid string %q: %w", s, err)- }- *f = flexInt(i)- return nil- }- return fmt.Errorf("flexInt: cannot unmarshal %s", string(data))-}--func (f flexInt) MarshalJSON() ([]byte, error) {- return json.Marshal(int(f))-}--// tocEntry holds a single entry from a document's TOC chunk.-// Note: level is stored as a string in JSON (e.g. "1"), so we use flexInt.-type tocEntry struct {- Level flexInt `json:"level"`- Title string `json:"title"`- IDs []string `json:"ids,omitempty"`-}--// tocRelevanceScore is the LLM-emitted score for a single TOC entry.-type tocRelevanceScore struct {- Level int `json:"level"`- Title string `json:"title"`- Score float64 `json:"score"`-}--const tocRelevanceSystemPrompt = `You are an expert logical reasoning assistant specializing in hierarchical Table of Contents (TOC) relevance evaluation.--## GOAL-You will receive:-1. A JSON list of TOC items, each with fields:- ` + "```" + `json- {- "level": <integer>, // e.g., 1, 2, 3- "title": <string> // section title-}--func asMap(v interface{}) map[string]interface{} {- if m, ok := v.(map[string]interface{}); ok {- return m- }- return nil-}- ` + "```" + `-2. A user query (natural language question).--You must assign a **relevance score** (integer) to every TOC entry, based on how related its ` + "`" + `title` + "`" + ` is to the ` + "`" + `query` + "`" + `.-------## RULES--### Scoring System-- 5 → highly relevant (directly answers or matches the query intent)-- 3 → somewhat related (same topic or partially overlaps)-- 1 → weakly related (vague or tangential)-- 0 → no clear relation-- -1 → explicitly irrelevant or contradictory--### Hierarchy Traversal-- The TOC is hierarchical: smaller ` + "`" + `level` + "`" + ` = higher layer (e.g., level 1 is top-level, level 2 is a subsection).-- You must traverse in **hierarchical order** — interpret the structure based on levels (1 > 2 > 3).-- If a high-level item (level 1) is strongly related (score 5), its child items (level 2, 3) are likely relevant too.-- If a high-level item is unrelated (-1 or 0), its deeper children are usually less relevant unless the titles clearly match the query.-- Lower (deeper) levels provide more specific content; prefer assigning higher scores if they directly match the query.--### Output Format-Return a **JSON array**, preserving the input order but adding a new key ` + "`" + `"score"` + "`" + `:--` + "```" + `json-[- {"level": 1, "title": "Introduction", "score": 0},- {"level": 2, "title": "Definition of Sustainability", "score": 5}-]-` + "```" + `--### Constraints-- Output **only the JSON array** — no explanations or reasoning text.--### EXAMPLES--#### Example 1-Input TOC:-[- {"level": 1, "title": "Machine Learning Overview"},- {"level": 2, "title": "Supervised Learning"},- {"level": 2, "title": "Unsupervised Learning"},- {"level": 3, "title": "Applications of Deep Learning"}-]--Query:-"How is deep learning used in image classification?"--Output:-[- {"level": 1, "title": "Machine Learning Overview", "score": 3},- {"level": 2, "title": "Supervised Learning", "score": 3},- {"level": 2, "title": "Unsupervised Learning", "score": 0},- {"level": 3, "title": "Applications of Deep Learning", "score": 5}-]-------#### Example 2-Input TOC:-[- {"level": 1, "title": "Marketing Basics"},- {"level": 2, "title": "Consumer Behavior"},- {"level": 2, "title": "Digital Marketing"},- {"level": 3, "title": "Social Media Campaigns"},- {"level": 3, "title": "SEO Optimization"}-]--Query:-"What are the best online marketing methods?"--Output:-[- {"level": 1, "title": "Marketing Basics", "score": 3},- {"level": 2, "title": "Consumer Behavior", "score": 1},- {"level": 2, "title": "Digital Marketing", "score": 5},- {"level": 3, "title": "Social Media Campaigns", "score": 5},- {"level": 3, "title": "SEO Optimization", "score": 5}-]-------#### Example 3-Input TOC:-[- {"level": 1, "title": "Physics Overview"},- {"level": 2, "title": "Classical Mechanics"},- {"level": 3, "title": "Newton's Laws"},- {"level": 2, "title": "Thermodynamics"},- {"level": 3, "title": "Entropy and Heat Transfer"}-]--Query:-"What is entropy?"--Output:-[- {"level": 1, "title": "Physics Overview", "score": 3},- {"level": 2, "title": "Classical Mechanics", "score": 0},- {"level": 3, "title": "Newton's Laws", "score": -1},- {"level": 2, "title": "Thermodynamics", "score": 5},- {"level": 3, "title": "Entropy and Heat Transfer", "score": 5}-]-`--const tocRelevanceUserTemplate = `You will now receive:-1. A JSON list of TOC items (each with ` + "`" + `level` + "`" + ` and ` + "`" + `title` + "`" + `)-2. A user query string.--Traverse the TOC hierarchically based on level numbers and assign scores (5,3,1,0,-1) according to the rules in the system prompt.-Output **only** the JSON array with the added ` + "`" + `"score"` + "`" + ` field.-------**Input TOC:**-%s--**Query:**-%s-`--// TOCEnhancer picks the top document, fetches its TOC, scores entries via LLM,-// then merges matching chunks into kbinfos["chunks"].-type TOCEnhancer struct {- docEngine engine.DocEngine- chatModel *modelModule.ChatModel- tenantIDs []string- kbIDs []string- question string- topN int-}--// NewTOCEnhancer constructs a TOCEnhancer.-func NewTOCEnhancer(- docEngine engine.DocEngine,- chatModel *modelModule.ChatModel,- tenantIDs []string,- kbIDs []string,- question string,- topN int,-) *TOCEnhancer {- return &TOCEnhancer{- docEngine: docEngine,- chatModel: chatModel,- tenantIDs: tenantIDs,- kbIDs: kbIDs,- question: question,- topN: topN,- }-}--// Enhance mutates kbinfos["chunks"] by appending/boosting TOC-relevant chunks.-func (e *TOCEnhancer) Enhance(ctx context.Context, kbinfos map[string]interface{}) (int, error) {- if e == nil || e.chatModel == nil {- return 0, nil- }- if kbinfos == nil {- return 0, nil- }- if e.docEngine == nil {- e.docEngine = engine.Get()- }- if e.docEngine == nil {- return 0, nil- }- chunksRaw, ok := kbinfos["chunks"].([]map[string]interface{})- if !ok || len(chunksRaw) == 0 {- return 0, nil- }-- common.Debug("TOC enhancer: started",- zap.Int("chunk_count", len(chunksRaw)),- zap.String("question", e.question))-- topDocID, docID2KBID := topDocFromChunks(chunksRaw)- if topDocID == "" {- return 0, nil- }-- filter := map[string]interface{}{- "doc_id": []string{topDocID},- "toc_kwd": "toc",- }- indexNames := make([]string, 0, len(e.tenantIDs))- for _, tid := range e.tenantIDs {- indexNames = append(indexNames, getIndexName(tid))- }- tocResp, err := e.docEngine.Search(ctx, &types.SearchRequest{- IndexNames: indexNames,- KbIDs: e.kbIDs,- Filter: filter,- SelectFields: []string{"content_with_weight"},- Offset: 0,- Limit: 128,- })- if err != nil || tocResp == nil || len(tocResp.Chunks) == 0 {- common.Debug("TOC enhancer: no TOC chunks found for top doc",- zap.String("doc_id", topDocID))- return 0, nil- }-- entries := parseTOCEntries(tocResp.Chunks)- if len(entries) == 0 {- common.Debug("TOC enhancer: TOC content did not parse to entries",- zap.String("doc_id", topDocID))- return 0, nil- }-- scores, err := e.scoreEntries(ctx, entries, e.topN*2)- if err != nil {- common.Warn("TOC enhancer: LLM scoring failed",- zap.Error(err), zap.String("doc_id", topDocID))- return 0, nil- }- if len(scores) == 0 {- return 0, nil- }-- id2idx := map[string]int{}- for i, cm := range chunksRaw {- if cid, ok := cm["chunk_id"].(string); ok && cid != "" {- id2idx[cid] = i- }- }- added := 0- kbID := docID2KBID[topDocID]- for _, sc := range scores {- cid := sc.Title- if idx, exists := id2idx[cid]; exists {- boostSimilarity(chunksRaw[idx], sc.Score)- } else {- fresh, fetchErr := e.fetchChunk(ctx, cid, topDocID, kbID)- if fetchErr != nil || fresh == nil {- continue- }- d := map[string]interface{}{- "chunk_id": cid,- "content_ltks": getString(fresh, "content_ltks"),- "content_with_weight": getString(fresh, "content_with_weight"),- "doc_id": topDocID,- "docnm_kwd": getStringDef(fresh, "docnm_kwd", ""),- "kb_id": getStringDef(fresh, "kb_id", kbID),- "important_kwd": getSlice(fresh, "important_kwd"),- "image_id": getStringDef(fresh, "img_id", getStringDef(fresh, "image_id", "")),- "similarity": sc.Score,- "vector_similarity": sc.Score,- "term_similarity": sc.Score,- "vector": []float64{},- "positions": getSlice(fresh, "position_int"),- "doc_type_kwd": getStringDef(fresh, "doc_type_kwd", ""),- }- for k, v := range fresh {- if len(k) >= 4 && k[len(k)-4:] == "_vec" {- if vec := toFloat64Slice(v); vec != nil {- d["vector"] = vec- break- }- }- }- chunksRaw = append(chunksRaw, d)- id2idx[cid] = len(chunksRaw) - 1- added++- }- }-- kbinfos["chunks"] = sortAndTrimChunks(chunksRaw, e.topN)- common.Debug("TOC enhancer: finished",- zap.Int("added_chunks", added),- zap.Int("total_chunks", len(chunksRaw)),- zap.String("doc_id", topDocID))- return added, nil-}--// topDocFromChunks picks the doc_id with the highest accumulated similarity.-func topDocFromChunks(chunks []map[string]interface{}) (string, map[string]string) {- ranks := map[string]float64{}- docID2KBID := map[string]string{}- for _, cm := range chunks {- docID, _ := cm["doc_id"].(string)- kbID, _ := cm["kb_id"].(string)- sim, _ := cm["similarity"].(float64)- if docID == "" {- continue- }- ranks[docID] += sim- if _, seen := docID2KBID[docID]; !seen && kbID != "" {- docID2KBID[docID] = kbID- }- }- if len(ranks) == 0 {- return "", nil- }- type kv struct {- k string- v float64- }- pairs := make([]kv, 0, len(ranks))- for k, v := range ranks {- pairs = append(pairs, kv{k, v})- }- sort.Slice(pairs, func(i, j int) bool { return pairs[i].v > pairs[j].v })- return pairs[0].k, docID2KBID-}--// parseTOCEntries flattens TOC entries across all TOC chunks.-func parseTOCEntries(chunks []map[string]interface{}) []tocEntry {- common.Debug("TOC enhancer: parsing TOC entries",- zap.Int("chunk_count", len(chunks)))- var out []tocEntry- for _, ck := range chunks {- cww, _ := ck["content_with_weight"].(string)- if cww == "" {- continue- }- var arr []tocEntry- if err := json.Unmarshal([]byte(cww), &arr); err == nil {- out = append(out, arr...)- continue- }- var single tocEntry- if err := json.Unmarshal([]byte(cww), &single); err == nil && single.Title != "" {- out = append(out, single)- continue- }- // Debug: log raw content that failed to parse- preview := cww- if len(preview) > 200 {- preview = preview[:200] + "..."- }- chunkID, _ := ck["id"].(string)- docID, _ := ck["doc_id"].(string)- common.Debug("TOC enhancer: chunk content not valid TOC JSON",- zap.String("chunk_id", chunkID),- zap.String("doc_id", docID),- zap.String("content_preview", preview))- }- return out-}--// scoreEntries calls the LLM to score TOC entries and returns (chunkID, normalizedScore) pairs.-func (e *TOCEnhancer) scoreEntries(ctx context.Context, entries []tocEntry, limit int) ([]tocRelevanceScore, error) {- if e.chatModel == nil || e.chatModel.ModelDriver == nil || len(entries) == 0 {- return nil, nil- }-- type tocLLMInput struct {- Level int `json:"level"`- Title string `json:"title"`- }- lines := make([]string, len(entries))- for i, ent := range entries {- b, _ := json.Marshal(tocLLMInput{Level: int(ent.Level), Title: ent.Title})- lines[i] = string(b)- }- tocStr := fmt.Sprintf("[\n%s\n]\n", strings.Join(lines, "\n"))-- userPrompt := fmt.Sprintf(tocRelevanceUserTemplate, tocStr, e.question)-- tempZero := 0.0- topP := 0.9- cfg := &modelModule.ChatConfig{- Temperature: &tempZero,- TopP: &topP,- }-- var scores []tocRelevanceScore- maxRetry := 2- var lastAns string- var lastErr error- for attempt := 0; attempt < maxRetry; attempt++ {- currentUser := userPrompt- if attempt > 0 && lastAns != "" && lastErr != nil {- currentUser += fmt.Sprintf(- "\nGenerated JSON is as following:\n%s\nBut exception while loading:\n%s\nPlease reconsider and correct it.",- lastAns, lastErr,- )- }- msgs := []modelModule.Message{- {Role: "system", Content: tocRelevanceSystemPrompt},- {Role: "user", Content: currentUser},- }- resp, err := e.chatModel.ChatWithMessages(ctx, msgs, cfg, nil)- if err != nil {- return nil, err- }- if resp == nil || resp.Answer == nil {- return nil, fmt.Errorf("toc scoring: empty response")- }-- raw := cleanLLMResponse(*resp.Answer)- lastAns = raw-- repaired, rerr := jsonrepair.Repair(raw)- if rerr != nil {- repaired = raw- }- if err = json.Unmarshal([]byte(repaired), &scores); err != nil {- lastErr = err- common.Warn("TOC enhancer: JSON parse failed, retrying",- zap.Error(err), zap.Int("attempt", attempt))- continue- }- break- }- if len(scores) == 0 && lastErr != nil {- return nil, fmt.Errorf("toc scoring: parse failed after retries: %w", lastErr)- }-- id2score := make(map[string][]float64)- for i := 0; i < len(scores) && i < len(entries); i++ {- sc := scores[i]- if sc.Score < 1 {- continue- }- norm := sc.Score / 5.0- for _, cid := range entries[i].IDs {- id2score[cid] = append(id2score[cid], norm)- }- }-- result := make([]tocRelevanceScore, 0, len(id2score))- for cid, vals := range id2score {- sum := 0.0- for _, v := range vals {- sum += v- }- avg := sum / float64(len(vals))- if avg >= 0.3 {- result = append(result, tocRelevanceScore{- Title: cid,- Score: avg,- })- }- }- if limit > 0 && len(result) > limit {- result = result[:limit]- }- return result, nil-}--// fetchChunk loads a single chunk by chunk_id from the engine.-func (e *TOCEnhancer) fetchChunk(ctx context.Context, chunkID, docID, kbID string) (map[string]interface{}, error) {- filter := map[string]interface{}{- "doc_id": []string{docID},- "chunk_id": []string{chunkID},- }- indexNames := make([]string, 0, len(e.tenantIDs))- for _, tid := range e.tenantIDs {- indexNames = append(indexNames, getIndexName(tid))- }- resp, err := e.docEngine.Search(ctx, &types.SearchRequest{- IndexNames: indexNames,- KbIDs: []string{kbID},- Filter: filter,- SelectFields: []string{"content_with_weight", "content_ltks", "doc_id", "docnm_kwd", "kb_id", "important_kwd", "image_id", "positions", "doc_type_kwd", "vector", "q_1024_vec"},- Offset: 0,- Limit: 1,- })- if err != nil || resp == nil || len(resp.Chunks) == 0 {- return nil, fmt.Errorf("toc enhancer: fetch chunk %s: not found", chunkID)- }- return resp.Chunks[0], nil-}--// getIndexName returns the search index name for a tenant.-func getIndexName(tenantID string) string {- return "ragflow_" + tenantID-}--func boostSimilarity(cm map[string]interface{}, delta float64) {- cm["similarity"] = getFloat(cm, "similarity") + delta-}--func getStringDef(m map[string]interface{}, key, def string) string {- if v, ok := m[key].(string); ok {- return v- }- return def-}--func getSlice(m map[string]interface{}, key string) []interface{} {- if v, ok := m[key].([]interface{}); ok {- return v- }- return nil-}--// sortAndTrimChunks sorts chunks by similarity descending and trims to top-N.-func sortAndTrimChunks(chunks []map[string]interface{}, topN int) []map[string]interface{} {- sort.SliceStable(chunks, func(i, j int) bool {- return getFloat(chunks[i], "similarity") > getFloat(chunks[j], "similarity")- })- if topN > 0 && topN < len(chunks) {- chunks = chunks[:topN]- }- return chunks-}--func asMap(v interface{}) map[string]interface{} {- if m, ok := v.(map[string]interface{}); ok {- return m- }- return nil-}diff --git a/internal/service/toc_enhancer_test.go b/internal/service/toc_enhancer_test.godeleted file mode 100644index faf65b77fe..0000000000--- a/internal/service/toc_enhancer_test.go+++ /dev/null@@ -1,314 +0,0 @@-//-// Copyright 2026 The InfiniFlow Authors. All Rights Reserved.-//-// Licensed under the Apache License, Version 2.0 (the "License");-// you may not use this file except in compliance with the License.-// You may obtain a copy of the License at-//-// http://www.apache.org/licenses/LICENSE-2.0-//-// Unless required by applicable law or agreed to in writing, software-// distributed under the License is distributed on an "AS IS" BASIS,-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.-// See the License for the specific language governing permissions and-// limitations under the License.-//--package service--import (- "testing"-)--func TestGetFloat(t *testing.T) {- tests := []struct {- name string- m map[string]interface{}- key string- want float64- }{- {"present", map[string]interface{}{"score": 3.5}, "score", 3.5},- {"missing", map[string]interface{}{}, "score", 0},- {"wrong type", map[string]interface{}{"score": "3.5"}, "score", 0},- {"nil value", map[string]interface{}{"score": nil}, "score", 0},- }- for _, tt := range tests {- t.Run(tt.name, func(t *testing.T) {- if got := getFloat(tt.m, tt.key); got != tt.want {- t.Errorf("getFloat() = %v, want %v", got, tt.want)- }- })- }-}--func TestGetStringDef(t *testing.T) {- tests := []struct {- name string- m map[string]interface{}- key string- def string- want string- }{- {"present", map[string]interface{}{"name": "foo"}, "name", "default", "foo"},- {"missing", map[string]interface{}{}, "name", "default", "default"},- {"wrong type", map[string]interface{}{"name": 42}, "name", "default", "default"},- {"empty string", map[string]interface{}{"name": ""}, "name", "default", ""},- }- for _, tt := range tests {- t.Run(tt.name, func(t *testing.T) {- if got := getStringDef(tt.m, tt.key, tt.def); got != tt.want {- t.Errorf("getStringDef() = %v, want %v", got, tt.want)- }- })- }-}--func TestGetSlice(t *testing.T) {- tests := []struct {- name string- m map[string]interface{}- key string- want []interface{}- }{- {"present", map[string]interface{}{"items": []interface{}{1, 2, 3}}, "items", []interface{}{1, 2, 3}},- {"missing", map[string]interface{}{}, "items", nil},- {"wrong type", map[string]interface{}{"items": "not a slice"}, "items", nil},- {"nil value", map[string]interface{}{"items": nil}, "items", nil},- }- for _, tt := range tests {- t.Run(tt.name, func(t *testing.T) {- got := getSlice(tt.m, tt.key)- if len(got) != len(tt.want) {- t.Errorf("getSlice() len = %d, want %d", len(got), len(tt.want))- return- }- for i := range got {- if got[i] != tt.want[i] {- t.Errorf("getSlice()[%d] = %v, want %v", i, got[i], tt.want[i])- }- }- })- }-}--func TestToFloat64Slice(t *testing.T) {- tests := []struct {- name string- v interface{}- want []float64- wantOk bool- }{- {"valid", []interface{}{1.0, 2.5, 3.0}, []float64{1.0, 2.5, 3.0}, true},- {"empty", []interface{}{}, []float64{}, true},- {"wrong type", "not a slice", nil, false},- {"non-float element", []interface{}{1.0, "x"}, nil, false},- {"nil", nil, nil, false},- }- for _, tt := range tests {- t.Run(tt.name, func(t *testing.T) {- got := toFloat64Slice(tt.v)- if (got != nil) != tt.wantOk {- t.Errorf("toFloat64Slice() ok = %v, want %v", got != nil, tt.wantOk)- return- }- if len(got) != len(tt.want) {- t.Errorf("toFloat64Slice() len = %d, want %d", len(got), len(tt.want))- return- }- for i := range got {- if got[i] != tt.want[i] {- t.Errorf("toFloat64Slice()[%d] = %v, want %v", i, got[i], tt.want[i])- }- }- })- }-}--func TestAsMap(t *testing.T) {- tests := []struct {- name string- v interface{}- want map[string]interface{}- }{- {"valid map", map[string]interface{}{"a": 1}, map[string]interface{}{"a": 1}},- {"nil", nil, nil},- {"wrong type", "not a map", nil},- }- for _, tt := range tests {- t.Run(tt.name, func(t *testing.T) {- got := asMap(tt.v)- if len(got) != len(tt.want) {- t.Errorf("asMap() len = %d, want %d", len(got), len(tt.want))- return- }- for k, v := range tt.want {- if got[k] != v {- t.Errorf("asMap()[%q] = %v, want %v", k, got[k], v)- }- }- })- }-}--func TestBoostSimilarity(t *testing.T) {- cm := map[string]interface{}{"similarity": 1.0}- boostSimilarity(cm, 0.5)- if cm["similarity"] != 1.5 {- t.Errorf("expected 1.5, got %v", cm["similarity"])- }-- boostSimilarity(cm, 0.0)- if cm["similarity"] != 1.5 {- t.Errorf("expected 1.5 (unchanged), got %v", cm["similarity"])- }-}--func TestTopDocFromChunks_Empty(t *testing.T) {- docID, docMap := topDocFromChunks(nil)- if docID != "" || docMap != nil {- t.Errorf("expected empty, got docID=%q, map=%v", docID, docMap)- }-}--func TestTopDocFromChunks_SingleDoc(t *testing.T) {- chunks := []map[string]interface{}{- map[string]interface{}{"doc_id": "doc1", "kb_id": "kb1", "similarity": 0.8},- map[string]interface{}{"doc_id": "doc1", "kb_id": "kb1", "similarity": 0.6},- }- docID, docMap := topDocFromChunks(chunks)- if docID != "doc1" {- t.Errorf("expected doc1, got %q", docID)- }- if docMap["doc1"] != "kb1" {- t.Errorf("expected kb1, got %q", docMap["doc1"])- }-}--func TestTopDocFromChunks_MultiDoc(t *testing.T) {- chunks := []map[string]interface{}{- map[string]interface{}{"doc_id": "doc1", "kb_id": "kb1", "similarity": 0.3},- map[string]interface{}{"doc_id": "doc2", "kb_id": "kb2", "similarity": 0.9},- map[string]interface{}{"doc_id": "doc1", "kb_id": "kb1", "similarity": 0.4},- }- docID, docMap := topDocFromChunks(chunks)- if docID != "doc2" {- t.Errorf("expected doc2 (accumulated 0.9 > doc1's 0.7), got %q", docID)- }- if docMap["doc1"] != "kb1" {- t.Errorf("expected kb1, got %q", docMap["doc1"])- }- if docMap["doc2"] != "kb2" {- t.Errorf("expected kb2, got %q", docMap["doc2"])- }-}--func TestTopDocFromChunks_NoDocID(t *testing.T) {- chunks := []map[string]interface{}{- map[string]interface{}{"similarity": 0.8},- }- docID, docMap := topDocFromChunks(chunks)- if docID != "" || docMap != nil {- t.Errorf("expected empty, got docID=%q, map=%v", docID, docMap)- }-}--func TestParseTOCEntries_Empty(t *testing.T) {- got := parseTOCEntries(nil)- if len(got) != 0 {- t.Errorf("expected 0 entries, got %d", len(got))- }-}--func TestParseTOCEntries_SingleEntry(t *testing.T) {- chunks := []map[string]interface{}{- {"content_with_weight": `{"level": 1, "title": "Intro", "ids": ["c1"]}`},- }- got := parseTOCEntries(chunks)- if len(got) != 1 {- t.Fatalf("expected 1 entry, got %d", len(got))- }- if got[0].Level != 1 || got[0].Title != "Intro" || len(got[0].IDs) != 1 || got[0].IDs[0] != "c1" {- t.Errorf("unexpected entry: %+v", got[0])- }-}--func TestParseTOCEntries_MultiEntry(t *testing.T) {- chunks := []map[string]interface{}{- {"content_with_weight": `[- {"level": 1, "title": "Intro", "ids": ["c1"]},- {"level": 2, "title": "Details", "ids": ["c2", "c3"]}- ]`},- }- got := parseTOCEntries(chunks)- if len(got) != 2 {- t.Fatalf("expected 2 entries, got %d", len(got))- }- if got[0].Title != "Intro" || got[1].Title != "Details" {- t.Errorf("unexpected titles: %q, %q", got[0].Title, got[1].Title)- }- if len(got[1].IDs) != 2 {- t.Errorf("expected 2 IDs for Details, got %v", got[1].IDs)- }-}--func TestParseTOCEntries_InvalidJSON(t *testing.T) {- chunks := []map[string]interface{}{- {"content_with_weight": `not json`},- }- got := parseTOCEntries(chunks)- if len(got) != 0 {- t.Errorf("expected 0 entries for invalid JSON, got %d", len(got))- }-}--func TestParseTOCEntries_MissingField(t *testing.T) {- chunks := []map[string]interface{}{- {"other_field": "value"},- }- got := parseTOCEntries(chunks)- if len(got) != 0 {- t.Errorf("expected 0 entries for missing content_with_weight, got %d", len(got))- }-}--func TestSortAndTrimChunks_Nil(t *testing.T) {- got := sortAndTrimChunks(nil, 3)- if got != nil {- t.Errorf("expected nil, got %v", got)- }-}--func TestSortAndTrimChunks_Trim(t *testing.T) {- chunks := []map[string]interface{}{- map[string]interface{}{"similarity": 0.3},- map[string]interface{}{"similarity": 0.9},- map[string]interface{}{"similarity": 0.6},- }- got := sortAndTrimChunks(chunks, 2)- if len(got) != 2 {- t.Fatalf("expected 2 chunks, got %d", len(got))- }- if got[0]["similarity"] != 0.9 {- t.Errorf("expected first similarity 0.9, got %v", got[0])- }- if got[1]["similarity"] != 0.6 {- t.Errorf("expected second similarity 0.6, got %v", got[1])- }-}--func TestSortAndTrimChunks_AllKept(t *testing.T) {- chunks := []map[string]interface{}{- map[string]interface{}{"similarity": 0.3},- map[string]interface{}{"similarity": 0.9},- }- got := sortAndTrimChunks(chunks, 5)- if len(got) != 2 {- t.Errorf("expected all 2 chunks kept, got %d", len(got))- }-}--func TestIndexName(t *testing.T) {- if got := getIndexName("tenant1"); got != "ragflow_tenant1" {- t.Errorf("expected 'ragflow_tenant1', got %q", got)- }-}diff --git a/sdk/python/ragflow_sdk/ragflow.py b/sdk/python/ragflow_sdk/ragflow.pyindex ccf90ca39a..f27feec3aa 100644--- a/sdk/python/ragflow_sdk/ragflow.py+++ b/sdk/python/ragflow_sdk/ragflow.py@@ -233,7 +233,6 @@ class RAGFlow:cross_languages: list[str] | None = None,metadata_condition: dict | None = None,use_kg: bool = False,- toc_enhance: bool = False,):if document_ids is None:document_ids = []@@ -251,7 +250,6 @@ class RAGFlow:"cross_languages": cross_languages,"metadata_condition": metadata_condition,"use_kg": use_kg,- "toc_enhance": toc_enhance,}# Send a POST request to the backend service (using requests library as an example, actual implementation may vary)res = self.post("/retrieval", json=data_json)diff --git a/web/src/interfaces/database/chat.ts b/web/src/interfaces/database/chat.tsindex ac631fa231..d7bfa389b0 100644--- a/web/src/interfaces/database/chat.ts+++ b/web/src/interfaces/database/chat.ts@@ -56,7 +56,6 @@ export interface PromptConfig {tavily_api_key?: string;youcom_api_key?: string;web_search_provider?: WebSearchProvider;- toc_enhance?: boolean;}export interface Parameter {diff --git a/web/src/locales/ar.ts b/web/src/locales/ar.tsindex e22437a727..628fc588ec 100644--- a/web/src/locales/ar.ts+++ b/web/src/locales/ar.ts@@ -828,9 +828,6 @@ export default {},cancel: 'يلغي',chatSetting: 'إعداد الدردشة',- tocEnhance: 'فهرس الصفحة',- tocEnhanceTip:- 'أثناء تحليل المستند، تم إنشاء معلومات جدول المحتويات (راجع خيار "تمكين استخراج جدول المحتويات" في الطريقة العامة). يسمح هذا للنموذج الكبير بإرجاع عناصر جدول المحتويات ذات الصلة باستعلام المستخدم، وبالتالي استخدام هذه العناصر لاسترداد الأجزاء ذات الصلة وتطبيق الترجيح على هذه القطع أثناء عملية الفرز. يحاكي هذا الأسلوب سلوك الإنسان في البحث عن المعلومات في الكتب.',batchDeleteSessions: 'حذف دفعة',deleteSelectedConfirm: 'هل تريد حذف الجلسة/الجلسات المحددة ({{count}})؟',showChunkMetadata: 'عرض بيانات التعريف للمقطع',diff --git a/web/src/locales/az.ts b/web/src/locales/az.tsindex b2a230aa3d..0b9eac8a3b 100644--- a/web/src/locales/az.ts+++ b/web/src/locales/az.ts@@ -1331,9 +1331,6 @@ Bu avtomatik etiketləmə funksiyası mövcud verilənlər dəstinə sahəyə ai},cancel: 'Ləğv et',chatSetting: 'Söhbət parametri',- tocEnhance: 'PageIndex',- tocEnhanceTip:- "Sənədin təhlili zamanı mündəricat məlumatı yaradılıb (Ümumi üsuldakı 'Mündəricatın çıxarılmasını aktivləşdir' seçiminə baxın). Bu, böyük modelə istifadəçinin sorğusuna uyğun mündəricat elementlərini qaytarmağa, sonra bu elementlərdən istifadə edərək əlaqəli fraqmentləri tapmağa və sıralama zamanı həmin fraqmentlərə çəki tətbiq etməyə imkan verir. Bu yanaşma insanların kitablarda məlumat axtarma davranışını təqlid edir.",batchDeleteSessions: 'Kütləvi sil',deleteSelectedConfirm: 'Seçilmiş {{count}} seans silinsin?',showChunkMetadata: 'Fraqmentin metaverilənlərini göstər',diff --git a/web/src/locales/bg.ts b/web/src/locales/bg.tsindex 746c08da6c..358824afe2 100644--- a/web/src/locales/bg.ts+++ b/web/src/locales/bg.ts@@ -905,8 +905,6 @@ The above is the content you need to summarize.`,},cancel: 'Отказ',chatSetting: 'Настройки на чат',- tocEnhance: 'PageIndex',- tocEnhanceTip: `По време на обработката на документа е генерирана информация за съдържание (вижте опцията 'Активиране на извличане на съдържание' в метода General). Това позволява на големия модел да върне елементи от съдържанието, релевантни на заявката на потребителя, като използва тези елементи за извличане на свързани фрагменти и прилагане на тегло върху тях при сортирането.`,batchDeleteSessions: 'Групово изтриване',deleteSelectedConfirm: 'Изтриване на избраните {count} сесия(и)?',showChunkMetadata: 'Показване на метаданни за чанк',diff --git a/web/src/locales/de.ts b/web/src/locales/de.tsindex 8a80193f08..413f526d4e 100644--- a/web/src/locales/de.ts+++ b/web/src/locales/de.ts@@ -922,9 +922,6 @@ Diese Auto-Tag-Funktion verbessert den Abruf, indem sie eine weitere Schicht dom},cancel: 'Abbrechen',chatSetting: 'Chat-Einstellung',- tocEnhance: 'Inhaltsverzeichnis verbessern',- tocEnhanceTip:- 'Während der Analyse des Dokuments wurden Inhaltsverzeichnisinformationen generiert (siehe Option "Inhaltsverzeichnis-Extraktion aktivieren" in der allgemeinen Methode). Dies ermöglicht es dem großen Modell, Inhaltsverzeichniselemente zurückzugeben, die für die Abfrage des Benutzers relevant sind, und diese Elemente zu verwenden, um verwandte Chunks abzurufen und diese Chunks während des Sortiervorgangs zu gewichten. Dieser Ansatz leitet sich von der Nachahmung der Verhaltenslogik ab, wie Menschen in Büchern nach Wissen suchen.',batchDeleteSessions: 'Stapel löschen',deleteSelectedConfirm: 'Die ausgewählten {count} Sitzung(en) löschen?',showChunkMetadata: 'Chunk-Metadaten anzeigen',diff --git a/web/src/locales/en.ts b/web/src/locales/en.tsindex 86cc6fde17..55d0036736 100644--- a/web/src/locales/en.ts+++ b/web/src/locales/en.ts@@ -1335,8 +1335,6 @@ This auto-tagging feature enhances retrieval by adding another layer of domain-s},cancel: 'Cancel',chatSetting: 'Chat setting',- tocEnhance: 'PageIndex',- tocEnhanceTip: `During the parsing of the document, table of contents information was generated (see the 'Enable Table of Contents Extraction' option in the General method). This allows the large model to return table of contents items relevant to the user's query, thereby using these items to retrieve related chunks and apply weighting to these chunks during the sorting process. This approach mimics human information-searching behavior in books.`,batchDeleteSessions: 'Batch delete',deleteSelectedConfirm: 'Delete the selected {{count}} session(s)?',},diff --git a/web/src/locales/fr.ts b/web/src/locales/fr.tsindex bd103a2737..2c62e2ddc3 100644--- a/web/src/locales/fr.ts+++ b/web/src/locales/fr.ts@@ -1124,8 +1124,6 @@ Applicable lorsque vous avez besoin que le LLM résume le document entier.},cancel: 'Annuler',chatSetting: 'Paramètres du chat',- tocEnhance: 'IndexPage',- tocEnhanceTip: `Lors de l'analyse du document, des informations de table des matières ont été générées (voir l'option 'Activer l'extraction de la table des matières' dans la méthode Général). Cela permet au grand modèle de retourner les éléments de table des matières pertinents à la requête de l'utilisateur, d'utiliser ces éléments pour récupérer les segments associés et d'appliquer une pondération lors du tri.`,batchDeleteSessions: 'Suppression en masse',deleteSelectedConfirm:'Supprimer les {{count}} session(s) sélectionnée(s) ?',diff --git a/web/src/locales/it.ts b/web/src/locales/it.tsindex b0bc05e432..18b8c60b61 100644--- a/web/src/locales/it.ts+++ b/web/src/locales/it.ts@@ -1169,8 +1169,6 @@ Questa funzionalità di auto-tagging migliora il recupero aggiungendo un ulterio},cancel: 'Annulla',chatSetting: 'Impostazioni chat',- tocEnhance: 'PageIndex',- tocEnhanceTip: ` Durante l'analisi del documento, sono state generate informazioni sull'indice (vedi l'opzione 'Abilita estrazione indice' nel metodo Generale). Questo permette al modello grande di restituire elementi dell'indice rilevanti per la query dell'utente, usando così questi elementi per recuperare i chunk correlati e applicare una ponderazione a questi chunk durante il processo di ordinamento. Questo approccio imita il comportamento umano di ricerca delle informazioni nei libri.`,batchDeleteSessions: 'Eliminazione multipla',deleteSelectedConfirm: 'Eliminare le {{count}} sessioni selezionate?',showChunkMetadata: 'Mostra metadati del chunk',diff --git a/web/src/locales/ja.ts b/web/src/locales/ja.tsindex 52fa9216bf..f6b75a4c24 100644--- a/web/src/locales/ja.ts+++ b/web/src/locales/ja.ts@@ -1008,9 +1008,6 @@ export default {muteWidget: 'ウィジェットの音声をミュート',crossLanguagePlaceholder: '値を選択してください',metadataKeys: 'フィルター可能な項目',- tocEnhance: 'PageIndex',- tocEnhanceTip:- 'ドキュメントの解析時に目次情報が生成されます(「全般」方式の「目次抽出を有効にする」オプションを参照)。これにより、大規模モデルはユーザーのクエリに関連する目次項目を返すことができ、これらの項目を使って関連チャンクを取得し、並べ替え時にこれらのチャンクへ重み付けを適用します。この手法は、人間が書籍の中で情報を探す際の行動を模倣したものです。',batchDeleteSessions: '一括削除',deleteSelectedConfirm: '選択した{{count}}件のセッションを削除しますか?',},diff --git a/web/src/locales/ko.ts b/web/src/locales/ko.tsindex 589e0ad58e..54b8ed7346 100644--- a/web/src/locales/ko.ts+++ b/web/src/locales/ko.ts@@ -1146,8 +1146,6 @@ export default {},cancel: '취소',chatSetting: '채팅 설정',- tocEnhance: 'PageIndex',- tocEnhanceTip: `문서 파싱 과정에서 목차 정보가 생성됩니다(일반 방법의 '목차 추출 활성화' 옵션 참조). 이 정보를 활용하면 대형 모델이 사용자 질의와 관련된 목차 항목을 반환하고, 이를 바탕으로 관련 청크를 검색한 뒤 정렬 시 해당 청크에 가중치를 부여할 수 있습니다. 책에서 목차를 보고 원하는 정보를 찾아가는 사람의 행동 방식을 모방한 방식입니다.`,batchDeleteSessions: '일괄 삭제',deleteSelectedConfirm: '선택한 {{count}}개의 세션을 삭제하시겠습니까?',showChunkMetadata: 'Chunk 메타데이터 표시',diff --git a/web/src/locales/ru.ts b/web/src/locales/ru.tsindex 2adc9cc916..a4f590ee52 100644--- a/web/src/locales/ru.ts+++ b/web/src/locales/ru.ts@@ -969,8 +969,6 @@ export default {},cancel: 'Отмена',chatSetting: 'Настройки чата',- tocEnhance: 'Улучшение оглавлением',- tocEnhanceTip: ` Во время парсинга документа была сгенерирована информация оглавления (см. опцию 'Включить извлечение оглавления' в методе General). Это позволяет большой модели возвращать элементы оглавления, релевантные запросу пользователя, тем самым используя эти элементы для извлечения связанных чанков и применения весов к этим чанкам в процессе сортировки. Этот подход получен из имитации поведенческой логики того, как люди ищут знания в книгах.`,deleteSelectedConfirm: 'Удалить выбранные сеансы ({{count}})?',showChunkMetadata: 'Показать метаданные чанка',showChunkMetadataTip:diff --git a/web/src/locales/tr.ts b/web/src/locales/tr.tsindex 9a2e622663..23ab45cb8c 100644--- a/web/src/locales/tr.ts+++ b/web/src/locales/tr.ts@@ -1298,8 +1298,6 @@ Bu otomatik etiketleme özelliği, mevcut datasete alanına özgü bilgi katman},cancel: 'İptal',chatSetting: 'Sohbet ayarı',- tocEnhance: 'SayfaDizini',- tocEnhanceTip: ` Belgenin ayrıştırılması sırasında içindekiler tablosu bilgisi oluşturuldu (Genel yöntemindeki 'İçindekiler Tablosu Çıkarmayı Etkinleştir' seçeneğine bakın). Bu, büyük modelin kullanıcının sorgusuyla ilgili içindekiler öğelerini döndürmesine olanak tanır, böylece bu öğeleri kullanarak ilgili parçaları alır ve sıralama işleminde bu parçalara ağırlık uygular. Bu yaklaşım, kitaplarda insan bilgi arama davranışını taklit eder.`,batchDeleteSessions: 'Toplu sil',deleteSelectedConfirm: 'Seçilen {{count}} oturum(lar) silinsin mi?',showChunkMetadata: 'Parça meta verilerini göster',diff --git a/web/src/locales/uz.ts b/web/src/locales/uz.tsindex eb34dfb986..a615f954db 100644--- a/web/src/locales/uz.ts+++ b/web/src/locales/uz.ts@@ -1220,9 +1220,6 @@ export default {},cancel: 'Bekor qilish',chatSetting: 'Chat sozlashi',- tocEnhance: 'PageIndex',- tocEnhanceTip:- 'Hujjatni tahlil qilish davomida mundarija ma’lumotlari generatsiya qilingan (Umumiy usuldagi ‘Mundarija ajratib olishni yoqish’ opsiyasini ko‘ring). Bu katta modelga foydalanuvchi so‘roviga tegishli mundarija elementlarini qaytarish imkonini beradi, shu orqali ushbu elementlardan tegishli bo‘laklarni olish va tartiblash jarayonida ularga vazn qo‘llash mumkin. Bu yondashuv kitoblardagi inson axborot izlash xatti-harakatiga taqlid qiladi.',batchDeleteSessions: 'Ommaviy o‘chirish',deleteSelectedConfirm: 'Tanlangan {{count}} sessiya(o‘chirilsinmi)?',showChunkMetadata: 'Bo‘lak metadatasini ko‘rsatish',diff --git a/web/src/locales/zh.ts b/web/src/locales/zh.tsindex 2ae39da7a8..ccbacdfdfb 100644--- a/web/src/locales/zh.ts+++ b/web/src/locales/zh.ts@@ -1218,8 +1218,6 @@ NER:使用 spaCy NER 和基于规则的关键词提取来抽取 Entities 和 RchatSetting: '聊天设置',avatarHidden: '隐藏头像',locale: '语言',- tocEnhance: 'PageIndex',- tocEnhanceTip: `解析文档时生成了目录信息(见General方法的'启用目录抽取'),让大模型返回和用户问题相关的目录项,从而利用目录项拿到相关 Chunk,对这些 Chunk 在排序中进行加权。这种方法来源于模仿人类查询书本中知识的行为逻辑`,batchDeleteSessions: '批量删除',deleteSelectedConfirm: '删除选中的 {{count}} 个会话?',},diff --git a/web/src/pages/next-chats/hooks/use-create-chat.ts b/web/src/pages/next-chats/hooks/use-create-chat.tsindex 2a244999d0..766cce45d1 100644--- a/web/src/pages/next-chats/hooks/use-create-chat.ts+++ b/web/src/pages/next-chats/hooks/use-create-chat.ts@@ -36,7 +36,6 @@ export const useCreateChatDialog = () => {{ key: 'knowledge', optional: false },{ key: 'date', optional: true },],- toc_enhance: false,},llm_id: defaultModelDictionary?.llm_id,tenant_llm_id: defaultModelDictionary?.llm_id,diff --git a/web/src/services/knowledge-service.ts b/web/src/services/knowledge-service.tsindex ec63e01518..5da36c8d58 100644--- a/web/src/services/knowledge-service.ts+++ b/web/src/services/knowledge-service.ts@@ -204,7 +204,6 @@ const chunkService = {meta_data_filter: rest.meta_data_filter,chat_id: rest.chat_id,use_kg: rest.use_kg,- toc_enhance: rest.toc_enhance,include_knowledge_compilation: rest.include_knowledge_compilation,};const response = await request.post(api.retrievalTest, {