Add chunked timeline routing
This commit is contained in:
+3
-1
@@ -12,7 +12,9 @@ try {
|
||||
dbnToolsError('No file was uploaded.', 422, 'missing_file');
|
||||
}
|
||||
|
||||
$result = dbnToolsExtractUploadedFile($_FILES['file']);
|
||||
$tool = (string)($_POST['tool'] ?? '');
|
||||
$limit = $tool === 'timeline' ? DBN_TOOLS_TIMELINE_EXTRACT_TEXT_LIMIT : DBN_TOOLS_EXTRACT_TEXT_LIMIT;
|
||||
$result = dbnToolsExtractUploadedFile($_FILES['file'], $limit);
|
||||
$ftRemaining = dbnToolsFreeTierDeduct($ftUid, 'extract');
|
||||
if ($ftRemaining >= 0) {
|
||||
header('X-Credits-Remaining: ' . $ftRemaining);
|
||||
|
||||
+12
-2
@@ -9,7 +9,7 @@ dbnToolsRequireAuth();
|
||||
|
||||
// Parse input and run credit pre-check BEFORE emitting SSE headers so that
|
||||
// auth/credit errors can still return JSON (dbnToolsError / dbnToolsAbort).
|
||||
$input = dbnToolsJsonInput(400000);
|
||||
$input = dbnToolsJsonInput(1500000);
|
||||
$language = dbnToolsNormalizeLanguage($input['language'] ?? 'en');
|
||||
|
||||
$_validEngines = ['nova_lite', 'azure_mini', 'azure_full'];
|
||||
@@ -17,7 +17,7 @@ $_requestedEngine = in_array((string)($input['engine'] ?? ''), $_validEngines, t
|
||||
? (string)$input['engine'] : 'azure_mini';
|
||||
|
||||
try {
|
||||
$text = dbnToolsInjectDocContent($input, dbnToolsString($input, 'text', 128000, false));
|
||||
$text = dbnToolsInjectDocContent($input, dbnToolsString($input, 'text', ToolModels::TIMELINE_DEEP_MAX_CHARS, false));
|
||||
if (mb_strlen(trim($text), 'UTF-8') < 10) {
|
||||
dbnToolsError('Paste text, upload a file, or select a document before running.', 422, 'empty_text');
|
||||
}
|
||||
@@ -33,6 +33,7 @@ try {
|
||||
}
|
||||
|
||||
$timelineRoute = ToolModels::timelineRoute($ftUid, $_requestedEngine, $text);
|
||||
ToolModels::assertTimelineQuoteAccepted($timelineRoute, $input);
|
||||
$ftUid = dbnToolsFreeTierCheckAmount('timeline', (int)$timelineRoute['credits']);
|
||||
} catch (DbnToolsHttpException $e) {
|
||||
dbnToolsError($e->getMessage(), $e->status, $e->errorCode, $e->extra);
|
||||
@@ -69,6 +70,11 @@ try {
|
||||
'msg' => 'This input is ' . number_format((int)$timelineRoute['input_char_count']) . " characters, so Timeline is using {$label} for reliability.",
|
||||
]);
|
||||
}
|
||||
if (!empty($timelineRoute['chunked_timeline'])) {
|
||||
sseEmit('status', [
|
||||
'msg' => 'Processing ' . (int)$timelineRoute['timeline_chunk_count'] . ' timeline chunk(s).',
|
||||
]);
|
||||
}
|
||||
|
||||
$validFocus = ['all', 'deadlines', 'hearings', 'cps'];
|
||||
$focus = in_array((string)($input['focus'] ?? ''), $validFocus, true)
|
||||
@@ -110,6 +116,10 @@ try {
|
||||
'auto_upgraded_engine' => $timelineRoute['auto_upgraded_engine'],
|
||||
'input_char_count' => $timelineRoute['input_char_count'],
|
||||
'engine_limit_chars' => $timelineRoute['engine_limit_chars'],
|
||||
'max_char_limit' => $timelineRoute['max_char_limit'],
|
||||
'chunked_timeline' => $timelineRoute['chunked_timeline'],
|
||||
'timeline_chunk_count' => $timelineRoute['timeline_chunk_count'],
|
||||
'estimated_credits' => $timelineRoute['estimated_credits'],
|
||||
'credits_charged' => $timelineRoute['credits'],
|
||||
]);
|
||||
|
||||
|
||||
+7
-2
@@ -6,7 +6,7 @@ require_once __DIR__ . '/../includes/ToolModels.php';
|
||||
|
||||
dbnToolsRequireMethod('POST');
|
||||
dbnToolsRequireAuth();
|
||||
$input = dbnToolsJsonInput(400000);
|
||||
$input = dbnToolsJsonInput(1500000);
|
||||
$language = dbnToolsNormalizeLanguage($input['language'] ?? 'en');
|
||||
$_validEngines = ['nova_lite', 'azure_mini', 'azure_full'];
|
||||
$_requestedEngine = in_array((string)($input['engine'] ?? ''), $_validEngines, true)
|
||||
@@ -15,7 +15,7 @@ $_requestedEngine = in_array((string)($input['engine'] ?? ''), $_validEngines, t
|
||||
$start = microtime(true);
|
||||
|
||||
try {
|
||||
$text = dbnToolsInjectDocContent($input, dbnToolsString($input, 'text', 128000, false));
|
||||
$text = dbnToolsInjectDocContent($input, dbnToolsString($input, 'text', ToolModels::TIMELINE_DEEP_MAX_CHARS, false));
|
||||
if (mb_strlen(trim($text), 'UTF-8') < 10) {
|
||||
dbnToolsAbort('Paste text, upload a file, or select a document before running.', 422, 'empty_text');
|
||||
}
|
||||
@@ -33,6 +33,7 @@ try {
|
||||
}
|
||||
|
||||
$timelineRoute = ToolModels::timelineRoute($ftUid, $_requestedEngine, $text);
|
||||
ToolModels::assertTimelineQuoteAccepted($timelineRoute, $input);
|
||||
$ftUid = dbnToolsFreeTierCheckAmount('timeline', (int)$timelineRoute['credits']);
|
||||
|
||||
$validFocus = ['all', 'deadlines', 'hearings', 'cps'];
|
||||
@@ -71,6 +72,10 @@ try {
|
||||
'auto_upgraded_engine' => $timelineRoute['auto_upgraded_engine'],
|
||||
'input_char_count' => $timelineRoute['input_char_count'],
|
||||
'engine_limit_chars' => $timelineRoute['engine_limit_chars'],
|
||||
'max_char_limit' => $timelineRoute['max_char_limit'],
|
||||
'chunked_timeline' => $timelineRoute['chunked_timeline'],
|
||||
'timeline_chunk_count' => $timelineRoute['timeline_chunk_count'],
|
||||
'estimated_credits' => $timelineRoute['estimated_credits'],
|
||||
'credits_charged' => $timelineRoute['credits'],
|
||||
]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user