korrespond v1 premiere: Bedrock routing, engine picker, journal auto-save + status
- KorrespondAgent: add resolveDeployment() helper; fix classify/translate to use
Haiku via Bedrock, draft to use Haiku (quick) or Sonnet (thorough) — fixes broken
withDeployment('gpt-4o-mini') calls when DBN_BEDROCK_ENABLED=true
- korrespond.php: add Quick/Thorough engine picker (case_toggle already present)
- korrespond.js: pass engine in request payload
- api/korrespond.php: accept user-selected engine, auto-save to case_tool_results
for paid users after each successful run, update deployment log label
- CaseResults: add korr_status to listForUser SELECT, add updateStatus() method
- result-action.php: add set_status action for correspondence journal
- account.php: show status dropdown (Draft/Sent/Reply received/Resolved) for
korrespond entries in #analyses, wire JS change handler to result-action.php
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+22
-2
@@ -165,8 +165,12 @@ try {
|
||||
}
|
||||
|
||||
// ── Deduct credit now (Pass 2 starts) ───────────────────────────────────────
|
||||
$ftUid = dbnToolsFreeTierCheck('korrespond');
|
||||
$ftUid = dbnToolsFreeTierCheck('korrespond');
|
||||
$engine = ToolModels::engineForUser($ftUid, 'azure_mini');
|
||||
$inputEngine = (string)($input['engine'] ?? '');
|
||||
if (in_array($inputEngine, ['azure_mini', 'claude_sonnet'], true)) {
|
||||
$engine = $inputEngine;
|
||||
}
|
||||
$ftRemaining = dbnToolsFreeTierDeduct($ftUid, 'korrespond');
|
||||
$creditDeducted = true;
|
||||
|
||||
@@ -184,12 +188,28 @@ try {
|
||||
'ok' => true,
|
||||
'latency_ms' => $result['latency_ms'],
|
||||
'source_count' => is_array($result['cited_law'] ?? null) ? count($result['cited_law']) : 0,
|
||||
'deployment' => ($engine === 'azure_full') ? 'gpt-4o' : 'gpt-4o-mini',
|
||||
'deployment' => $engine,
|
||||
]);
|
||||
|
||||
|
||||
$emit('final', ['result' => $result]);
|
||||
|
||||
// Auto-save for paid users — non-critical, silent on failure
|
||||
try {
|
||||
require_once __DIR__ . '/../includes/CaseResults.php';
|
||||
require_once __DIR__ . '/../includes/CaseStore.php';
|
||||
$authUser = dbnToolsAuthenticatedUser();
|
||||
$uid = (int)($authUser['user_id'] ?? 0);
|
||||
$oid = CaseStore::caseResolveClientId($uid);
|
||||
CaseResults::save($uid, $oid, 'korrespond', $intake, $result, [
|
||||
'used_case_context' => !empty($intake['use_my_case']) ? 1 : 0,
|
||||
'case_doc_ids' => $GLOBALS['dbn_last_case_doc_ids'] ?? [],
|
||||
'model' => $engine,
|
||||
'latency_ms' => $result['latency_ms'],
|
||||
'credits_charged' => 1,
|
||||
]);
|
||||
} catch (Throwable) { /* non-critical */ }
|
||||
|
||||
} catch (DbnToolsHttpException $e) {
|
||||
$latency = (int)round((microtime(true) - $startTime) * 1000);
|
||||
dbnToolsLogMetadata([
|
||||
|
||||
Reference in New Issue
Block a user