Redact: multi-doc upload, contextual person naming, aliases

- Extract limit raised from 32K to 128K chars per file (long legal docs now fit)
- Redact API body/text limits raised (400KB / 128K chars) to match
- Upload zone accepts multiple files (up to 5); extracted text concatenated with
  doc separator and combined before redaction; shows per-file char counts
- LLM redact pass now infers contextual person roles (FATHER, MOTHER, CHILD,
  ATTORNEY, JUDGE, etc.) instead of generic [PERSON] for all names; same
  individual gets consistent tag throughout the document
- Tag validation widened to allow any [A-Za-z0-9_- ] pattern (not just the
  five hardcoded tags), supporting contextual and alias tags
- Alias UI added to Redact mode: user maps real names to bracketed aliases
  (e.g. "David Jr" -> [Junior]); aliases injected into LLM system prompt as
  override instructions; max 20 aliases, 100 chars each
- max_tokens raised from 2000 to 4000; timeout from 60s to 90s for larger docs

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-13 07:17:02 +02:00
parent bbe5307c03
commit 95685862ab
6 changed files with 276 additions and 55 deletions
+19 -3
View File
@@ -5,12 +5,28 @@ require_once __DIR__ . '/../includes/LegalTools.php';
dbnToolsRequireMethod('POST');
dbnToolsRequireAuth();
$input = dbnToolsJsonInput(70000);
$input = dbnToolsJsonInput(400000);
dbnToolsWithTelemetry('redact', '', function () use ($input): array {
$text = dbnToolsString($input, 'text', 32000);
$text = dbnToolsString($input, 'text', 128000);
$mode = (string)($input['mode'] ?? 'standard');
$region = dbnToolsNormalizeRegion($input['region'] ?? 'nordic');
$language = dbnToolsNormalizeLanguage($input['language'] ?? 'en');
return (new DbnLegalToolsService())->redact($text, $mode, $region, $language);
$aliases = [];
$rawAliases = $input['aliases'] ?? [];
if (is_array($rawAliases)) {
foreach (array_slice($rawAliases, 0, 20) as $item) {
if (!is_array($item)) {
continue;
}
$original = substr(trim((string)($item['original'] ?? '')), 0, 100);
$alias = substr(trim((string)($item['alias'] ?? '')), 0, 100);
if ($original !== '' && $alias !== '') {
$aliases[] = ['original' => $original, 'alias' => $alias];
}
}
}
return (new DbnLegalToolsService())->redact($text, $mode, $region, $language, $aliases);
});