feat: add functionality to manage suggested and removable tags in document suggestions

This commit is contained in:
Dominik Schröter 2025-01-13 10:26:19 +01:00
parent 9fb2f65909
commit 6e88a1b7bb
4 changed files with 10 additions and 3 deletions

View file

@ -253,8 +253,12 @@ func (app *App) generateDocumentSuggestions(ctx context.Context, suggestionReque
docLogger.Printf("Suggested tags for document %d: %v", documentID, suggestedTags)
suggestion.SuggestedTags = suggestedTags
} else {
suggestion.SuggestedTags = removeTagFromList(doc.Tags, manualTag)
suggestion.SuggestedTags = doc.Tags
}
// Remove manual tag from the list of suggested tags
suggestion.RemoveTags = []string{manualTag, autoTag}
documentSuggestions = append(documentSuggestions, suggestion)
mu.Unlock()
docLogger.Printf("Document %d processed successfully.", documentID)

View file

@ -430,6 +430,7 @@ func (app *App) processAutoOcrTagDocuments() (int, error) {
ID: documents[0].ID,
OriginalDocument: documents[0],
SuggestedContent: ocrContent,
RemoveTags: []string{autoOcrTag},
},
}, app.Database, false)
if err != nil {

View file

@ -272,8 +272,9 @@ func (c *PaperlessClient) UpdateDocuments(ctx context.Context, documents []Docum
}
// remove autoTag to prevent infinite loop (even if it is in the original tags)
originalTags = removeTagFromList(originalTags, autoTag)
originalTags = removeTagFromList(originalTags, autoOcrTag)
for _, tag := range document.RemoveTags {
originalTags = removeTagFromList(originalTags, tag)
}
if len(tags) == 0 {
tags = originalTags

View file

@ -79,4 +79,5 @@ type DocumentSuggestion struct {
SuggestedTitle string `json:"suggested_title,omitempty"`
SuggestedTags []string `json:"suggested_tags,omitempty"`
SuggestedContent string `json:"suggested_content,omitempty"`
RemoveTags []string `json:"remove_tags,omitempty"`
}