0fcfed1a86
dbnToolsString was called with required=true (default), so it aborted before dbnToolsInjectDocContent could inject content from the doc picker. Now passes required=false and validates after injection so doc-only submissions work in timeline, redact, ask, and summarize. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
21 lines
824 B
PHP
21 lines
824 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
require_once __DIR__ . '/../includes/LegalTools.php';
|
|
|
|
dbnToolsRequireMethod('POST');
|
|
dbnToolsRequireAuth();
|
|
$ftUid = dbnToolsFreeTierCheck('ask');
|
|
$ftRemaining = dbnToolsFreeTierDeduct($ftUid, 'ask');
|
|
if ($ftRemaining >= 0) { header('X-Credits-Remaining: ' . $ftRemaining); }
|
|
$input = dbnToolsJsonInput(25000);
|
|
$language = dbnToolsNormalizeLanguage($input['language'] ?? 'en');
|
|
|
|
dbnToolsWithTelemetry('ask', $language, function () use ($input, $language): array {
|
|
$question = dbnToolsInjectDocContent($input, dbnToolsString($input, 'question', 4000, false));
|
|
if (mb_strlen(trim($question), 'UTF-8') < 5) {
|
|
dbnToolsAbort('Enter a question or select a document before running.', 422, 'empty_text');
|
|
}
|
|
return (new DbnLegalToolsService())->ask($question, $language);
|
|
});
|