Files
dobetternorge-tools/includes/layout.php
T
daveadmin 4cbe0a4ac4 Add Deep Research tool — agent + rank/rerank RAG
New surface at /deep-research.php where the user pastes a question or
uploads PDF/DOCX/TXT case files and a LLM-orchestrated agent researches
the Do Better Norge legal corpus from 3-5 angles, with hybrid retrieval,
cross-encoder rerank, and synthesis that emits an inline-[n]-cited
markdown brief plus a numbered sources panel.

Uploaded documents are chunked + embedded in memory only (nomic-embed-text
via LiteLLM) and searched alongside the shared corpus during the same
request — never persisted to disk, DB, or Qdrant.

Reuses ClientRagPipeline::searchAll (hybrid + rerank), dbnV6 slice
helpers, and the existing extract.php text-extraction logic via a new
dbnToolsExtractUploadedFile() helper. Also adds dbnToolsCallGpuLlm()
helper in bootstrap.php — fixes a latent bug where LegalTools.php
was already calling that name with no definition.

Search.php is unchanged.
2026-05-15 10:30:47 +02:00

69 lines
2.8 KiB
PHP

<?php
declare(strict_types=1);
// Required vars: $toolName (string), $toolTitle (string), $toolKind (string), $toolBadge (string)
require_once __DIR__ . '/bootstrap.php';
if (!dbnToolsIsAuthenticated()) {
$return = urlencode($_SERVER['REQUEST_URI'] ?? '/');
header('Location: /?return=' . $return);
exit;
}
$navItems = [
'ask' => ['Ask', 'Source-grounded'],
'search' => ['Search', 'Legal sources'],
'deep-research' => ['Deep research', 'Agent + RAG'],
'summarize' => ['Summarize', 'Pasted text'],
'timeline' => ['Timeline', 'Events'],
'redact' => ['Redact', 'Privacy'],
'transcribe' => ['Transcribe', 'Audio'],
];
$toolName = $toolName ?? 'ask';
$toolTitle = $toolTitle ?? 'Legal Tools';
$toolKind = $toolKind ?? '';
$toolBadge = $toolBadge ?? '';
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?= htmlspecialchars($toolTitle) ?> — Do Better Norge</title>
<link rel="stylesheet" href="assets/css/tools.css">
</head>
<body data-authenticated="true" data-active-tool="<?= htmlspecialchars($toolName) ?>">
<script>window.DBN_TOOLS_AUTHENTICATED = true;</script>
<main id="appShell" class="app-shell">
<header class="topbar">
<div>
<p class="eyebrow">Do Better Norge</p>
<h1>Legal Tools</h1>
</div>
<div class="topbar-actions">
<span id="healthPill" class="status-pill">Session active</span>
<button id="healthButton" class="secondary-button" type="button">Health</button>
</div>
</header>
<div class="disclaimer" role="note">
Legal information and preparation support, not final legal advice. Pasted text is processed in memory by default.
</div>
<section class="workspace" aria-label="Legal tools workspace">
<nav class="tool-rail" aria-label="Tools">
<?php foreach ($navItems as $slug => [$label, $sub]): ?>
<a href="<?= $slug ?>.php" class="tool-tab<?= $slug === $toolName ? ' is-active' : '' ?>" data-tool="<?= $slug ?>"<?= $slug === $toolName ? ' aria-current="page"' : '' ?>>
<span><?= $label ?></span>
<small><?= $sub ?></small>
</a>
<?php endforeach; ?>
</nav>
<section class="tool-panel" aria-labelledby="toolTitle">
<div class="tool-heading">
<div>
<p id="toolKind" class="eyebrow"><?= htmlspecialchars($toolKind) ?></p>
<h2 id="toolTitle"><?= htmlspecialchars($toolTitle) ?></h2>
</div>
<span id="toolBadge" class="tool-badge"><?= htmlspecialchars($toolBadge) ?></span>
</div>