feat: add AUTO_TAG_COMPLETE environment variable#892
Conversation
Add AUTO_TAG_COMPLETE environment variable to tag documents after auto-processing is complete, similar to PDF_OCR_COMPLETE_TAG for OCR processing. Default value: paperless-gpt-auto-complete
|
No actionable comments were generated in the recent review. 🎉 📝 WalkthroughWalkthroughAdds an Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Fix all issues with AI agents
In `@app_llm.go`:
- Around line 674-678: generateDocumentSuggestions currently applies
app.autoTagComplete unconditionally, causing manually-reviewed docs to get the
"auto-processing complete" tag; change generateDocumentSuggestions signature to
accept a boolean flag like isAuto (or source enum) and only append
app.autoTagComplete when isAuto is true, then update both callers (the manual
review caller and the auto-processing caller) to pass false and true
respectively; ensure the parameter name and the variable app.autoTagComplete are
used so the conditional lives inside generateDocumentSuggestions and no other
behavior is changed.
In `@main.go`:
- Around line 564-566: The auto-complete tag defaulting makes disabling
impossible because validateOrDefaultEnvVars unconditionally fills
autoTagComplete, yet app_llm.go gates on app.autoTagComplete != ""; fix by
either adding a boolean env like AUTO_TAG_COMPLETE_ENABLED (mirror
PDF_OCR_TAGGING and pdfOCRCompleteTag flow) and use it to control whether the
tag is appended, or change logic to treat an explicit empty env as “disabled” by
reading the env with os.LookupEnv in validateOrDefaultEnvVars (or set
autoTagComplete there) so you only default when the env is truly unset; update
the check in app_llm.go to rely on the new boolean or the possibly-empty
app.autoTagComplete accordingly.
In `@README.md`:
- Line 544: Update the README entry for AUTO_TAG_COMPLETE to document how users
can disable auto-completion tagging: state the exact environment variable
behavior (e.g., set AUTO_TAG_COMPLETE="" to disable or unset it) and mention the
alternative disable mechanism implemented in main.go (reference the logic in
main.go that reads AUTO_TAG_COMPLETE or the new enable flag name if added), and
include a short example showing disabling via environment variable and via the
enable flag if present so users know the opt-out path.
…abling The autoTagComplete tag was unconditionally added in generateDocumentSuggestions, which meant documents processed via manual review also received it. Additionally, validateOrDefaultEnvVars always defaulted the tag, making it impossible to disable. - Add IsAutoProcessing field to GenerateSuggestionsRequest to distinguish flows - Set IsAutoProcessing=true only in the background auto-processing caller - Gate auto-complete tag on both non-empty value and IsAutoProcessing flag - Use os.LookupEnv so AUTO_TAG_COMPLETE="" explicitly disables the feature - Update README to document the disable mechanism
There was a problem hiding this comment.
🧹 Nitpick comments (1)
main.go (1)
564-568: Consider logging the resolvedautoTagCompletevalue for consistency.Other tags like
manualTagandautoTagare logged viafmt.Printfafter defaulting (lines 545, 550). Adding a similar log forautoTagCompletewould help with debugging.Suggested addition
if val, ok := os.LookupEnv("AUTO_TAG_COMPLETE"); ok { autoTagComplete = val } else { autoTagComplete = "paperless-gpt-auto-complete" } + if autoTagComplete != "" { + fmt.Printf("Using %s as auto tag complete\n", autoTagComplete) + } else { + fmt.Println("Auto tag complete is disabled") + }
This new tag is already being logged in app_llm.go |
Match the existing logging pattern used by manualTag and autoTag.
|
I see there is a CI failure, but it doesnt look like its related to my changes as far as I can tell. |
Add AUTO_TAG_COMPLETE environment variable to tag documents after auto-processing is complete, similar to PDF_OCR_COMPLETE_TAG for OCR processing.
Default value: paperless-gpt-auto-complete
Summary by CodeRabbit
New Features
Documentation