feat(advisor): Legal-RAG Zitier-Metadaten — ai-sdk + Advisor/Drafting lesen article_label

ai-sdk (legal_rag_client/scroll/types) liest die gepinnten Spec-Felder
article_label/regulation_code/article/paragraph/sub/citation_style/is_recital
mit Fallback auf alt-ingestierte Chunks (regulation_id, section); neuer getBool-Helfer.
Advisor + Drafting-Engine bilden die Quellenzeile primaer aus article_label
("BDSG § 38 Abs. 1"), sonst aus den strukturierten Feldern. 17 Tests gruen, tsc sauber.
Vertrag: docs-src/development/rag_reingest_spec.md (§2/§7). Deploy an den Re-Ingest
gekoppelt — neue Felder sind bis dahin leer (graceful Fallback).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Benjamin Admin
2026-06-20 14:34:15 +02:00
parent b664d73ffc
commit 017c9b3c12
7 changed files with 198 additions and 7 deletions
@@ -18,6 +18,10 @@ interface SdkRagResult {
regulation_code?: string
regulation_name?: string
regulation_short?: string
article_label?: string
article?: string
paragraph?: string
sub?: string
// Rueckwaerts-kompatibel, falls eine Quelle noch das alte rag-service-Format liefert:
content?: string
source_name?: string
@@ -56,12 +60,13 @@ export async function queryRAG(query: string, topK = 3, collection?: string): Pr
return results
.map((r, i) => {
const base =
r.regulation_short || r.regulation_name || r.regulation_code || r.source_name || r.source_code
// article_label = fertig formatierte Fundstelle aus der Ingestion ("BDSG § 38 Abs. 1");
// Fallback baut sie aus den strukturierten Feldern. Siehe rag_reingest_spec.md §2/§7.
const source =
r.regulation_short ||
r.regulation_name ||
r.regulation_code ||
r.source_name ||
r.source_code ||
(r.article_label && r.article_label.trim()) ||
[base, r.article, r.paragraph, r.sub].filter(Boolean).join(' ') ||
'Unbekannt'
const content = r.text || r.content || ''
return `[Quelle ${i + 1}: ${source}]\n${content}`