diff --git a/advocate.php b/advocate.php index d97bace..109d7b9 100644 --- a/advocate.php +++ b/advocate.php @@ -39,8 +39,9 @@ require_once __DIR__ . '/includes/layout.php'; + -

Azure mini finishes fastest. Azure full produces the most thorough advocate brief. GPU keeps everything inside the BNL fleet.

+

Azure mini finishes fastest. Azure full produces the most thorough advocate brief. Norwegian specialist uses a fine-tuned Norwegian law model for the synthesis — best for Barneloven, barnevern, and ECHR family law cases.

Corpus slices

diff --git a/includes/DeepResearchAgent.php b/includes/DeepResearchAgent.php index d880ff0..1e84fa7 100644 --- a/includes/DeepResearchAgent.php +++ b/includes/DeepResearchAgent.php @@ -431,10 +431,18 @@ In {$locale}, produce JSON with: PROMPT; try { - $raw = $this->azure->chatText([ - ['role' => 'system', 'content' => 'You return valid JSON only. No markdown fences.'], - ['role' => 'user', 'content' => $prompt], - ], ['json' => true, 'temperature' => 0.1, 'max_tokens' => 400, 'timeout' => 30]); + $sysMsg = ['role' => 'system', 'content' => 'You return valid JSON only. No markdown fences.']; + $userMsg = ['role' => 'user', 'content' => $prompt]; + if ($language === 'no' || $advocateRole !== '') { + $resp = dbnToolsCallGpuLlm([$sysMsg, $userMsg], [ + 'model' => 'dbn-legal-agent', 'json' => true, + 'temperature' => 0.1, 'max_tokens' => 400, 'timeout' => 40, + ]); + $raw = (string)($resp['choices'][0]['message']['content'] ?? ''); + } else { + $raw = $this->azure->chatText([$sysMsg, $userMsg], + ['json' => true, 'temperature' => 0.1, 'max_tokens' => 400, 'timeout' => 30]); + } $json = $this->azure->decodeJsonObject($raw); if (is_array($json) && !empty($json['brief'])) { $signals = $json['key_signals'] ?? []; @@ -514,10 +522,18 @@ PROMPT; } try { - $raw = $this->azure->chatText([ - ['role' => 'system', 'content' => 'You return valid JSON only. No markdown fences.'], - ['role' => 'user', 'content' => $prompt], - ], ['json' => true, 'temperature' => 0.2, 'max_tokens' => 700, 'timeout' => 35]); + $sysMsg = ['role' => 'system', 'content' => 'You return valid JSON only. No markdown fences.']; + $userMsg = ['role' => 'user', 'content' => $prompt]; + if ($language === 'no') { + $resp = dbnToolsCallGpuLlm([$sysMsg, $userMsg], [ + 'model' => 'dbn-legal-agent', 'json' => true, + 'temperature' => 0.2, 'max_tokens' => 700, 'timeout' => 50, + ]); + $raw = (string)($resp['choices'][0]['message']['content'] ?? ''); + } else { + $raw = $this->azure->chatText([$sysMsg, $userMsg], + ['json' => true, 'temperature' => 0.2, 'max_tokens' => 700, 'timeout' => 35]); + } $json = $this->azure->decodeJsonObject($raw); $items = is_array($json['sub_questions'] ?? null) ? $json['sub_questions'] : []; $normalized = []; @@ -866,7 +882,12 @@ PROMPT; 'what_remains_uncertain' => ['No corpus evidence retrieved for the given query and slice selection.'], 'next_practical_step' => 'Try widening slice selection or rephrasing with more specific statutory or party terms.', ], - 'deploy_label' => $engine === 'gpu' ? 'GPU (cuttlefish)' : ($engine === 'azure_full' ? 'gpt-4o' : $this->azure->chatDeployment()), + 'deploy_label' => match($engine) { + 'gpu' => 'GPU (cuttlefish)', + 'dbn_legal' => 'dbn-legal-agent', + 'azure_full'=> 'gpt-4o', + default => $this->azure->chatDeployment(), + }, ]; } @@ -976,7 +997,11 @@ PROMPT; $opts = ['json' => true, 'temperature' => $temperature, 'max_tokens' => 3200, 'timeout' => 180]; try { - if ($engine === 'gpu') { + if ($engine === 'dbn_legal') { + $response = dbnToolsCallGpuLlm($messages, array_merge($opts, ['model' => 'dbn-legal-agent', 'timeout' => 180])); + $deployLabel = 'dbn-legal-agent'; + $raw = (string)($response['choices'][0]['message']['content'] ?? ''); + } elseif ($engine === 'gpu') { $response = dbnToolsCallGpuLlm($messages, $opts); $deployLabel = 'GPU (cuttlefish)'; $raw = (string)($response['choices'][0]['message']['content'] ?? '');