fix(compliance-advisor): Update RAG endpoint to use DSFA corpus API
Switch from /admin/legal-corpus/search to /dsfa-rag/search endpoint. Add RAGResult interface for type safety. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -76,12 +76,20 @@ Diese gehoeren nicht zum Datenschutz-Kompetenzbereich.
|
||||
- Bei widerspruechlichen Rechtslagen: Beide Positionen darstellen und DSB-Konsultation empfehlen
|
||||
- Bei dringenden Datenpannen: Auf 72-Stunden-Frist (Art. 33 DSGVO) hinweisen und Notfallplan-Modul empfehlen`
|
||||
|
||||
interface RAGResult {
|
||||
content: string
|
||||
source_name: string
|
||||
source_code: string
|
||||
attribution_text: string
|
||||
score: number
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the RAG legal corpus for relevant documents
|
||||
* Query the DSFA RAG corpus for relevant documents
|
||||
*/
|
||||
async function queryRAG(query: string): Promise<string> {
|
||||
try {
|
||||
const url = `${KLAUSUR_SERVICE_URL}/api/v1/admin/legal-corpus/search?query=${encodeURIComponent(query)}&top_k=5`
|
||||
const url = `${KLAUSUR_SERVICE_URL}/api/v1/dsfa-rag/search?query=${encodeURIComponent(query)}&top_k=5`
|
||||
const res = await fetch(url, {
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
signal: AbortSignal.timeout(10000),
|
||||
@@ -97,8 +105,8 @@ async function queryRAG(query: string): Promise<string> {
|
||||
if (data.results && data.results.length > 0) {
|
||||
return data.results
|
||||
.map(
|
||||
(r: { metadata?: { regulation?: string; source?: string }; text?: string; content?: string }, i: number) =>
|
||||
`[Quelle ${i + 1}: ${r.metadata?.regulation || r.metadata?.source || 'Unbekannt'}]\n${r.text || r.content || ''}`
|
||||
(r: RAGResult, i: number) =>
|
||||
`[Quelle ${i + 1}: ${r.source_name || r.source_code || 'Unbekannt'}]\n${r.content || ''}`
|
||||
)
|
||||
.join('\n\n---\n\n')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user