a8b1bb87a6
Port the dobetterlegal-tools two-tier quality stack to dobetternorge.no: QUALITY_TIERS registry + resolveTier (ToolModels), dbnToolsResolveToolRun (bootstrap), tier read+charge in the 6 analytical endpoints, Quick/Pro UI + payload.tier on the 6 tool pages/JS, and the bounded corpusContextForSummarize RAG fix (per-passage trim + total budget + reranker_enabled). Back-compat: requests without `tier` keep legacy engine behavior. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
228 lines
16 KiB
PHP
228 lines
16 KiB
PHP
<?php
|
||
declare(strict_types=1);
|
||
$toolName = 'deep-research';
|
||
$toolTitle = 'Deep Research';
|
||
$toolKind = 'Agent + Rank/Rerank RAG';
|
||
$toolBadge = 'family-legal';
|
||
$extraScripts = ['assets/js/deep-research.js'];
|
||
require_once __DIR__ . '/includes/layout.php';
|
||
?>
|
||
<form id="deepResearchForm" class="tool-form deep-research" enctype="multipart/form-data">
|
||
|
||
<div class="lang-switcher" id="drLangSwitcher" role="group" aria-label="UI language">
|
||
<button type="button" class="lang-btn is-active" data-lang="en">🇬🇧 EN</button>
|
||
<button type="button" class="lang-btn" data-lang="no">🇳🇴 NO</button>
|
||
<button type="button" class="lang-btn" data-lang="uk">🇺🇦 UK</button>
|
||
<button type="button" class="lang-btn" data-lang="pl">🇵🇱 PL</button>
|
||
</div>
|
||
|
||
<div class="control-row" id="drTierControl">
|
||
<span class="control-label">Quality</span>
|
||
<label><input type="radio" name="drTier" value="quick" checked> Quick ★ <small class="control-hint">(Claude Haiku · fast · 6 credits)</small></label>
|
||
<label><input type="radio" name="drTier" value="pro"> Pro <small class="control-hint">(Claude Sonnet · best · 12 credits)</small></label>
|
||
</div>
|
||
<p class="upload-hint">Quick uses Claude Haiku 4.5 — fast and accurate for most research (6 credits). Pro uses Claude Sonnet 4.6 — the most thorough synthesis, best for cases involving § 4-25, Strand Lobben, or procedural challenges (12 credits).</p>
|
||
|
||
<div class="control-row corpus-persona is-hidden" id="drPersonaControl">
|
||
<span class="control-label">Domain</span>
|
||
<select id="drPersonaSelect" class="drill-sort-select" aria-label="Legal domain persona"></select>
|
||
<small class="control-hint">Scopes the corpus to a legal domain persona.</small>
|
||
</div>
|
||
|
||
<div class="dr-slice-section">
|
||
<p class="control-label">Corpus slices</p>
|
||
<p class="upload-hint">Three core legal slices are on by default. Enable Hague Convention, Norwegian Courts, Bufdir guidance, or DBN Resources for more targeted research.</p>
|
||
<div class="dr-slice-grid">
|
||
<button type="button" class="dr-slice is-on" data-slice="family_core" aria-pressed="true">
|
||
<div class="dr-slice__head">
|
||
<span class="dr-slice__title">Family Law Core</span>
|
||
<span class="dr-slice__badge">on</span>
|
||
</div>
|
||
<p class="dr-slice__tagline">Barneloven, custody, samvær, mediation</p>
|
||
</button>
|
||
<button type="button" class="dr-slice is-on" data-slice="child_welfare" aria-pressed="true">
|
||
<div class="dr-slice__head">
|
||
<span class="dr-slice__title">Child Welfare</span>
|
||
<span class="dr-slice__badge">on</span>
|
||
</div>
|
||
<p class="dr-slice__tagline">Barnevern, omsorgsovertakelse, foster care</p>
|
||
</button>
|
||
<button type="button" class="dr-slice is-on" data-slice="echr" aria-pressed="true">
|
||
<div class="dr-slice__head">
|
||
<span class="dr-slice__title">ECHR</span>
|
||
<span class="dr-slice__badge">on</span>
|
||
</div>
|
||
<p class="dr-slice__tagline">Art. 8 family life, Art. 9 religion, HUDOC vs Norway</p>
|
||
</button>
|
||
<button type="button" class="dr-slice" data-slice="hague" aria-pressed="false">
|
||
<div class="dr-slice__head">
|
||
<span class="dr-slice__title">Hague Convention</span>
|
||
<span class="dr-slice__badge">off</span>
|
||
</div>
|
||
<p class="dr-slice__tagline">INCADAT, cross-border abduction, wrongful removal</p>
|
||
</button>
|
||
<button type="button" class="dr-slice" data-slice="norwegian_courts" aria-pressed="false">
|
||
<div class="dr-slice__head">
|
||
<span class="dr-slice__title">Norwegian Courts</span>
|
||
<span class="dr-slice__badge">off</span>
|
||
</div>
|
||
<p class="dr-slice__tagline">Høyesterett + Lagmannsrett family decisions</p>
|
||
</button>
|
||
<button type="button" class="dr-slice" data-slice="bufdir_guidance" aria-pressed="false">
|
||
<div class="dr-slice__head">
|
||
<span class="dr-slice__title">Bufdir Guidance</span>
|
||
<span class="dr-slice__badge">off</span>
|
||
</div>
|
||
<p class="dr-slice__tagline">Bufdir, Barneombudet, Statsforvalteren guidance</p>
|
||
</button>
|
||
<button type="button" class="dr-slice" data-slice="broader_legal" aria-pressed="false">
|
||
<div class="dr-slice__head">
|
||
<span class="dr-slice__title">Broader Legal Support</span>
|
||
<span class="dr-slice__badge">off</span>
|
||
</div>
|
||
<p class="dr-slice__tagline">Arbeidsmiljøloven, NOUer, statutes, government background</p>
|
||
</button>
|
||
<button type="button" class="dr-slice" data-slice="dbn_resources" aria-pressed="false">
|
||
<div class="dr-slice__head">
|
||
<span class="dr-slice__title">DBN Resources</span>
|
||
<span class="dr-slice__badge">off</span>
|
||
</div>
|
||
<p class="dr-slice__tagline">Do Better Norge guides, flashcards, resource directory</p>
|
||
</button>
|
||
</div>
|
||
</div>
|
||
|
||
<details class="advanced-panel" id="drAdvanced">
|
||
<summary class="advanced-toggle">Advanced controls</summary>
|
||
<div class="dr-control-grid">
|
||
<div class="dr-control-card">
|
||
<label>Sub-questions <span id="drSubQValue" class="dr-control-value">4</span></label>
|
||
<input type="range" id="drSubQ" min="3" max="5" step="1" value="4">
|
||
<small>How many angles the agent expands the question into before retrieval.</small>
|
||
</div>
|
||
<div class="dr-control-card">
|
||
<label>Chunks / sub-Q <span id="drChunkLimitValue" class="dr-control-value">6</span></label>
|
||
<input type="range" id="drChunkLimit" min="4" max="10" step="1" value="6">
|
||
<small>How many corpus chunks the hybrid retriever pulls per sub-question.</small>
|
||
</div>
|
||
<div class="dr-control-card">
|
||
<label>Similarity floor <span id="drSimValue" class="dr-control-value">0.30</span></label>
|
||
<input type="range" id="drSim" min="0.20" max="0.60" step="0.05" value="0.30">
|
||
<small>Minimum cosine similarity for uploaded-doc chunks to count as a match.</small>
|
||
</div>
|
||
<div class="dr-control-card">
|
||
<label>Sources kept <span id="drTopKValue" class="dr-control-value">12</span></label>
|
||
<input type="range" id="drTopK" min="8" max="14" step="1" value="12">
|
||
<small>Top sources kept after dedupe + rerank to feed synthesis.</small>
|
||
</div>
|
||
<div class="dr-control-card">
|
||
<label>Temperature <span id="drTempValue" class="dr-control-value">0.15</span></label>
|
||
<input type="range" id="drTemp" min="0.05" max="0.40" step="0.05" value="0.15">
|
||
<small>Synthesis creativity. Keep low for grounded legal briefs.</small>
|
||
</div>
|
||
</div>
|
||
</details>
|
||
|
||
<div id="docPickerSection" class="doc-picker-section">
|
||
<button type="button" id="docPickerBtn" class="doc-picker-btn" aria-haspopup="dialog">
|
||
<svg class="doc-picker-btn__icon" width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><rect x="2" y="1" width="9" height="12" rx="1.5" stroke="currentColor" stroke-width="1.4"/><path d="M5 5h5M5 8h3" stroke="currentColor" stroke-width="1.3" stroke-linecap="round"/><rect x="7" y="9" width="6" height="5" rx="1" fill="white" stroke="currentColor" stroke-width="1.3"/><path d="M9 11h2M9 12.5h1" stroke="currentColor" stroke-width="1" stroke-linecap="round"/></svg>
|
||
<span><?= htmlspecialchars(dbnToolsT('doc_picker_btn', $uiLang)) ?></span>
|
||
</button>
|
||
<div id="docPickerChips" class="doc-picker-chips" aria-label="Selected documents"></div>
|
||
<input type="hidden" id="docPickerIds" name="doc_ids" value="">
|
||
</div>
|
||
|
||
<div class="upload-zone" id="drUploadZone" role="region" aria-label="File upload">
|
||
<input type="file" id="drUploadInput" multiple accept=".pdf,.docx,.txt" aria-label="Choose files">
|
||
<div id="drUploadPrompt" class="upload-prompt">
|
||
<span class="upload-icon" aria-hidden="true">⇧</span>
|
||
<p>Drop up to 5 case files here, or <label for="drUploadInput" class="upload-browse">browse</label></p>
|
||
<p class="upload-hint"><strong>PDF</strong>, <strong>DOCX</strong>, <strong>TXT</strong> — chunked + embedded in memory only, never stored.</p>
|
||
</div>
|
||
<div id="drUploadFileInfo" class="upload-file is-hidden">
|
||
<ul id="drUploadFileList" class="upload-file-list"></ul>
|
||
<button type="button" id="drUploadClear" class="upload-clear">× Clear</button>
|
||
</div>
|
||
</div>
|
||
|
||
<div id="drBranchPanel" class="branch-panel is-hidden" aria-label="Branch context">
|
||
<div class="branch-panel__head">
|
||
<span class="branch-panel__label">Branching from sub-question</span>
|
||
<button type="button" id="drBranchClear" class="upload-clear">× Clear branch</button>
|
||
</div>
|
||
<p id="drBranchOrigin" class="branch-panel__origin"></p>
|
||
<details class="branch-panel__prior">
|
||
<summary>Prior brief summary</summary>
|
||
<div id="drBranchSummary" class="branch-panel__brief"></div>
|
||
</details>
|
||
<label class="input-label" for="drBranchNotes">Add your notes / context</label>
|
||
<textarea id="drBranchNotes" rows="3" placeholder="Optional: add observations, corrections, or additional context for this branch…"></textarea>
|
||
</div>
|
||
|
||
<label class="input-label" for="drInput">Question or pasted text</label>
|
||
<textarea id="drInput" name="drInput" rows="8" placeholder="Describe the legal question, paste case notes, or both. The agent will research the corpus from 3–5 angles."></textarea>
|
||
|
||
<?php require __DIR__ . '/includes/case_toggle.php'; ?>
|
||
|
||
<div class="form-footer">
|
||
<p id="drStatus" class="form-status" role="status" aria-live="polite"></p>
|
||
<button id="drRunButton" type="submit">Run deep research</button>
|
||
</div>
|
||
</form>
|
||
|
||
<section id="drResults" class="results deep-research-results" aria-live="polite">
|
||
<div class="empty-state">
|
||
<h3>Ready</h3>
|
||
<p>Pick slices, drop a case file or paste a question, then run. The agent will expand the question, retrieve from the corpus + your upload, rerank, and synthesise a cited brief.</p>
|
||
</div>
|
||
</section>
|
||
|
||
<!-- Source modal -->
|
||
<div id="drSourceModal" class="dr-source-modal is-hidden" role="dialog" aria-modal="true" aria-labelledby="drSourceModalTitle">
|
||
<div class="dr-source-modal__dialog">
|
||
<header class="dr-source-modal__head">
|
||
<div>
|
||
<p class="eyebrow" id="drSourceModalEyebrow">Source</p>
|
||
<h3 id="drSourceModalTitle"></h3>
|
||
</div>
|
||
<button type="button" id="drSourceModalClose" class="upload-clear" aria-label="Close">×</button>
|
||
</header>
|
||
<div class="dr-source-modal__body">
|
||
<aside class="dr-source-modal__meta" id="drSourceModalMeta"></aside>
|
||
<div class="dr-source-modal__text" id="drSourceModalText"></div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Hidden stubs so tools.js element refs don't crash on this page -->
|
||
<div class="is-hidden" id="languageControl" aria-hidden="true">
|
||
<input type="radio" name="language" value="en" checked>
|
||
<input type="radio" name="language" value="no">
|
||
<input type="radio" name="language" value="uk">
|
||
<input type="radio" name="language" value="pl">
|
||
</div>
|
||
<div class="is-hidden" id="redactionControl" aria-hidden="true"></div>
|
||
<div class="is-hidden" id="audioZone" aria-hidden="true">
|
||
<input type="file" id="audioInput" style="display:none">
|
||
<div id="audioPrompt"></div>
|
||
<div id="audioFileInfo"><ol id="audioQueueList"></ol><button type="button" id="audioClear"></button></div>
|
||
</div>
|
||
<div class="is-hidden" id="diarizeControl" aria-hidden="true">
|
||
<input type="checkbox" id="diarizeCheck">
|
||
<input type="number" id="numSpeakersInput">
|
||
</div>
|
||
<div class="is-hidden" id="transcribeLangControl" aria-hidden="true"><input type="radio" name="transcribeLang" value="no" checked></div>
|
||
<div class="is-hidden" id="vocabControl" aria-hidden="true">
|
||
<div id="vocabPresets"></div>
|
||
<textarea id="initPromptInput"></textarea>
|
||
</div>
|
||
<div class="is-hidden" id="aliasSection" aria-hidden="true">
|
||
<button type="button" id="addAliasRow"></button>
|
||
<div id="aliasRows"></div>
|
||
</div>
|
||
<div class="is-hidden" id="exemptSection" aria-hidden="true">
|
||
<button type="button" id="addExemptRow"></button>
|
||
<div id="exemptRows"></div>
|
||
</div>
|
||
<?php require_once __DIR__ . '/includes/layout_footer.php'; ?>
|