From 28932297b33ec5db2d9bcdd292149c52f6b5dc2b Mon Sep 17 00:00:00 2001 From: davegilligan Date: Tue, 19 May 2026 12:36:37 +0200 Subject: [PATCH] Add user context notes field to timeline tool MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds an optional textarea below the main text input where users can provide clarifications to guide the LLM — e.g. year anchors, actor aliases, or focus instructions. Notes are injected into the prompt as a clearly delimited block and translated across all four UI languages (en/no/uk/pl). Co-Authored-By: Claude Sonnet 4.6 --- api/timeline.php | 3 ++- assets/js/tools.js | 13 +++++++++++++ includes/LegalTools.php | 9 +++++++-- timeline.php | 6 ++++++ 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/api/timeline.php b/api/timeline.php index 9fc42a6..0a40837 100644 --- a/api/timeline.php +++ b/api/timeline.php @@ -27,6 +27,7 @@ dbnToolsWithTelemetry('timeline', $language, function () use ($input, $language) $includeRelative = ($input['include_relative'] ?? true) !== false; $includeBackground = ($input['include_background'] ?? true) !== false; + $userNotes = dbnToolsString($input, 'user_notes', 2000, false); - return (new DbnLegalToolsService())->timeline($text, $language, $engine, $focus, $confidenceFilter, $includeRelative, $includeBackground); + return (new DbnLegalToolsService())->timeline($text, $language, $engine, $focus, $confidenceFilter, $includeRelative, $includeBackground, $userNotes); }); diff --git a/assets/js/tools.js b/assets/js/tools.js index 823447f..a141905 100644 --- a/assets/js/tools.js +++ b/assets/js/tools.js @@ -260,6 +260,9 @@ const TIMELINE_I18N = { sortDocOrder: 'Document order', sortChronological: 'Chronological', timelineExportCsv: 'Download CSV', + timelineNotesLabel: 'Context notes', + timelineNotesPlaceholder: 'Add any clarifications to guide the AI — e.g. "All dates are 2024", "Focus on the mother\'s actions", "D refers to the defendant throughout".', + timelineNotesHint: 'These notes are included in the prompt to help the model interpret ambiguous dates, actors, or abbreviations. Not stored.', }, no: { timelineEngine: 'Motor', @@ -298,6 +301,9 @@ const TIMELINE_I18N = { sortDocOrder: 'Dokumentrekkefølge', sortChronological: 'Kronologisk', timelineExportCsv: 'Last ned CSV', + timelineNotesLabel: 'Kontekstnotes', + timelineNotesPlaceholder: 'Legg til avklaringer for å veilede AI-en — f.eks. "Alle datoer er 2024", "Fokuser på morens handlinger", "D refererer til saksøkte gjennom hele dokumentet".', + timelineNotesHint: 'Disse notatene inkluderes i ledeteksten for å hjelpe modellen med å tolke uklare datoer, aktører eller forkortelser. Lagres ikke.', }, uk: { timelineEngine: 'Рушій', @@ -336,6 +342,9 @@ const TIMELINE_I18N = { sortDocOrder: 'Порядок документа', sortChronological: 'Хронологічний', timelineExportCsv: 'Завантажити CSV', + timelineNotesLabel: 'Контекстні нотатки', + timelineNotesPlaceholder: 'Додайте пояснення для ШІ — напр. "Усі дати відносяться до 2024 року", "Зосередьтесь на діях матері", "D — відповідач по всьому документу".', + timelineNotesHint: 'Ці нотатки включаються до запиту, щоб допомогти моделі інтерпретувати неоднозначні дати, учасників або скорочення. Не зберігаються.', }, pl: { timelineEngine: 'Silnik', @@ -374,6 +383,9 @@ const TIMELINE_I18N = { sortDocOrder: 'Kolejność dokumentu', sortChronological: 'Chronologicznie', timelineExportCsv: 'Pobierz CSV', + timelineNotesLabel: 'Notatki kontekstowe', + timelineNotesPlaceholder: 'Dodaj wyjaśnienia dla AI — np. "Wszystkie daty dotyczą 2024", "Skup się na działaniach matki", "D odnosi się do pozwanego w całym dokumencie".', + timelineNotesHint: 'Te notatki są dołączane do zapytania, aby pomóc modelowi interpretować niejednoznaczne daty, uczestników lub skróty. Nie są przechowywane.', }, }; @@ -1087,6 +1099,7 @@ async function runTool(event) { payload.confidence_filter = currentConfidenceFilter(); payload.include_relative = currentIncludeRelative(); payload.include_background = currentIncludeBackground(); + payload.user_notes = (document.getElementById('timelineNotes')?.value || '').trim(); } setBusy(true); diff --git a/includes/LegalTools.php b/includes/LegalTools.php index a413f23..8462a56 100644 --- a/includes/LegalTools.php +++ b/includes/LegalTools.php @@ -289,7 +289,8 @@ PROMPT; string $focus = 'all', string $confidenceFilter = 'all', bool $includeRelative = true, - bool $includeBackground = true + bool $includeBackground = true, + string $userNotes = '' ): array { $text = $this->requirePasteText($text); $engine = in_array($engine, ['azure_mini', 'azure_full', 'gpu'], true) ? $engine : 'azure_mini'; @@ -316,8 +317,12 @@ PROMPT; ? '' : "\nDo NOT extract relative, recurring, or conditional date references — extract only events with determinable absolute dates (date_type=absolute)."; + $userNotesBlock = $userNotes !== '' + ? "\n\nUser-provided context notes (use these to resolve ambiguities, not as source events):\n---\n" . $userNotes . "\n---" + : ''; + $prompt = <<Pasted text +
+ + +

These notes are included in the prompt to help the model interpret ambiguous dates, actors, or abbreviations. Not stored.

+
+