feat(tools): converge two-tier Quick/Pro selector onto .no fork

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>
This commit is contained in:
2026-06-15 12:23:46 +02:00
parent b217f18118
commit a8b1bb87a6
21 changed files with 339 additions and 103 deletions
+6 -3
View File
@@ -65,8 +65,9 @@ try {
throw new DbnToolsHttpException('advocate_role is too long.', 422, 'advocate_role_too_long');
}
$chargeTool = $advocateRole !== '' ? 'advocate' : 'deep-research';
$ftUid = dbnToolsFreeTierCheck($chargeTool);
$engine = ToolModels::engineForUser($ftUid, (string)($input['engine'] ?? 'azure_mini'));
$run = dbnToolsResolveToolRun($chargeTool, $input);
$ftUid = $run['ftUid'];
$engine = $run['engine'];
$priorContext = is_array($input['prior_context'] ?? null) ? $input['prior_context'] : null;
$branchNotes = mb_substr(trim((string)($input['branch_notes'] ?? '')), 0, 1000, 'UTF-8');
$subQsOverride = is_array($input['sub_questions_override'] ?? null) ? $input['sub_questions_override'] : [];
@@ -160,7 +161,9 @@ try {
'advocate_role' => $advocateRole !== '' ? $advocateRole : null,
]);
$ftRemaining = dbnToolsFreeTierDeduct($ftUid, $chargeTool);
$ftRemaining = $run['credits'] === null
? dbnToolsFreeTierDeduct($ftUid, $chargeTool)
: dbnToolsFreeTierDeductAmount($ftUid, $chargeTool, $run['credits'], $run['metadata']);
if ($ftRemaining >= 0) {
$result['balance'] = $ftRemaining;
}