diff --git a/internal/application/service/chat_pipeline/extract_entity.go b/internal/application/service/chat_pipeline/extract_entity.go index 233779a6..3bfa881b 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 e0884109..c58582ed 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) + } +}