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:
+16
-7
@@ -165,15 +165,24 @@ try {
|
||||
}
|
||||
|
||||
// ── Deduct credit now (Pass 2 starts) ───────────────────────────────────────
|
||||
$ftUid = dbnToolsFreeTierCheck('korrespond');
|
||||
$engine = ToolModels::engineForUser($ftUid, 'azure_mini');
|
||||
$inputEngine = (string)($input['engine'] ?? '');
|
||||
if (in_array($inputEngine, ['azure_mini', 'claude_sonnet'], true)) {
|
||||
$engine = $inputEngine;
|
||||
if (isset($input['tier'])) {
|
||||
$run = dbnToolsResolveToolRun('korrespond', $input);
|
||||
$ftUid = $run['ftUid'];
|
||||
$engine = $run['engine'];
|
||||
} else {
|
||||
$ftUid = dbnToolsFreeTierCheck('korrespond');
|
||||
$engine = ToolModels::engineForUser($ftUid, 'azure_mini');
|
||||
$inputEngine = (string)($input['engine'] ?? '');
|
||||
if (in_array($inputEngine, ['azure_mini', 'claude_sonnet'], true)) {
|
||||
$engine = $inputEngine;
|
||||
}
|
||||
$run = ['credits' => null, 'metadata' => []];
|
||||
}
|
||||
$length = in_array($input['length'] ?? '', ['concise', 'standard', 'detailed'], true)
|
||||
? (string)$input['length'] : 'standard';
|
||||
$ftRemaining = dbnToolsFreeTierDeduct($ftUid, 'korrespond');
|
||||
$ftRemaining = $run['credits'] === null
|
||||
? dbnToolsFreeTierDeduct($ftUid, 'korrespond')
|
||||
: dbnToolsFreeTierDeductAmount($ftUid, 'korrespond', $run['credits'], $run['metadata']);
|
||||
$creditDeducted = true;
|
||||
|
||||
$personaSlug = (isset($input['profile']) && is_string($input['profile']) && trim($input['profile']) !== '')
|
||||
@@ -212,7 +221,7 @@ try {
|
||||
'case_doc_ids' => $GLOBALS['dbn_last_case_doc_ids'] ?? [],
|
||||
'model' => $engine,
|
||||
'latency_ms' => $result['latency_ms'],
|
||||
'credits_charged' => 1,
|
||||
'credits_charged' => $run['credits'] ?? 1,
|
||||
]);
|
||||
} catch (Throwable) { /* non-critical */ }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user