mirror of
https://github.com/icereed/paperless-gpt.git
synced 2025-03-13 21:28:02 -05:00
feat: add functionality to manage suggested and removable tags in document suggestions
This commit is contained in:
parent
9fb2f65909
commit
6e88a1b7bb
4 changed files with 10 additions and 3 deletions
|
@ -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)
|
||||
|
|
1
main.go
1
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 {
|
||||
|
|
|
@ -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
|
||||
|
|
1
types.go
1
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"`
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue