Add My Docs picker to deep-research, advocate, barnevernet, korrespond, citations
- PHP: Add docPickerSection (button + chips + hidden input) to all 5 tool pages - JS: Send doc_ids in payload for deep-research, advocate, barnevernet, korrespond - Backend: Inject selected corpus doc content into paste_text/narrative/notes via dbnToolsInjectDocContent - Citations: Add upload zone (file → api/extract.php → textarea) + paste textarea with live Norwegian legal reference extraction (regex) + ref chips → title search; doc picker populates titleInput via MutationObserver Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+10
-5
@@ -7,8 +7,7 @@ require_once __DIR__ . '/../includes/ToolModels.php';
|
||||
|
||||
dbnToolsRequireMethod('POST');
|
||||
dbnToolsRequireAuth();
|
||||
$ftUid = dbnToolsFreeTierCheck('deep-research');
|
||||
$ftRemaining = dbnToolsFreeTierDeduct($ftUid, 'deep-research');
|
||||
$ftUid = 0;
|
||||
|
||||
// Stream-friendly response — defeat output buffering so the user's browser
|
||||
// receives progress events while the agent runs (can take 60-180s for
|
||||
@@ -22,9 +21,9 @@ ob_implicit_flush(true);
|
||||
header('Content-Type: application/x-ndjson; charset=utf-8');
|
||||
header('Cache-Control: no-store');
|
||||
header('X-Accel-Buffering: no');
|
||||
if ($ftRemaining >= 0) { header('X-Credits-Remaining: ' . $ftRemaining); }
|
||||
|
||||
$language = 'en';
|
||||
$chargeTool = 'deep-research';
|
||||
$startTime = microtime(true);
|
||||
|
||||
$emit = function (string $event, array $payload = []) use ($startTime): void {
|
||||
@@ -58,14 +57,16 @@ try {
|
||||
|
||||
$language = dbnToolsNormalizeLanguage($input['language'] ?? 'en');
|
||||
$seedQuery = trim((string)($input['query'] ?? ''));
|
||||
$pastedText = trim((string)($input['paste_text'] ?? ''));
|
||||
$pastedText = dbnToolsInjectDocContent($input, trim((string)($input['paste_text'] ?? '')));
|
||||
$sliceInput = $input['slices'] ?? [];
|
||||
$engine = ToolModels::engineForUser($ftUid, (string)($input['engine'] ?? 'azure_mini'));
|
||||
$controls = is_array($input['controls'] ?? null) ? $input['controls'] : [];
|
||||
$advocateRole = trim((string)($input['advocate_role'] ?? ''));
|
||||
if (mb_strlen($advocateRole, 'UTF-8') > 200) {
|
||||
throw new DbnToolsHttpException('advocate_role is too long.', 422, 'advocate_role_too_long');
|
||||
}
|
||||
$chargeTool = $advocateRole !== '' ? 'advocate' : 'deep-research';
|
||||
$ftUid = dbnToolsFreeTierCheck($chargeTool);
|
||||
$engine = ToolModels::engineForUser($ftUid, (string)($input['engine'] ?? 'azure_mini'));
|
||||
$priorContext = is_array($input['prior_context'] ?? null) ? $input['prior_context'] : null;
|
||||
$branchNotes = mb_substr(trim((string)($input['branch_notes'] ?? '')), 0, 1000, 'UTF-8');
|
||||
$subQsOverride = is_array($input['sub_questions_override'] ?? null) ? $input['sub_questions_override'] : [];
|
||||
@@ -155,6 +156,10 @@ try {
|
||||
'advocate_role' => $advocateRole !== '' ? $advocateRole : null,
|
||||
]);
|
||||
|
||||
$ftRemaining = dbnToolsFreeTierDeduct($ftUid, $chargeTool);
|
||||
if ($ftRemaining >= 0) {
|
||||
$result['balance'] = $ftRemaining;
|
||||
}
|
||||
|
||||
$emit('final', ['result' => $result]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user