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:
+2
-1
@@ -39,8 +39,9 @@ require_once __DIR__ . '/includes/layout.php';
|
|||||||
<label><input type="radio" name="advEngine" value="azure_mini" checked> Azure gpt-4o-mini ★ <small class="control-hint">(~15-45s)</small></label>
|
<label><input type="radio" name="advEngine" value="azure_mini" checked> Azure gpt-4o-mini ★ <small class="control-hint">(~15-45s)</small></label>
|
||||||
<label><input type="radio" name="advEngine" value="azure_full"> Azure gpt-4o <small class="control-hint">(best · ~60-180s)</small></label>
|
<label><input type="radio" name="advEngine" value="azure_full"> Azure gpt-4o <small class="control-hint">(best · ~60-180s)</small></label>
|
||||||
<label><input type="radio" name="advEngine" value="gpu"> GPU (cuttlefish) <small class="control-hint">(local · ~30-90s)</small></label>
|
<label><input type="radio" name="advEngine" value="gpu"> GPU (cuttlefish) <small class="control-hint">(local · ~30-90s)</small></label>
|
||||||
|
<label><input type="radio" name="advEngine" value="dbn_legal"> 🇳🇴 Norwegian specialist <small class="control-hint">(dbn-legal-agent · ~40-90s)</small></label>
|
||||||
</div>
|
</div>
|
||||||
<p class="upload-hint">Azure mini finishes fastest. Azure full produces the most thorough advocate brief. GPU keeps everything inside the BNL fleet.</p>
|
<p class="upload-hint">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.</p>
|
||||||
|
|
||||||
<div class="dr-slice-section">
|
<div class="dr-slice-section">
|
||||||
<p class="control-label">Corpus slices</p>
|
<p class="control-label">Corpus slices</p>
|
||||||
|
|||||||
@@ -431,10 +431,18 @@ In {$locale}, produce JSON with:
|
|||||||
PROMPT;
|
PROMPT;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$raw = $this->azure->chatText([
|
$sysMsg = ['role' => 'system', 'content' => 'You return valid JSON only. No markdown fences.'];
|
||||||
['role' => 'system', 'content' => 'You return valid JSON only. No markdown fences.'],
|
$userMsg = ['role' => 'user', 'content' => $prompt];
|
||||||
['role' => 'user', 'content' => $prompt],
|
if ($language === 'no' || $advocateRole !== '') {
|
||||||
], ['json' => true, 'temperature' => 0.1, 'max_tokens' => 400, 'timeout' => 30]);
|
$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);
|
$json = $this->azure->decodeJsonObject($raw);
|
||||||
if (is_array($json) && !empty($json['brief'])) {
|
if (is_array($json) && !empty($json['brief'])) {
|
||||||
$signals = $json['key_signals'] ?? [];
|
$signals = $json['key_signals'] ?? [];
|
||||||
@@ -514,10 +522,18 @@ PROMPT;
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$raw = $this->azure->chatText([
|
$sysMsg = ['role' => 'system', 'content' => 'You return valid JSON only. No markdown fences.'];
|
||||||
['role' => 'system', 'content' => 'You return valid JSON only. No markdown fences.'],
|
$userMsg = ['role' => 'user', 'content' => $prompt];
|
||||||
['role' => 'user', 'content' => $prompt],
|
if ($language === 'no') {
|
||||||
], ['json' => true, 'temperature' => 0.2, 'max_tokens' => 700, 'timeout' => 35]);
|
$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);
|
$json = $this->azure->decodeJsonObject($raw);
|
||||||
$items = is_array($json['sub_questions'] ?? null) ? $json['sub_questions'] : [];
|
$items = is_array($json['sub_questions'] ?? null) ? $json['sub_questions'] : [];
|
||||||
$normalized = [];
|
$normalized = [];
|
||||||
@@ -866,7 +882,12 @@ PROMPT;
|
|||||||
'what_remains_uncertain' => ['No corpus evidence retrieved for the given query and slice selection.'],
|
'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.',
|
'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];
|
$opts = ['json' => true, 'temperature' => $temperature, 'max_tokens' => 3200, 'timeout' => 180];
|
||||||
|
|
||||||
try {
|
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);
|
$response = dbnToolsCallGpuLlm($messages, $opts);
|
||||||
$deployLabel = 'GPU (cuttlefish)';
|
$deployLabel = 'GPU (cuttlefish)';
|
||||||
$raw = (string)($response['choices'][0]['message']['content'] ?? '');
|
$raw = (string)($response['choices'][0]['message']['content'] ?? '');
|
||||||
|
|||||||
Reference in New Issue
Block a user