Add Quick mode (nova-lite/Bedrock) as 3rd tier for timeline tool

Timeline now offers Quick/Standard/Deep: nova_lite routes to Amazon
Bedrock nova-lite via LiteLLM (1 credit, ~2s faster), azure_mini stays
gpt-4o-mini (1 credit), azure_full stays gpt-4o (2 credits, Pro only).
ToolModels tier rules: free→nova_lite only, plus→quick/standard,
pro→all three.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-25 10:26:07 +02:00
parent 1d1bbeb69f
commit f00d3d68e5
6 changed files with 24 additions and 16 deletions
+2 -2
View File
@@ -12,7 +12,7 @@ dbnToolsRequireAuth();
$input = dbnToolsJsonInput(400000);
$language = dbnToolsNormalizeLanguage($input['language'] ?? 'en');
$_validEngines = ['azure_mini', 'azure_full'];
$_validEngines = ['nova_lite', 'azure_mini', 'azure_full'];
$_engine = in_array((string)($input['engine'] ?? ''), $_validEngines, true)
? (string)$input['engine'] : 'azure_mini';
$_engineCredits = $_engine === 'azure_full' ? 2 : 1;
@@ -42,7 +42,7 @@ try {
exit;
}
$validEngines = ['azure_mini', 'azure_full'];
$validEngines = ['nova_lite', 'azure_mini', 'azure_full'];
$engine = in_array((string)($input['engine'] ?? ''), $validEngines, true)
? (string)$input['engine'] : 'azure_mini';
$engine = ToolModels::engineForUser($ftUid, $engine);
+2 -2
View File
@@ -7,7 +7,7 @@ require_once __DIR__ . '/../includes/ToolModels.php';
dbnToolsRequireMethod('POST');
dbnToolsRequireAuth();
$input = dbnToolsJsonInput(400000);
$_validEngines = ['azure_mini', 'azure_full'];
$_validEngines = ['nova_lite', 'azure_mini', 'azure_full'];
$_engine = in_array((string)($input['engine'] ?? ''), $_validEngines, true)
? (string)$input['engine'] : 'azure_mini';
$_engineCredits = $_engine === 'azure_full' ? 2 : 1;
@@ -20,7 +20,7 @@ dbnToolsWithChargedTelemetry('timeline', $language, $ftUid, function () use ($in
dbnToolsAbort('Paste text, upload a file, or select a document before running.', 422, 'empty_text');
}
$validEngines = ['azure_mini', 'azure_full'];
$validEngines = ['nova_lite', 'azure_mini', 'azure_full'];
$engine = in_array((string)($input['engine'] ?? ''), $validEngines, true)
? (string)$input['engine'] : 'azure_mini';
$engine = ToolModels::engineForUser($ftUid, $engine);
+8 -5
View File
@@ -354,7 +354,7 @@ PROMPT;
?callable $onProgress = null
): array {
$text = $this->requirePasteText($text);
$engine = in_array($engine, ['azure_mini', 'azure_full'], true) ? $engine : 'azure_mini';
$engine = in_array($engine, ['nova_lite', 'azure_mini', 'azure_full'], true) ? $engine : 'azure_mini';
$focus = in_array($focus, ['all', 'deadlines', 'hearings', 'cps'], true) ? $focus : 'all';
$this->azure->requireChat();
@@ -450,12 +450,15 @@ PROMPT;
['role' => 'system', 'content' => $system],
['role' => 'user', 'content' => $prompt],
];
$chatOptions = ['json' => true, 'temperature' => 0.1, 'max_tokens' => ($engine === 'azure_full' ? 8000 : 4000), 'timeout' => 120];
$deployLabel = $engine === 'azure_full' ? 'gpt-4o' : 'gpt-4o-mini';
$maxTokens = match ($engine) { 'azure_full' => 8000, 'nova_lite' => 2000, default => 4000 };
$chatOptions = ['json' => true, 'temperature' => 0.1, 'max_tokens' => $maxTokens, 'timeout' => 120];
$deployLabel = match ($engine) { 'azure_full' => 'gpt-4o', 'nova_lite' => 'nova-lite', default => 'gpt-4o-mini' };
$onProgress && $onProgress("Calling {$deployLabel}\u{2026}");
try {
if ($engine === 'azure_full') {
if ($engine === 'nova_lite') {
$response = dbnToolsCallGpuLlm($messages, ['model' => 'nova-lite', 'json' => true, 'max_tokens' => $maxTokens, 'temperature' => 0.1, 'timeout' => 120]);
} elseif ($engine === 'azure_full') {
$response = $this->azure->withDeployment('gpt-4o')->chat($messages, $chatOptions);
} else {
$response = $this->azure->withDeployment('gpt-4o-mini')->chat($messages, $chatOptions);
@@ -484,7 +487,7 @@ PROMPT;
$events = array_values(array_filter($events, fn($ev) => ($ev['date_type'] ?? 'absolute') === 'absolute'));
}
$engineLabel = $engine === 'azure_full' ? 'gpt-4o' : 'gpt-4o-mini';
$engineLabel = match ($engine) { 'azure_full' => 'gpt-4o', 'nova_lite' => 'nova-lite', default => 'gpt-4o-mini' };
$focusLabel = match ($focus) {
'deadlines' => 'legal deadlines',
+1 -1
View File
@@ -132,7 +132,7 @@ final class PricingCatalog
'summarize' => 1,
'translate' => 1,
'korrespond_refine' => 1,
'timeline' => 1, // minimum (gpt-4o-mini); azure_full overrides to 2 in api/timeline.php
'timeline' => 1, // nova_lite=1, azure_mini=1; azure_full overrides to 2 in api/timeline.php
'redact' => 1, // minimum (gpt-4o-mini); azure_full overrides to 2 in api/redact.php
'barnevernet' => 3,
'advocate' => 3,
+6 -2
View File
@@ -13,13 +13,17 @@ final class ToolModels
{
public static function engineForUser(int $userId, string $requestedEngine): string
{
$valid = ['azure_mini', 'azure_full', 'gpu', 'regex'];
$valid = ['nova_lite', 'azure_mini', 'azure_full', 'gpu', 'regex'];
$requestedEngine = in_array($requestedEngine, $valid, true) ? $requestedEngine : 'azure_mini';
if ($userId <= 0) {
return $requestedEngine;
}
return FreeTier::tier($userId) === 'pro' ? 'azure_full' : 'azure_mini';
return match (FreeTier::tier($userId)) {
'pro' => $requestedEngine,
'plus' => $requestedEngine === 'azure_full' ? 'azure_mini' : $requestedEngine,
default => in_array($requestedEngine, ['nova_lite', 'regex'], true) ? $requestedEngine : 'nova_lite',
};
}
}
+5 -4
View File
@@ -24,11 +24,12 @@ require_once __DIR__ . '/includes/layout.php';
</div>
<div class="control-row" id="timelineEngineControl">
<span class="control-label" data-i18n="timelineEngine">Engine</span>
<label><input type="radio" name="timelineEngine" value="azure_mini" checked id="timelineEngineAzureMini"> <span data-i18n="timelineEngineAzureMini">Azure gpt-4o-mini</span> &#9733; <small class="control-hint">(fast)</small></label>
<label><input type="radio" name="timelineEngine" value="azure_full" id="timelineEngineAzureFull"> <span data-i18n="timelineEngineAzureFull">Azure gpt-4o</span> <small class="control-hint">(best)</small></label>
<span class="control-label" data-i18n="timelineEngine">Mode</span>
<label><input type="radio" name="timelineEngine" value="nova_lite" id="timelineEngineNovaLite"> <span>Quick</span> <small class="control-hint">(nova-lite · 1 credit · fastest)</small></label>
<label><input type="radio" name="timelineEngine" value="azure_mini" checked id="timelineEngineAzureMini"> <span data-i18n="timelineEngineAzureMini">Standard</span> &#9733; <small class="control-hint">(gpt-4o-mini · 1 credit)</small></label>
<label><input type="radio" name="timelineEngine" value="azure_full" id="timelineEngineAzureFull"> <span data-i18n="timelineEngineAzureFull">Deep</span> <small class="control-hint">(gpt-4o · 2 credits · Pro)</small></label>
</div>
<p class="upload-hint" data-i18n="timelineEngineHint">Azure engines use your BNL Azure credits. GPU runs the local LiteLLM proxy on cuttlefish.</p>
<p class="upload-hint" data-i18n="timelineEngineHint">Quick uses Amazon Bedrock nova-lite (fast, cheap). Standard and Deep use Azure OpenAI.</p>
<details class="advanced-panel" id="timelineAdvanced">
<summary class="advanced-toggle" data-i18n="timelineAdvancedToggle">Advanced settings</summary>