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:
@@ -12,7 +12,7 @@ dbnToolsRequireAuth();
|
|||||||
$input = dbnToolsJsonInput(400000);
|
$input = dbnToolsJsonInput(400000);
|
||||||
$language = dbnToolsNormalizeLanguage($input['language'] ?? 'en');
|
$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)
|
$_engine = in_array((string)($input['engine'] ?? ''), $_validEngines, true)
|
||||||
? (string)$input['engine'] : 'azure_mini';
|
? (string)$input['engine'] : 'azure_mini';
|
||||||
$_engineCredits = $_engine === 'azure_full' ? 2 : 1;
|
$_engineCredits = $_engine === 'azure_full' ? 2 : 1;
|
||||||
@@ -42,7 +42,7 @@ try {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$validEngines = ['azure_mini', 'azure_full'];
|
$validEngines = ['nova_lite', 'azure_mini', 'azure_full'];
|
||||||
$engine = in_array((string)($input['engine'] ?? ''), $validEngines, true)
|
$engine = in_array((string)($input['engine'] ?? ''), $validEngines, true)
|
||||||
? (string)$input['engine'] : 'azure_mini';
|
? (string)$input['engine'] : 'azure_mini';
|
||||||
$engine = ToolModels::engineForUser($ftUid, $engine);
|
$engine = ToolModels::engineForUser($ftUid, $engine);
|
||||||
|
|||||||
+2
-2
@@ -7,7 +7,7 @@ require_once __DIR__ . '/../includes/ToolModels.php';
|
|||||||
dbnToolsRequireMethod('POST');
|
dbnToolsRequireMethod('POST');
|
||||||
dbnToolsRequireAuth();
|
dbnToolsRequireAuth();
|
||||||
$input = dbnToolsJsonInput(400000);
|
$input = dbnToolsJsonInput(400000);
|
||||||
$_validEngines = ['azure_mini', 'azure_full'];
|
$_validEngines = ['nova_lite', 'azure_mini', 'azure_full'];
|
||||||
$_engine = in_array((string)($input['engine'] ?? ''), $_validEngines, true)
|
$_engine = in_array((string)($input['engine'] ?? ''), $_validEngines, true)
|
||||||
? (string)$input['engine'] : 'azure_mini';
|
? (string)$input['engine'] : 'azure_mini';
|
||||||
$_engineCredits = $_engine === 'azure_full' ? 2 : 1;
|
$_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');
|
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)
|
$engine = in_array((string)($input['engine'] ?? ''), $validEngines, true)
|
||||||
? (string)$input['engine'] : 'azure_mini';
|
? (string)$input['engine'] : 'azure_mini';
|
||||||
$engine = ToolModels::engineForUser($ftUid, $engine);
|
$engine = ToolModels::engineForUser($ftUid, $engine);
|
||||||
|
|||||||
@@ -354,7 +354,7 @@ PROMPT;
|
|||||||
?callable $onProgress = null
|
?callable $onProgress = null
|
||||||
): array {
|
): array {
|
||||||
$text = $this->requirePasteText($text);
|
$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';
|
$focus = in_array($focus, ['all', 'deadlines', 'hearings', 'cps'], true) ? $focus : 'all';
|
||||||
|
|
||||||
$this->azure->requireChat();
|
$this->azure->requireChat();
|
||||||
@@ -450,12 +450,15 @@ PROMPT;
|
|||||||
['role' => 'system', 'content' => $system],
|
['role' => 'system', 'content' => $system],
|
||||||
['role' => 'user', 'content' => $prompt],
|
['role' => 'user', 'content' => $prompt],
|
||||||
];
|
];
|
||||||
$chatOptions = ['json' => true, 'temperature' => 0.1, 'max_tokens' => ($engine === 'azure_full' ? 8000 : 4000), 'timeout' => 120];
|
$maxTokens = match ($engine) { 'azure_full' => 8000, 'nova_lite' => 2000, default => 4000 };
|
||||||
$deployLabel = $engine === 'azure_full' ? 'gpt-4o' : 'gpt-4o-mini';
|
$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}");
|
$onProgress && $onProgress("Calling {$deployLabel}\u{2026}");
|
||||||
|
|
||||||
try {
|
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);
|
$response = $this->azure->withDeployment('gpt-4o')->chat($messages, $chatOptions);
|
||||||
} else {
|
} else {
|
||||||
$response = $this->azure->withDeployment('gpt-4o-mini')->chat($messages, $chatOptions);
|
$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'));
|
$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) {
|
$focusLabel = match ($focus) {
|
||||||
'deadlines' => 'legal deadlines',
|
'deadlines' => 'legal deadlines',
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ final class PricingCatalog
|
|||||||
'summarize' => 1,
|
'summarize' => 1,
|
||||||
'translate' => 1,
|
'translate' => 1,
|
||||||
'korrespond_refine' => 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
|
'redact' => 1, // minimum (gpt-4o-mini); azure_full overrides to 2 in api/redact.php
|
||||||
'barnevernet' => 3,
|
'barnevernet' => 3,
|
||||||
'advocate' => 3,
|
'advocate' => 3,
|
||||||
|
|||||||
@@ -13,13 +13,17 @@ final class ToolModels
|
|||||||
{
|
{
|
||||||
public static function engineForUser(int $userId, string $requestedEngine): string
|
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';
|
$requestedEngine = in_array($requestedEngine, $valid, true) ? $requestedEngine : 'azure_mini';
|
||||||
|
|
||||||
if ($userId <= 0) {
|
if ($userId <= 0) {
|
||||||
return $requestedEngine;
|
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
@@ -24,11 +24,12 @@ require_once __DIR__ . '/includes/layout.php';
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="control-row" id="timelineEngineControl">
|
<div class="control-row" id="timelineEngineControl">
|
||||||
<span class="control-label" data-i18n="timelineEngine">Engine</span>
|
<span class="control-label" data-i18n="timelineEngine">Mode</span>
|
||||||
<label><input type="radio" name="timelineEngine" value="azure_mini" checked id="timelineEngineAzureMini"> <span data-i18n="timelineEngineAzureMini">Azure gpt-4o-mini</span> ★ <small class="control-hint">(fast)</small></label>
|
<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_full" id="timelineEngineAzureFull"> <span data-i18n="timelineEngineAzureFull">Azure gpt-4o</span> <small class="control-hint">(best)</small></label>
|
<label><input type="radio" name="timelineEngine" value="azure_mini" checked id="timelineEngineAzureMini"> <span data-i18n="timelineEngineAzureMini">Standard</span> ★ <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>
|
</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">
|
<details class="advanced-panel" id="timelineAdvanced">
|
||||||
<summary class="advanced-toggle" data-i18n="timelineAdvancedToggle">Advanced settings</summary>
|
<summary class="advanced-toggle" data-i18n="timelineAdvancedToggle">Advanced settings</summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user