feat(advisor): wire structured controls into compliance-advisor (HELD, not deployed)
Prompt-augments the RAG-only advisor with the shared use-case->controls API: deterministic topic detection -> local controls API -> context block, so the agent can answer from real Control-IDs. 100% local at runtime (no Anthropic). NOT pushed/deployed: the shared API currently returns MASTER-grain controls, whose composition is broken (gpre2 object-only clustering -> mega-clusters). Pending the atom-grain rework of the API. tsc + vitest green. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
|
||||
import { NextRequest, NextResponse } from 'next/server'
|
||||
import { readSoulFile } from '@/lib/sdk/agents/soul-reader'
|
||||
import { buildControlsContext } from '@/lib/sdk/agents/controls-augmentation'
|
||||
|
||||
const RAG_SERVICE_URL = process.env.RAG_SERVICE_URL || 'http://rag-service:8097'
|
||||
const OLLAMA_URL = process.env.OLLAMA_URL || 'http://host.docker.internal:11434'
|
||||
@@ -137,8 +138,12 @@ export async function POST(request: NextRequest) {
|
||||
// Validate country parameter
|
||||
const validCountry = ['DE', 'AT', 'CH', 'EU'].includes(country) ? (country as Country) : undefined
|
||||
|
||||
// 1. Query RAG across all collections
|
||||
const ragContext = await queryMultiCollectionRAG(message, validCountry)
|
||||
// 1. Query RAG across all collections + structured controls for the topic
|
||||
// (both local; the controls block lets the agent answer from real Control-IDs)
|
||||
const [ragContext, controlsContext] = await Promise.all([
|
||||
queryMultiCollectionRAG(message, validCountry),
|
||||
buildControlsContext(message),
|
||||
])
|
||||
|
||||
// 2. Build system prompt with RAG context + country
|
||||
const soulPrompt = await readSoulFile('compliance-advisor')
|
||||
@@ -158,6 +163,10 @@ Der Nutzer hat "${countryLabel} (${validCountry})" gewaehlt.
|
||||
systemContent += `\n\n## Relevanter Kontext aus dem RAG-System\n\nNutze die folgenden Quellen fuer deine Antwort. Verweise in deiner Antwort auf die jeweilige Quelle:\n\n${ragContext}`
|
||||
}
|
||||
|
||||
if (controlsContext) {
|
||||
systemContent += `\n\n${controlsContext}`
|
||||
}
|
||||
|
||||
systemContent += `\n\n## Aktueller SDK-Schritt\nDer Nutzer befindet sich im SDK-Schritt: ${currentStep}`
|
||||
|
||||
// 3. Build messages array (limit history to last 6 messages)
|
||||
|
||||
Reference in New Issue
Block a user