feat(tools): persona-driven multi-domain corpus + model routing
Generalize the family-locked legal tools into caveauAI persona profiles (client 57 chat profiles, resolved in-process via the chat_profiles bridge). Each tool accepts an optional `profile` slug that scopes the corpus package(s), search method, system prompt and synthesis model; omitting it falls back to the family-legal package so existing behaviour is unchanged. - dbnToolsResolvePersona / dbnToolsListPersonas / dbnToolsBootChatProfiles in bootstrap.php; new api/personas.php + dbn.list_personas MCP tool. - LegalTools search/ask/corpusContextForSummarize and the BvjAnalyzer / LegalAnalysis / translate paths take the persona's packages + prompt + model. - Persona <select> on ask/search/summarize (populated from api/personas.php). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
+13
-3
@@ -55,7 +55,16 @@ try {
|
||||
'chars' => mb_strlen($text, 'UTF-8'),
|
||||
]);
|
||||
|
||||
$agent = new DbnLegalAnalysisAgent();
|
||||
// Resolve the persona (default = child-welfare for this barnevern tool) so
|
||||
// the targeted legal-check step uses the persona's system prompt + model.
|
||||
$client = dbnToolsRequireClient();
|
||||
$personaSlug = (isset($input['profile']) && is_string($input['profile']) && trim($input['profile']) !== '')
|
||||
? trim($input['profile'])
|
||||
: 'child-welfare';
|
||||
$personaResolved = dbnToolsResolvePersona((int)$client['id'], $personaSlug);
|
||||
|
||||
$agent = (new DbnLegalAnalysisAgent())
|
||||
->withPersonaPrompt($personaResolved['system_prompt'] ?? null);
|
||||
|
||||
// Pass 1 — extract issues (Azure, fast); deduct credit AFTER this succeeds
|
||||
$emit('progress', ['step' => 'extracting_issues', 'detail' => 'Identifying distinct legal issues…']);
|
||||
@@ -101,7 +110,7 @@ try {
|
||||
'issue_id' => $issue['id'],
|
||||
]);
|
||||
$corpusQuery = $issue['question'] . "\n" . $issue['brief_context'];
|
||||
$corpusContext = $svc->corpusContextForSummarize($corpusQuery, 3);
|
||||
$corpusContext = $svc->corpusContextForSummarize($corpusQuery, 3, $personaResolved['slug'] ?? null);
|
||||
|
||||
$emit('progress', [
|
||||
'step' => 'issue_answering',
|
||||
@@ -122,7 +131,8 @@ try {
|
||||
try {
|
||||
$legalCheck = dbnToolsRunLegalCheck(
|
||||
mb_strimwidth((string)($synth['overall_assessment'] ?? ''), 0, 800),
|
||||
$docType
|
||||
$docType,
|
||||
$personaResolved['system_prompt'] ?? null
|
||||
);
|
||||
} catch (Throwable) {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user