mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-10-04 07:10:32 +00:00
Enhancement: more control over suggestion requests (#14258)
This commit is contained in:
@@ -15,3 +15,33 @@ export interface DocumentSuggestions {
|
||||
|
||||
dates?: string[] // ISO-formatted date string e.g. 2022-11-03
|
||||
}
|
||||
|
||||
const union = <T>(a: T[] = [], b: T[] = []): T[] => [...new Set([...a, ...b])]
|
||||
|
||||
export function mergeSuggestions(
|
||||
a: DocumentSuggestions,
|
||||
b: DocumentSuggestions
|
||||
): DocumentSuggestions {
|
||||
if (!a) return b
|
||||
return {
|
||||
title: a.title || b.title,
|
||||
tags: union(a.tags, b.tags),
|
||||
suggested_tags: union(a.suggested_tags, b.suggested_tags),
|
||||
correspondents: union(a.correspondents, b.correspondents),
|
||||
suggested_correspondents: union(
|
||||
a.suggested_correspondents,
|
||||
b.suggested_correspondents
|
||||
),
|
||||
document_types: union(a.document_types, b.document_types),
|
||||
suggested_document_types: union(
|
||||
a.suggested_document_types,
|
||||
b.suggested_document_types
|
||||
),
|
||||
storage_paths: union(a.storage_paths, b.storage_paths),
|
||||
suggested_storage_paths: union(
|
||||
a.suggested_storage_paths,
|
||||
b.suggested_storage_paths
|
||||
),
|
||||
dates: union(a.dates, b.dates),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,12 @@ export enum GlobalSearchType {
|
||||
TITLE_CONTENT = 'title-content',
|
||||
}
|
||||
|
||||
export enum SuggestionSource {
|
||||
ML = 'ml',
|
||||
AI = 'ai',
|
||||
Both = 'both',
|
||||
}
|
||||
|
||||
export enum CollapsibleSection {
|
||||
ATTRIBUTES = 'attributes',
|
||||
}
|
||||
@@ -98,6 +104,8 @@ export const SETTINGS_KEYS = {
|
||||
'general-settings:document-editing:overlay-thumbnail',
|
||||
DOCUMENT_EDITING_AUTO_SUGGEST:
|
||||
'general-settings:document-editing:auto-suggest',
|
||||
DOCUMENT_EDITING_SUGGESTION_SOURCE:
|
||||
'general-settings:document-editing:suggestion-source',
|
||||
DOCUMENT_DETAILS_HIDDEN_FIELDS:
|
||||
'general-settings:document-details:hidden-fields',
|
||||
SEARCH_DB_ONLY: 'general-settings:search:db-only',
|
||||
@@ -326,6 +334,11 @@ export const SETTINGS: UiSetting[] = [
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
},
|
||||
{
|
||||
key: SETTINGS_KEYS.DOCUMENT_EDITING_SUGGESTION_SOURCE,
|
||||
type: 'string',
|
||||
default: SuggestionSource.AI,
|
||||
},
|
||||
{
|
||||
key: SETTINGS_KEYS.DOCUMENT_DETAILS_HIDDEN_FIELDS,
|
||||
type: 'array',
|
||||
|
||||
Reference in New Issue
Block a user