From f00d3d68e5fa3919daca5bc36a1e7d26bb7d7e62 Mon Sep 17 00:00:00 2001 From: davegilligan Date: Mon, 25 May 2026 10:26:07 +0200 Subject: [PATCH] Add Quick mode (nova-lite/Bedrock) as 3rd tier for timeline tool MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- api/timeline-stream.php | 4 ++-- api/timeline.php | 4 ++-- includes/LegalTools.php | 13 ++++++++----- includes/PricingCatalog.php | 2 +- includes/ToolModels.php | 8 ++++++-- timeline.php | 9 +++++---- 6 files changed, 24 insertions(+), 16 deletions(-) diff --git a/api/timeline-stream.php b/api/timeline-stream.php index d68bb7f..7e50c70 100644 --- a/api/timeline-stream.php +++ b/api/timeline-stream.php @@ -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); diff --git a/api/timeline.php b/api/timeline.php index bdc5d3a..b2c9f29 100644 --- a/api/timeline.php +++ b/api/timeline.php @@ -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); diff --git a/includes/LegalTools.php b/includes/LegalTools.php index 5dd06ac..1919a2e 100644 --- a/includes/LegalTools.php +++ b/includes/LegalTools.php @@ -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', diff --git a/includes/PricingCatalog.php b/includes/PricingCatalog.php index f584a56..f418c6e 100644 --- a/includes/PricingCatalog.php +++ b/includes/PricingCatalog.php @@ -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, diff --git a/includes/ToolModels.php b/includes/ToolModels.php index e50a6b0..40bbf2c 100644 --- a/includes/ToolModels.php +++ b/includes/ToolModels.php @@ -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', + }; } } diff --git a/timeline.php b/timeline.php index 1ed09aa..ac814bc 100644 --- a/timeline.php +++ b/timeline.php @@ -24,11 +24,12 @@ require_once __DIR__ . '/includes/layout.php';
- Engine - - + Mode + + +
-

Azure engines use your BNL Azure credits. GPU runs the local LiteLLM proxy on cuttlefish.

+

Quick uses Amazon Bedrock nova-lite (fast, cheap). Standard and Deep use Azure OpenAI.

Advanced settings