Skip to content

Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.

fix(graph): increase entity extraction output budget (#2859)

JYao-Chen07a5af673ec5
diff --git a/internal/application/service/chat_pipeline/extract_entity.go b/internal/application/service/chat_pipeline/extract_entity.go
index 233779a6d..3bfa881be 100644
--- a/internal/application/service/chat_pipeline/extract_entity.go
+++ b/internal/application/service/chat_pipeline/extract_entity.go
@@ -151,6 +151,9 @@ func (p *PluginExtractEntity) OnEvent(ctx context.Context,
return next()
}
+// Graph extraction can return many nodes and relations; 4096 tokens can truncate the JSON payload.
+const entityExtractionMaxTokens = 8192
+
// Extractor is a struct for extracting entities
type Extractor struct {
chat chat.Chat
@@ -171,7 +174,7 @@ func NewExtractor(
template: template,
chatOpt: &chat.ChatOptions{
Temperature: 0.3,
- MaxTokens: 4096,
+ MaxTokens: entityExtractionMaxTokens,
Thinking: &think,
},
}
diff --git a/internal/application/service/chat_pipeline/extract_entity_test.go b/internal/application/service/chat_pipeline/extract_entity_test.go
index e08841091..c58582edd 100644
--- a/internal/application/service/chat_pipeline/extract_entity_test.go
+++ b/internal/application/service/chat_pipeline/extract_entity_test.go
@@ -259,3 +259,10 @@ func TestIsLikelyLanguageTag(t *testing.T) {
})
}
}
+
+func TestNewExtractorUsesGraphOutputBudget(t *testing.T) {
+ extractor := NewExtractor(nil, nil)
+ if got := extractor.chatOpt.MaxTokens; got != 8192 {
+ t.Fatalf("MaxTokens = %d, want 8192", got)
+ }
+}