diff --git a/app_llm.go b/app_llm.go index 6e0dc2c..f070c13 100644 --- a/app_llm.go +++ b/app_llm.go @@ -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) diff --git a/main.go b/main.go index 9290296..142be4f 100644 --- a/main.go +++ b/main.go @@ -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 { diff --git a/paperless.go b/paperless.go index 16ab98b..063097b 100644 --- a/paperless.go +++ b/paperless.go @@ -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 diff --git a/types.go b/types.go index 72238c0..11fbc53 100644 --- a/types.go +++ b/types.go @@ -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"` }