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.
This commit is contained in:
2026-05-15 10:30:47 +02:00
parent 55e11cb649
commit 4cbe0a4ac4
10 changed files with 2119 additions and 125 deletions
+6 -1
View File
@@ -91,7 +91,7 @@ if (dbnToolsIsAuthenticated()) {
<section class="cap-section">
<div class="section-inner">
<h2 class="section-heading">Six tools, one suite</h2>
<h2 class="section-heading">Seven tools, one suite</h2>
<div class="cap-grid">
<div class="cap-card">
<span class="cap-label">Ask</span>
@@ -103,6 +103,11 @@ if (dbnToolsIsAuthenticated()) {
<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 35 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>