4cbe0a4ac4
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.
212 lines
11 KiB
PHP
212 lines
11 KiB
PHP
<?php
|
||
declare(strict_types=1);
|
||
|
||
require_once __DIR__ . '/includes/bootstrap.php';
|
||
|
||
// Handle SSO token from dobetternorge.no
|
||
if (isset($_GET['sso']) && !dbnToolsIsAuthenticated()) {
|
||
$ssoSecret = (string) dbnToolsEnv('DBN_SSO_SECRET', '');
|
||
if ($ssoSecret !== '') {
|
||
$tokenData = dbnToolsValidateSsoToken((string)$_GET['sso'], $ssoSecret);
|
||
if ($tokenData !== null) {
|
||
session_regenerate_id(true);
|
||
$_SESSION['dbn_tools_authenticated'] = true;
|
||
$_SESSION['dbn_tools_authenticated_at'] = time();
|
||
$_SESSION['dbn_tools_sso_uid'] = (int)$tokenData['uid'];
|
||
$_SESSION['dbn_tools_user_id'] = (int)$tokenData['uid'];
|
||
$_SESSION['dbn_tools_user_email'] = (string)$tokenData['email'];
|
||
$_SESSION['dbn_tools_user_role'] = 'sso';
|
||
header('Location: ask.php');
|
||
exit;
|
||
}
|
||
}
|
||
// Invalid/expired token — redirect back to main site to re-login
|
||
header('Location: https://dobetternorge.no/account.php?error=' . urlencode('Session expired. Please log in and try again.'));
|
||
exit;
|
||
}
|
||
|
||
if (dbnToolsIsAuthenticated()) {
|
||
$return = $_GET['return'] ?? '';
|
||
$dest = ($return && str_starts_with($return, '/') && !str_contains($return, '//'))
|
||
? $return : 'ask.php';
|
||
header('Location: ' . $dest);
|
||
exit;
|
||
}
|
||
?>
|
||
<!doctype html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
<title>Do Better Norge — AI Legal Research</title>
|
||
<meta name="description" content="AI-powered family law research for Norway. Source-cited answers from curated legal corpora, with a post-generation reviewer pass. Powered by CaveauAI.">
|
||
<meta name="robots" content="index, follow">
|
||
<link rel="canonical" href="https://tools.dobetternorge.no/">
|
||
<meta property="og:title" content="Do Better Norge — AI Legal Research">
|
||
<meta property="og:description" content="Source-cited answers from curated Norwegian law corpora. Every claim checked against real sources before it reaches you.">
|
||
<meta property="og:type" content="website">
|
||
<meta property="og:url" content="https://tools.dobetternorge.no/">
|
||
<meta name="theme-color" content="#f7f8fb">
|
||
<link rel="stylesheet" href="assets/css/tools.css">
|
||
</head>
|
||
<body data-authenticated="false">
|
||
|
||
<div id="publicLanding" class="showcase-page">
|
||
|
||
<header class="showcase-header">
|
||
<div class="showcase-header-inner">
|
||
<div class="showcase-brand">
|
||
<p class="eyebrow">Do Better Norge</p>
|
||
<h1 class="showcase-title">AI Legal Research</h1>
|
||
<p class="showcase-tagline">Source-cited answers from curated Norwegian law corpora</p>
|
||
<a href="https://caveauai.bluenotelogic.com/" class="powered-badge" rel="noopener" target="_blank">Powered by CaveauAI</a>
|
||
</div>
|
||
<a href="#access" class="cta-button">Access Legal Tools →</a>
|
||
</div>
|
||
</header>
|
||
|
||
<section class="hiw-section">
|
||
<div class="section-inner">
|
||
<h2 class="section-heading">How it works</h2>
|
||
<p class="section-sub">From question to reviewed, cited answer in three steps</p>
|
||
<div class="hiw-steps">
|
||
<div class="hiw-step">
|
||
<div class="hiw-num">01</div>
|
||
<h3>Curated legal corpus</h3>
|
||
<p>Norwegian family law, ECHR rulings, and Lovdata sources are indexed, chunked, and embedded by CaveauAI’s ingestion pipeline.</p>
|
||
</div>
|
||
<div class="hiw-step">
|
||
<div class="hiw-num">02</div>
|
||
<h3>Hybrid retrieval</h3>
|
||
<p>Your question triggers vector similarity search and keyword retrieval — sources are scored, re-ranked, and presented as a labelled evidence trail.</p>
|
||
</div>
|
||
<div class="hiw-step">
|
||
<div class="hiw-num">03</div>
|
||
<h3>Reviewed, cited answer</h3>
|
||
<p>A post-generation reviewer checks every claim against retrieved sources before the answer reaches you. Citations are attached to real corpus documents.</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
|
||
<section class="cap-section">
|
||
<div class="section-inner">
|
||
<h2 class="section-heading">Seven tools, one suite</h2>
|
||
<div class="cap-grid">
|
||
<div class="cap-card">
|
||
<span class="cap-label">Ask</span>
|
||
<h3>Ask</h3>
|
||
<p>Source-grounded legal questions with citations and explicit uncertainty notes.</p>
|
||
</div>
|
||
<div class="cap-card">
|
||
<span class="cap-label">Search</span>
|
||
<h3>Search</h3>
|
||
<p>Retrieve up to seven relevant legal sources with titles, sections, and excerpts.</p>
|
||
</div>
|
||
<div class="cap-card">
|
||
<span class="cap-label">Deep research</span>
|
||
<h3>Deep research</h3>
|
||
<p>Upload a case file or paste a question. An agent expands it into 3–5 angles, runs hybrid rank/rerank RAG across the corpus + your upload, and returns a cited brief.</p>
|
||
</div>
|
||
<div class="cap-card">
|
||
<span class="cap-label">Summarize</span>
|
||
<h3>Summarize</h3>
|
||
<p>Extract facts, dates, parties, and legal references from pasted text.</p>
|
||
</div>
|
||
<div class="cap-card">
|
||
<span class="cap-label">Timeline</span>
|
||
<h3>Timeline</h3>
|
||
<p>Build a chronological event sequence from case notes or documents.</p>
|
||
</div>
|
||
<div class="cap-card">
|
||
<span class="cap-label">Redact</span>
|
||
<h3>Redact</h3>
|
||
<p>Remove sensitive personal data with configurable Nordic / ECHR / Global profiles.</p>
|
||
</div>
|
||
<div class="cap-card">
|
||
<span class="cap-label">Transcribe</span>
|
||
<h3>Transcribe</h3>
|
||
<p>Convert audio recordings to text with optional speaker separation and Norwegian role labelling.</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
|
||
<section class="evidence-section">
|
||
<div class="section-inner evidence-inner">
|
||
<div class="evidence-copy">
|
||
<h2>Every answer shows its work</h2>
|
||
<p>Alongside each answer, the evidence trail shows which sources were retrieved, how they scored, which claims they support, and what remains uncertain. The legal reviewer pass checks all claims against the corpus before the answer is returned.</p>
|
||
<ul class="evidence-list">
|
||
<li>Source document, section, and authority type</li>
|
||
<li>Similarity score per retrieved chunk</li>
|
||
<li>Reviewer decision: approved / revised / insufficient support</li>
|
||
<li>Explicit uncertainty statement when the corpus can’t support a claim</li>
|
||
</ul>
|
||
</div>
|
||
<div class="evidence-mock" aria-hidden="true">
|
||
<p class="mock-label">Evidence Trail</p>
|
||
<div class="mock-step mock-done">
|
||
<span class="mock-dot"></span>
|
||
<div><strong>Query interpreted</strong><p>Barneloven §42 custody arrangements</p></div>
|
||
</div>
|
||
<div class="mock-step mock-done">
|
||
<span class="mock-dot"></span>
|
||
<div><strong>3 sources retrieved</strong><p>Barneloven, ECHR Johansen v. Norway, Ot.prp. nr. 56</p></div>
|
||
</div>
|
||
<div class="mock-step mock-done">
|
||
<span class="mock-dot"></span>
|
||
<div><strong>Reviewer: approved</strong><p>All claims supported by corpus sources</p></div>
|
||
</div>
|
||
<div class="mock-step">
|
||
<span class="mock-dot mock-dot--amber"></span>
|
||
<div><strong>Uncertainty noted</strong><p>Recent amendments after 2024 may not be indexed</p></div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
|
||
<section id="access" class="access-section" aria-labelledby="accessTitle">
|
||
<div class="gate-panel">
|
||
<p class="eyebrow">Do Better Norge</p>
|
||
<h2 id="accessTitle">Access Legal Tools</h2>
|
||
<p class="gate-copy">Legal information and preparation support, not final legal advice.</p>
|
||
|
||
<div style="margin-bottom:20px;padding:14px 18px;background:rgba(0,32,91,.06);border-radius:10px;border:1px solid rgba(0,32,91,.12);font-size:14px;color:#333;text-align:center;">
|
||
<strong>Do Better Norge member?</strong>
|
||
<a href="https://dobetternorge.no/account.php" style="color:#00205B;font-weight:600;margin-left:6px;">Log in at dobetternorge.no →</a><br>
|
||
<span style="color:#888;font-size:13px;">Then open Tools from your account dashboard</span>
|
||
</div>
|
||
|
||
<div style="text-align:center;margin:16px 0 12px;font-size:13px;color:#aaa;letter-spacing:.05em;">OR SIGN IN WITH CAVEAU ACCOUNT</div>
|
||
|
||
<form id="passcodeForm" class="passcode-form">
|
||
<label for="loginEmail">Email</label>
|
||
<input id="loginEmail" name="email" type="email" autocomplete="username email" required>
|
||
<label for="loginPassword">Password</label>
|
||
<div class="passcode-row">
|
||
<input id="loginPassword" name="password" type="password" autocomplete="current-password" required>
|
||
<button type="submit">Sign in</button>
|
||
</div>
|
||
<p id="gateStatus" class="form-status" role="status" aria-live="polite"></p>
|
||
</form>
|
||
|
||
<p style="text-align:center;margin-top:16px;font-size:13px;color:#888;">
|
||
No account yet?
|
||
<a href="https://dobetternorge.no/register.php" style="color:#00205B;font-weight:600;">Register free at dobetternorge.no</a>
|
||
</p>
|
||
</div>
|
||
</section>
|
||
|
||
<footer class="showcase-footer">
|
||
<p>Do Better Norge · Built with <a href="https://caveauai.bluenotelogic.com/" rel="noopener" target="_blank">CaveauAI</a> by Blue Note Logic</p>
|
||
<p class="footer-disclaimer">Legal information and preparation support, not final legal advice. Not a substitute for professional legal counsel.</p>
|
||
</footer>
|
||
|
||
</div>
|
||
|
||
<script>window.DBN_TOOLS_AUTHENTICATED = false;</script>
|
||
<script src="assets/js/tools.js" defer></script>
|
||
</body>
|
||
</html>
|