From e7fb9d59f1f517ae169a40553a2e9a12540bd0c0 Mon Sep 17 00:00:00 2001 From: Benjamin Admin Date: Sat, 28 Feb 2026 18:22:12 +0100 Subject: [PATCH] Fix ChunkBrowserQA: use regulation_id from Qdrant payload instead of regulation_code The Qdrant collections use regulation_id (e.g. eu_2016_679) as the filter key, not regulation_code (e.g. GDPR). Updated rag-constants.ts with correct qdrant_id mappings from actual Qdrant data, fixed API to filter on regulation_id, and updated ChunkBrowserQA to pass qdrant_id values. Co-Authored-By: Claude Opus 4.6 --- .../ai/rag/components/ChunkBrowserQA.tsx | 33 ++- .../app/(admin)/ai/rag/rag-constants.ts | 251 ++++++++++-------- admin-lehrer/app/api/legal-corpus/route.ts | 13 +- 3 files changed, 166 insertions(+), 131 deletions(-) diff --git a/admin-lehrer/app/(admin)/ai/rag/components/ChunkBrowserQA.tsx b/admin-lehrer/app/(admin)/ai/rag/components/ChunkBrowserQA.tsx index 84171b1..f2e0099 100644 --- a/admin-lehrer/app/(admin)/ai/rag/components/ChunkBrowserQA.tsx +++ b/admin-lehrer/app/(admin)/ai/rag/components/ChunkBrowserQA.tsx @@ -84,22 +84,37 @@ export function ChunkBrowserQA({ apiProxy }: ChunkBrowserQAProps) { // Load regulation counts for current collection const loadRegulationCounts = useCallback(async (col: string) => { - const codes = Object.entries(REGULATIONS_IN_RAG) - .filter(([, info]) => info.collection === col) - .map(([code]) => code) - if (codes.length === 0) return + const entries = Object.entries(REGULATIONS_IN_RAG) + .filter(([, info]) => info.collection === col && info.qdrant_id) + if (entries.length === 0) return + + // Build qdrant_id -> our_code mapping + const qdrantIdToCode: Record = {} + for (const [code, info] of entries) { + if (!qdrantIdToCode[info.qdrant_id]) qdrantIdToCode[info.qdrant_id] = [] + qdrantIdToCode[info.qdrant_id].push(code) + } + const uniqueQdrantIds = Object.keys(qdrantIdToCode) setCountsLoading(true) try { const params = new URLSearchParams({ action: 'regulation-counts-batch', collection: col, - codes: codes.join(','), + qdrant_ids: uniqueQdrantIds.join(','), }) const res = await fetch(`${apiProxy}?${params}`) if (res.ok) { const data = await res.json() - setRegulationCounts(prev => ({ ...prev, ...data.counts })) + // Map qdrant_id counts back to our codes + const mapped: Record = {} + for (const [qid, count] of Object.entries(data.counts as Record)) { + const codes = qdrantIdToCode[qid] || [] + for (const code of codes) { + mapped[code] = count + } + } + setRegulationCounts(prev => ({ ...prev, ...mapped })) } } catch (error) { console.error('Failed to load regulation counts:', error) @@ -111,7 +126,7 @@ export function ChunkBrowserQA({ apiProxy }: ChunkBrowserQAProps) { // Load all chunks for a regulation (paginated scroll) const loadDocumentChunks = useCallback(async (regulationCode: string) => { const ragInfo = REGULATIONS_IN_RAG[regulationCode] - if (!ragInfo) return + if (!ragInfo || !ragInfo.qdrant_id) return setDocLoading(true) setDocChunks([]) @@ -129,8 +144,8 @@ export function ChunkBrowserQA({ apiProxy }: ChunkBrowserQAProps) { action: 'scroll', collection: ragInfo.collection, limit: '100', - filter_key: 'regulation_code', - filter_value: regulationCode, + filter_key: 'regulation_id', + filter_value: ragInfo.qdrant_id, }) if (offset) params.append('offset', offset) diff --git a/admin-lehrer/app/(admin)/ai/rag/rag-constants.ts b/admin-lehrer/app/(admin)/ai/rag/rag-constants.ts index 6055034..4e47b99 100644 --- a/admin-lehrer/app/(admin)/ai/rag/rag-constants.ts +++ b/admin-lehrer/app/(admin)/ai/rag/rag-constants.ts @@ -1,110 +1,126 @@ /** * Shared RAG constants used by both page.tsx and ChunkBrowserQA. - * REGULATIONS_IN_RAG maps regulation codes to their Qdrant collection and chunk count. + * REGULATIONS_IN_RAG maps regulation codes to their Qdrant collection, chunk count, and qdrant_id. + * The qdrant_id is the actual `regulation_id` value stored in Qdrant payloads. * REGULATION_INFO provides minimal metadata (code, name, type) for all regulations. */ -export const REGULATIONS_IN_RAG: Record = { - // EU Verordnungen/Richtlinien (bp_compliance_ce) - GDPR: { collection: 'bp_compliance_ce', chunks: 1842 }, - EPRIVACY: { collection: 'bp_compliance_ce', chunks: 156 }, - SCC: { collection: 'bp_compliance_ce', chunks: 89 }, - SCC_FULL_TEXT: { collection: 'bp_compliance_ce', chunks: 154 }, - AIACT: { collection: 'bp_compliance_ce', chunks: 1245 }, - CRA: { collection: 'bp_compliance_ce', chunks: 687 }, - NIS2: { collection: 'bp_compliance_ce', chunks: 534 }, - DGA: { collection: 'bp_compliance_ce', chunks: 312 }, - DSA: { collection: 'bp_compliance_ce', chunks: 978 }, - PLD: { collection: 'bp_compliance_ce', chunks: 124 }, - E_COMMERCE_RL: { collection: 'bp_compliance_ce', chunks: 198 }, - VERBRAUCHERRECHTE_RL: { collection: 'bp_compliance_ce', chunks: 245 }, - DIGITALE_INHALTE_RL: { collection: 'bp_compliance_ce', chunks: 187 }, - DMA: { collection: 'bp_compliance_ce', chunks: 590 }, - DPF: { collection: 'bp_compliance_ce', chunks: 1232 }, - EUCSA: { collection: 'bp_compliance_ce', chunks: 558 }, - DATAACT: { collection: 'bp_compliance_ce', chunks: 809 }, - DORA: { collection: 'bp_compliance_ce', chunks: 823 }, - PSD2: { collection: 'bp_compliance_ce', chunks: 796 }, - AMLR: { collection: 'bp_compliance_ce', chunks: 1182 }, - MiCA: { collection: 'bp_compliance_ce', chunks: 1640 }, - EHDS: { collection: 'bp_compliance_ce', chunks: 1212 }, - EAA: { collection: 'bp_compliance_ce', chunks: 433 }, - DSM: { collection: 'bp_compliance_ce', chunks: 416 }, - GPSR: { collection: 'bp_compliance_ce', chunks: 509 }, - MACHINERY_REG: { collection: 'bp_compliance_ce', chunks: 0 }, - BLUE_GUIDE: { collection: 'bp_compliance_ce', chunks: 0 }, - EU_IFRS_DE: { collection: 'bp_compliance_ce', chunks: 0 }, - EU_IFRS_EN: { collection: 'bp_compliance_ce', chunks: 0 }, - // DE Gesetze (bp_compliance_gesetze) - TDDDG: { collection: 'bp_compliance_gesetze', chunks: 215 }, - BDSG_FULL: { collection: 'bp_compliance_gesetze', chunks: 487 }, - DE_DDG: { collection: 'bp_compliance_gesetze', chunks: 198 }, - DE_BGB_AGB: { collection: 'bp_compliance_gesetze', chunks: 4250 }, - DE_EGBGB: { collection: 'bp_compliance_gesetze', chunks: 312 }, - DE_HGB_RET: { collection: 'bp_compliance_gesetze', chunks: 6840 }, - DE_AO_RET: { collection: 'bp_compliance_gesetze', chunks: 5620 }, - DE_UWG: { collection: 'bp_compliance_gesetze', chunks: 1 }, - DE_TKG: { collection: 'bp_compliance_gesetze', chunks: 1631 }, - DE_PANGV: { collection: 'bp_compliance_gesetze', chunks: 1 }, - DE_DLINFOV: { collection: 'bp_compliance_gesetze', chunks: 21 }, - DE_BETRVG: { collection: 'bp_compliance_gesetze', chunks: 498 }, - DE_GESCHGEHG: { collection: 'bp_compliance_gesetze', chunks: 63 }, - DE_BSIG: { collection: 'bp_compliance_gesetze', chunks: 1 }, - DE_USTG_RET: { collection: 'bp_compliance_gesetze', chunks: 1071 }, - // BSI Standards (bp_compliance_gesetze) - 'BSI-TR-03161-1': { collection: 'bp_compliance_gesetze', chunks: 425 }, - 'BSI-TR-03161-2': { collection: 'bp_compliance_gesetze', chunks: 380 }, - 'BSI-TR-03161-3': { collection: 'bp_compliance_gesetze', chunks: 345 }, - // AT Gesetze (bp_compliance_gesetze) - AT_DSG: { collection: 'bp_compliance_gesetze', chunks: 287 }, - AT_DSG_FULL: { collection: 'bp_compliance_gesetze', chunks: 6 }, - AT_ECG: { collection: 'bp_compliance_gesetze', chunks: 120 }, - AT_TKG: { collection: 'bp_compliance_gesetze', chunks: 2174 }, - AT_KSCHG: { collection: 'bp_compliance_gesetze', chunks: 402 }, - AT_FAGG: { collection: 'bp_compliance_gesetze', chunks: 2 }, - AT_UGB_RET: { collection: 'bp_compliance_gesetze', chunks: 2828 }, - AT_BAO_RET: { collection: 'bp_compliance_gesetze', chunks: 2246 }, - AT_MEDIENG: { collection: 'bp_compliance_gesetze', chunks: 571 }, - AT_ABGB_AGB: { collection: 'bp_compliance_gesetze', chunks: 2521 }, - AT_UWG: { collection: 'bp_compliance_gesetze', chunks: 403 }, - // CH Gesetze (bp_compliance_gesetze) - CH_DSG: { collection: 'bp_compliance_gesetze', chunks: 156 }, - CH_DSV: { collection: 'bp_compliance_gesetze', chunks: 5 }, - CH_OR_AGB: { collection: 'bp_compliance_gesetze', chunks: 5 }, - CH_UWG: { collection: 'bp_compliance_gesetze', chunks: 5 }, - CH_FMG: { collection: 'bp_compliance_gesetze', chunks: 5 }, - CH_GEBUV: { collection: 'bp_compliance_gesetze', chunks: 5 }, - CH_ZERTES: { collection: 'bp_compliance_gesetze', chunks: 5 }, - CH_ZGB_PERS: { collection: 'bp_compliance_gesetze', chunks: 5 }, - // LI - LI_DSG: { collection: 'bp_compliance_gesetze', chunks: 2 }, - // Nationale DSG (andere EU) - ES_LOPDGDD: { collection: 'bp_compliance_gesetze', chunks: 1245 }, - IT_CODICE_PRIVACY: { collection: 'bp_compliance_gesetze', chunks: 198 }, - NL_UAVG: { collection: 'bp_compliance_gesetze', chunks: 1320 }, - FR_CNIL_GUIDE: { collection: 'bp_compliance_gesetze', chunks: 1450 }, - IE_DPA_2018: { collection: 'bp_compliance_gesetze', chunks: 534 }, - UK_DPA_2018: { collection: 'bp_compliance_gesetze', chunks: 1680 }, - UK_GDPR: { collection: 'bp_compliance_gesetze', chunks: 890 }, - NO_PERSONOPPLYSNINGSLOVEN: { collection: 'bp_compliance_gesetze', chunks: 245 }, - SE_DATASKYDDSLAG: { collection: 'bp_compliance_gesetze', chunks: 167 }, - PL_UODO: { collection: 'bp_compliance_gesetze', chunks: 198 }, - CZ_ZOU: { collection: 'bp_compliance_gesetze', chunks: 1120 }, - HU_INFOTV: { collection: 'bp_compliance_gesetze', chunks: 1345 }, - BE_DPA_LAW: { collection: 'bp_compliance_gesetze', chunks: 3 }, - FI_TIETOSUOJALAKI: { collection: 'bp_compliance_gesetze', chunks: 2 }, - DK_DATABESKYTTELSESLOVEN: { collection: 'bp_compliance_gesetze', chunks: 2 }, - LU_DPA_LAW: { collection: 'bp_compliance_gesetze', chunks: 2 }, - // EDPB Guidelines (bp_compliance_datenschutz) - EDPB_GUIDELINES_5_2020: { collection: 'bp_compliance_datenschutz', chunks: 245 }, - EDPB_GUIDELINES_7_2020: { collection: 'bp_compliance_datenschutz', chunks: 347 }, - // Frameworks (bp_compliance_datenschutz) - ENISA_SECURE_BY_DESIGN: { collection: 'bp_compliance_datenschutz', chunks: 0 }, - ENISA_SUPPLY_CHAIN: { collection: 'bp_compliance_datenschutz', chunks: 0 }, - NIST_SSDF: { collection: 'bp_compliance_datenschutz', chunks: 0 }, - NIST_CSF_2: { collection: 'bp_compliance_datenschutz', chunks: 0 }, - OECD_AI_PRINCIPLES: { collection: 'bp_compliance_datenschutz', chunks: 0 }, - EFRAG_ENDORSEMENT: { collection: 'bp_compliance_datenschutz', chunks: 0 }, +export interface RagRegulationEntry { + collection: string + chunks: number + qdrant_id: string // The actual regulation_id value in Qdrant payload +} + +export const REGULATIONS_IN_RAG: Record = { + // === EU Verordnungen/Richtlinien (bp_compliance_ce) === + GDPR: { collection: 'bp_compliance_ce', chunks: 423, qdrant_id: 'eu_2016_679' }, + EPRIVACY: { collection: 'bp_compliance_ce', chunks: 134, qdrant_id: 'eu_2002_58' }, + SCC: { collection: 'bp_compliance_ce', chunks: 330, qdrant_id: 'eu_2021_914' }, + SCC_FULL_TEXT: { collection: 'bp_compliance_ce', chunks: 330, qdrant_id: 'eu_2021_914' }, + AIACT: { collection: 'bp_compliance_ce', chunks: 726, qdrant_id: 'eu_2024_1689' }, + CRA: { collection: 'bp_compliance_ce', chunks: 429, qdrant_id: 'eu_2024_2847' }, + NIS2: { collection: 'bp_compliance_ce', chunks: 342, qdrant_id: 'eu_2022_2555' }, + DGA: { collection: 'bp_compliance_ce', chunks: 508, qdrant_id: 'eu_2022_868' }, + DSA: { collection: 'bp_compliance_ce', chunks: 1106, qdrant_id: 'eu_2022_2065' }, + PLD: { collection: 'bp_compliance_ce', chunks: 44, qdrant_id: 'eu_1985_374' }, + E_COMMERCE_RL: { collection: 'bp_compliance_ce', chunks: 197, qdrant_id: 'eu_2000_31' }, + VERBRAUCHERRECHTE_RL: { collection: 'bp_compliance_ce', chunks: 266, qdrant_id: 'eu_2011_83' }, + DIGITALE_INHALTE_RL: { collection: 'bp_compliance_ce', chunks: 321, qdrant_id: 'eu_2019_770' }, + DMA: { collection: 'bp_compliance_ce', chunks: 701, qdrant_id: 'eu_2022_1925' }, + DPF: { collection: 'bp_compliance_ce', chunks: 2464, qdrant_id: 'dpf' }, + EUCSA: { collection: 'bp_compliance_ce', chunks: 558, qdrant_id: 'eucsa' }, + DATAACT: { collection: 'bp_compliance_ce', chunks: 809, qdrant_id: 'dataact' }, + DORA: { collection: 'bp_compliance_ce', chunks: 823, qdrant_id: 'dora' }, + PSD2: { collection: 'bp_compliance_ce', chunks: 796, qdrant_id: 'psd2' }, + AMLR: { collection: 'bp_compliance_ce', chunks: 1182, qdrant_id: 'amlr' }, + MiCA: { collection: 'bp_compliance_ce', chunks: 1640, qdrant_id: 'mica' }, + EHDS: { collection: 'bp_compliance_ce', chunks: 1212, qdrant_id: 'ehds' }, + EAA: { collection: 'bp_compliance_ce', chunks: 433, qdrant_id: 'eaa' }, + DSM: { collection: 'bp_compliance_ce', chunks: 416, qdrant_id: 'dsm' }, + GPSR: { collection: 'bp_compliance_ce', chunks: 509, qdrant_id: 'gpsr' }, + MACHINERY_REG: { collection: 'bp_compliance_ce', chunks: 1271, qdrant_id: 'eu_2023_1230' }, + BLUE_GUIDE: { collection: 'bp_compliance_ce', chunks: 2271, qdrant_id: 'eu_blue_guide_2022' }, + EU_IFRS_DE: { collection: 'bp_compliance_ce', chunks: 34388, qdrant_id: 'eu_2023_1803' }, + EU_IFRS_EN: { collection: 'bp_compliance_ce', chunks: 34388, qdrant_id: 'eu_2023_1803' }, + // International standards in bp_compliance_ce + NIST_SSDF: { collection: 'bp_compliance_ce', chunks: 111, qdrant_id: 'nist_sp_800_218' }, + NIST_CSF_2: { collection: 'bp_compliance_ce', chunks: 67, qdrant_id: 'nist_csf_2_0' }, + OECD_AI_PRINCIPLES: { collection: 'bp_compliance_ce', chunks: 34, qdrant_id: 'oecd_ai_principles' }, + ENISA_SECURE_BY_DESIGN: { collection: 'bp_compliance_ce', chunks: 97, qdrant_id: 'cisa_secure_by_design' }, + ENISA_SUPPLY_CHAIN: { collection: 'bp_compliance_ce', chunks: 110, qdrant_id: 'enisa_supply_chain_good_practices' }, + ENISA_THREAT_LANDSCAPE: { collection: 'bp_compliance_ce', chunks: 118, qdrant_id: 'enisa_threat_landscape_supply_chain' }, + ENISA_ICS_SCADA: { collection: 'bp_compliance_ce', chunks: 195, qdrant_id: 'enisa_ics_scada_dependencies' }, + ENISA_CYBERSECURITY_2024: { collection: 'bp_compliance_ce', chunks: 22, qdrant_id: 'enisa_cybersecurity_state_2024' }, + + // === DE Gesetze (bp_compliance_gesetze) === + TDDDG: { collection: 'bp_compliance_gesetze', chunks: 5, qdrant_id: 'tdddg_25' }, + TMG_KOMPLETT: { collection: 'bp_compliance_gesetze', chunks: 108, qdrant_id: 'tmg_komplett' }, + BDSG_FULL: { collection: 'bp_compliance_gesetze', chunks: 1056, qdrant_id: 'bdsg_2018_komplett' }, + DE_DDG: { collection: 'bp_compliance_gesetze', chunks: 40, qdrant_id: 'ddg_5' }, + DE_BGB_AGB: { collection: 'bp_compliance_gesetze', chunks: 4024, qdrant_id: 'bgb_komplett' }, + DE_EGBGB: { collection: 'bp_compliance_gesetze', chunks: 36, qdrant_id: 'egbgb_widerruf' }, + DE_HGB_RET: { collection: 'bp_compliance_gesetze', chunks: 11363, qdrant_id: 'hgb_komplett' }, + DE_AO_RET: { collection: 'bp_compliance_gesetze', chunks: 9669, qdrant_id: 'ao_komplett' }, + DE_TKG: { collection: 'bp_compliance_gesetze', chunks: 1631, qdrant_id: 'de_tkg' }, + DE_DLINFOV: { collection: 'bp_compliance_gesetze', chunks: 21, qdrant_id: 'de_dlinfov' }, + DE_BETRVG: { collection: 'bp_compliance_gesetze', chunks: 498, qdrant_id: 'de_betrvg' }, + DE_GESCHGEHG: { collection: 'bp_compliance_gesetze', chunks: 63, qdrant_id: 'de_geschgehg' }, + DE_USTG_RET: { collection: 'bp_compliance_gesetze', chunks: 1071, qdrant_id: 'de_ustg_ret' }, + DE_URHG: { collection: 'bp_compliance_gesetze', chunks: 626, qdrant_id: 'urhg_komplett' }, + + // === BSI Standards (bp_compliance_gesetze) === + 'BSI-TR-03161-1': { collection: 'bp_compliance_gesetze', chunks: 138, qdrant_id: 'bsi_tr_03161_1' }, + 'BSI-TR-03161-2': { collection: 'bp_compliance_gesetze', chunks: 124, qdrant_id: 'bsi_tr_03161_2' }, + 'BSI-TR-03161-3': { collection: 'bp_compliance_gesetze', chunks: 121, qdrant_id: 'bsi_tr_03161_3' }, + + // === AT Gesetze (bp_compliance_gesetze) === + AT_DSG: { collection: 'bp_compliance_gesetze', chunks: 805, qdrant_id: 'at_dsg' }, + AT_DSG_FULL: { collection: 'bp_compliance_gesetze', chunks: 6, qdrant_id: 'at_dsg_full' }, + AT_ECG: { collection: 'bp_compliance_gesetze', chunks: 120, qdrant_id: 'at_ecg' }, + AT_TKG: { collection: 'bp_compliance_gesetze', chunks: 4348, qdrant_id: 'at_tkg' }, + AT_KSCHG: { collection: 'bp_compliance_gesetze', chunks: 402, qdrant_id: 'at_kschg' }, + AT_FAGG: { collection: 'bp_compliance_gesetze', chunks: 2, qdrant_id: 'at_fagg' }, + AT_UGB_RET: { collection: 'bp_compliance_gesetze', chunks: 2828, qdrant_id: 'at_ugb_ret' }, + AT_BAO_RET: { collection: 'bp_compliance_gesetze', chunks: 2246, qdrant_id: 'at_bao_ret' }, + AT_MEDIENG: { collection: 'bp_compliance_gesetze', chunks: 571, qdrant_id: 'at_medieng' }, + AT_ABGB_AGB: { collection: 'bp_compliance_gesetze', chunks: 2521, qdrant_id: 'at_abgb_agb' }, + AT_UWG: { collection: 'bp_compliance_gesetze', chunks: 403, qdrant_id: 'at_uwg' }, + + // === CH Gesetze (bp_compliance_gesetze) === + CH_DSG: { collection: 'bp_compliance_gesetze', chunks: 180, qdrant_id: 'ch_revdsg' }, + CH_DSV: { collection: 'bp_compliance_gesetze', chunks: 5, qdrant_id: 'ch_dsv' }, + CH_OR_AGB: { collection: 'bp_compliance_gesetze', chunks: 5, qdrant_id: 'ch_or_agb' }, + CH_GEBUV: { collection: 'bp_compliance_gesetze', chunks: 5, qdrant_id: 'ch_gebuv' }, + CH_ZERTES: { collection: 'bp_compliance_gesetze', chunks: 5, qdrant_id: 'ch_zertes' }, + CH_ZGB_PERS: { collection: 'bp_compliance_gesetze', chunks: 5, qdrant_id: 'ch_zgb_pers' }, + + // === Nationale Gesetze (andere EU) in bp_compliance_gesetze === + ES_LOPDGDD: { collection: 'bp_compliance_gesetze', chunks: 782, qdrant_id: 'es_lopdgdd' }, + IT_CODICE_PRIVACY: { collection: 'bp_compliance_gesetze', chunks: 59, qdrant_id: 'it_codice_privacy' }, + NL_UAVG: { collection: 'bp_compliance_gesetze', chunks: 523, qdrant_id: 'nl_uavg' }, + FR_CNIL_GUIDE: { collection: 'bp_compliance_gesetze', chunks: 562, qdrant_id: 'fr_loi_informatique' }, + IE_DPA_2018: { collection: 'bp_compliance_gesetze', chunks: 64, qdrant_id: 'ie_dpa_2018' }, + UK_DPA_2018: { collection: 'bp_compliance_gesetze', chunks: 156, qdrant_id: 'uk_dpa_2018' }, + UK_GDPR: { collection: 'bp_compliance_gesetze', chunks: 45, qdrant_id: 'uk_gdpr' }, + NO_PERSONOPPLYSNINGSLOVEN: { collection: 'bp_compliance_gesetze', chunks: 41, qdrant_id: 'no_pol' }, + SE_DATASKYDDSLAG: { collection: 'bp_compliance_gesetze', chunks: 56, qdrant_id: 'se_dataskyddslag' }, + PL_UODO: { collection: 'bp_compliance_gesetze', chunks: 39, qdrant_id: 'pl_ustawa' }, + CZ_ZOU: { collection: 'bp_compliance_gesetze', chunks: 238, qdrant_id: 'cz_zakon' }, + HU_INFOTV: { collection: 'bp_compliance_gesetze', chunks: 747, qdrant_id: 'hu_info_tv' }, + LU_DPA_LAW: { collection: 'bp_compliance_gesetze', chunks: 2, qdrant_id: 'lu_dpa_law' }, + + // === EDPB Guidelines (bp_compliance_datenschutz) === + EDPB_GUIDELINES_5_2020: { collection: 'bp_compliance_datenschutz', chunks: 236, qdrant_id: 'edpb_05_2020' }, + EDPB_GUIDELINES_7_2020: { collection: 'bp_compliance_datenschutz', chunks: 347, qdrant_id: 'edpb_guidelines_7_2020' }, + EDPB_GUIDELINES_1_2020: { collection: 'bp_compliance_datenschutz', chunks: 337, qdrant_id: 'edpb_01_2020' }, + EDPB_GUIDELINES_1_2022: { collection: 'bp_compliance_datenschutz', chunks: 510, qdrant_id: 'edpb_01_2022' }, + EDPB_GUIDELINES_2_2023: { collection: 'bp_compliance_datenschutz', chunks: 94, qdrant_id: 'edpb_02_2023' }, + EDPB_GUIDELINES_2_2024: { collection: 'bp_compliance_datenschutz', chunks: 79, qdrant_id: 'edpb_02_2024' }, + EDPB_GUIDELINES_4_2019: { collection: 'bp_compliance_datenschutz', chunks: 202, qdrant_id: 'edpb_04_2019' }, + EDPB_GUIDELINES_9_2022: { collection: 'bp_compliance_datenschutz', chunks: 243, qdrant_id: 'edpb_09_2022' }, + EDPB_DPIA_LIST: { collection: 'bp_compliance_datenschutz', chunks: 29, qdrant_id: 'edpb_dpia_list' }, + EDPB_LEGITIMATE_INTEREST: { collection: 'bp_compliance_datenschutz', chunks: 336, qdrant_id: 'edpb_legitimate_interest' }, + EDPS_DPIA_LIST: { collection: 'bp_compliance_datenschutz', chunks: 35, qdrant_id: 'edps_dpia_list' }, } /** @@ -151,20 +167,19 @@ export const REGULATION_INFO: RegulationInfo[] = [ { code: 'EU_IFRS_EN', name: 'EU-IFRS (EN)', type: 'eu_regulation' }, // DE Gesetze { code: 'TDDDG', name: 'TDDDG', type: 'de_law' }, + { code: 'TMG_KOMPLETT', name: 'TMG', type: 'de_law' }, { code: 'BDSG_FULL', name: 'BDSG', type: 'de_law' }, { code: 'DE_DDG', name: 'DDG', type: 'de_law' }, { code: 'DE_BGB_AGB', name: 'BGB/AGB', type: 'de_law' }, { code: 'DE_EGBGB', name: 'EGBGB', type: 'de_law' }, { code: 'DE_HGB_RET', name: 'HGB', type: 'de_law' }, { code: 'DE_AO_RET', name: 'AO', type: 'de_law' }, - { code: 'DE_UWG', name: 'UWG', type: 'de_law' }, { code: 'DE_TKG', name: 'TKG', type: 'de_law' }, - { code: 'DE_PANGV', name: 'PAngV', type: 'de_law' }, { code: 'DE_DLINFOV', name: 'DL-InfoV', type: 'de_law' }, { code: 'DE_BETRVG', name: 'BetrVG', type: 'de_law' }, { code: 'DE_GESCHGEHG', name: 'GeschGehG', type: 'de_law' }, - { code: 'DE_BSIG', name: 'BSIG', type: 'de_law' }, { code: 'DE_USTG_RET', name: 'UStG', type: 'de_law' }, + { code: 'DE_URHG', name: 'UrhG', type: 'de_law' }, // BSI { code: 'BSI-TR-03161-1', name: 'BSI-TR Teil 1', type: 'bsi_standard' }, { code: 'BSI-TR-03161-2', name: 'BSI-TR Teil 2', type: 'bsi_standard' }, @@ -185,13 +200,9 @@ export const REGULATION_INFO: RegulationInfo[] = [ { code: 'CH_DSG', name: 'DSG Schweiz', type: 'ch_law' }, { code: 'CH_DSV', name: 'DSV', type: 'ch_law' }, { code: 'CH_OR_AGB', name: 'OR/AGB', type: 'ch_law' }, - { code: 'CH_UWG', name: 'UWG CH', type: 'ch_law' }, - { code: 'CH_FMG', name: 'FMG', type: 'ch_law' }, { code: 'CH_GEBUV', name: 'GeBuV', type: 'ch_law' }, { code: 'CH_ZERTES', name: 'ZertES', type: 'ch_law' }, { code: 'CH_ZGB_PERS', name: 'ZGB', type: 'ch_law' }, - // LI - { code: 'LI_DSG', name: 'DSG Liechtenstein', type: 'national_law' }, // Andere EU nationale { code: 'ES_LOPDGDD', name: 'LOPDGDD Spanien', type: 'national_law' }, { code: 'IT_CODICE_PRIVACY', name: 'Codice Privacy Italien', type: 'national_law' }, @@ -205,18 +216,26 @@ export const REGULATION_INFO: RegulationInfo[] = [ { code: 'PL_UODO', name: 'UODO Polen', type: 'national_law' }, { code: 'CZ_ZOU', name: 'Zakon Tschechien', type: 'national_law' }, { code: 'HU_INFOTV', name: 'Infotv. Ungarn', type: 'national_law' }, - { code: 'BE_DPA_LAW', name: 'Datenschutzgesetz Belgien', type: 'national_law' }, - { code: 'FI_TIETOSUOJALAKI', name: 'Tietosuojalaki Finnland', type: 'national_law' }, - { code: 'DK_DATABESKYTTELSESLOVEN', name: 'Databeskyttelsesloven DK', type: 'national_law' }, { code: 'LU_DPA_LAW', name: 'Datenschutzgesetz Luxemburg', type: 'national_law' }, // EDPB { code: 'EDPB_GUIDELINES_5_2020', name: 'EDPB GL Einwilligung', type: 'eu_guideline' }, { code: 'EDPB_GUIDELINES_7_2020', name: 'EDPB GL C/P Konzepte', type: 'eu_guideline' }, - // Frameworks - { code: 'ENISA_SECURE_BY_DESIGN', name: 'ENISA Secure by Design', type: 'international_standard' }, - { code: 'ENISA_SUPPLY_CHAIN', name: 'ENISA Supply Chain', type: 'international_standard' }, + { code: 'EDPB_GUIDELINES_1_2020', name: 'EDPB GL Fahrzeuge', type: 'eu_guideline' }, + { code: 'EDPB_GUIDELINES_1_2022', name: 'EDPB GL Bussgelder', type: 'eu_guideline' }, + { code: 'EDPB_GUIDELINES_2_2023', name: 'EDPB GL Art. 37 Scope', type: 'eu_guideline' }, + { code: 'EDPB_GUIDELINES_2_2024', name: 'EDPB GL 2024', type: 'eu_guideline' }, + { code: 'EDPB_GUIDELINES_4_2019', name: 'EDPB GL Art. 25 DPbD', type: 'eu_guideline' }, + { code: 'EDPB_GUIDELINES_9_2022', name: 'EDPB GL Datenschutzverletzung', type: 'eu_guideline' }, + { code: 'EDPB_DPIA_LIST', name: 'EDPB DPIA-Liste', type: 'eu_guideline' }, + { code: 'EDPB_LEGITIMATE_INTEREST', name: 'EDPB Berecht. Interesse', type: 'eu_guideline' }, + { code: 'EDPS_DPIA_LIST', name: 'EDPS DPIA-Liste', type: 'eu_guideline' }, + // International Standards { code: 'NIST_SSDF', name: 'NIST SSDF', type: 'international_standard' }, { code: 'NIST_CSF_2', name: 'NIST CSF 2.0', type: 'international_standard' }, { code: 'OECD_AI_PRINCIPLES', name: 'OECD AI Principles', type: 'international_standard' }, - { code: 'EFRAG_ENDORSEMENT', name: 'EFRAG Endorsement', type: 'eu_guideline' }, + { code: 'ENISA_SECURE_BY_DESIGN', name: 'CISA Secure by Design', type: 'international_standard' }, + { code: 'ENISA_SUPPLY_CHAIN', name: 'ENISA Supply Chain', type: 'international_standard' }, + { code: 'ENISA_THREAT_LANDSCAPE', name: 'ENISA Threat Landscape', type: 'international_standard' }, + { code: 'ENISA_ICS_SCADA', name: 'ENISA ICS/SCADA', type: 'international_standard' }, + { code: 'ENISA_CYBERSECURITY_2024', name: 'ENISA Cybersecurity 2024', type: 'international_standard' }, ] diff --git a/admin-lehrer/app/api/legal-corpus/route.ts b/admin-lehrer/app/api/legal-corpus/route.ts index b0f5f4f..d483f7f 100644 --- a/admin-lehrer/app/api/legal-corpus/route.ts +++ b/admin-lehrer/app/api/legal-corpus/route.ts @@ -121,24 +121,25 @@ export async function GET(request: NextRequest) { } case 'regulation-counts-batch': { const col = searchParams.get('collection') || 'bp_compliance_gesetze' - const codes = (searchParams.get('codes') || '').split(',').filter(Boolean) + // Accept qdrant_ids (actual regulation_id values in Qdrant payload) + const qdrantIds = (searchParams.get('qdrant_ids') || '').split(',').filter(Boolean) const results: Record = {} - for (let i = 0; i < codes.length; i += 10) { - const batch = codes.slice(i, i + 10) - await Promise.all(batch.map(async (code) => { + for (let i = 0; i < qdrantIds.length; i += 10) { + const batch = qdrantIds.slice(i, i + 10) + await Promise.all(batch.map(async (qid) => { try { const res = await fetch(`${QDRANT_URL}/collections/${encodeURIComponent(col)}/points/count`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ - filter: { must: [{ key: 'regulation_code', match: { value: code } }] }, + filter: { must: [{ key: 'regulation_id', match: { value: qid } }] }, exact: true, }), cache: 'no-store', }) if (res.ok) { const data = await res.json() - results[code] = data.result?.count || 0 + results[qid] = data.result?.count || 0 } } catch { /* skip failed counts */ } }))