Add dbn-legal-agent to deep-research and advocate pipelines

- interpretSeed: uses dbn-legal-agent for Norwegian/advocate queries
- expandQueries: uses dbn-legal-agent for Norwegian sub-question generation
- synthesise: adds dbn_legal engine option (dbn-legal-agent via LiteLLM GPU)
- advocate.php: adds Norwegian specialist radio button in engine selector

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-15 19:12:19 +02:00
parent a61329eb85
commit 0ff4eb6d31
2 changed files with 37 additions and 11 deletions
+35 -10
View File
@@ -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'] ?? '');