Dokumentation » KI-System » RAG Collections

RAG Collections

Erstellt: 2025-12-21 | Aktualisiert: 2025-12-31

Verwaltung der Qdrant-Collections für RAG-Suche in Chat und Content Studio.

Datenbankki_dev
Tabellerag_collections
Repository/src/Infrastructure/Persistence/CollectionRepository.php
Qdrant-APIhttp://localhost:6333

Zweck

Die Tabelle rag_collections synchronisiert Metadaten von Qdrant-Collections mit der Anwendung:

Schema

SpalteTypDefaultBeschreibung
idINT AUTO_INCREMENT-Primary Key
collection_idVARCHAR(100) UNIQUE-Qdrant Collection-Name
display_nameVARCHAR(100)-Anzeigename in UI
descriptionTEXTNULLBeschreibung
vector_sizeINTNULLEmbedding-Dimension (z.B. 1024)
distance_metricVARCHAR(20)NULLCosine, Euclidean, Dot
points_countINT0Anzahl Vektoren
embedding_modelVARCHAR(100)NULLz.B. mxbai-embed-large
chunk_sizeINTNULLChunk-Größe in Zeichen
chunk_overlapINTNULLChunk-Überlappung
source_typeENUM'manual'nextcloud, mail, manual, system
source_pathVARCHAR(500)NULLQuellpfad (z.B. Nextcloud-Ordner)
is_activeTINYINT(1)1Collection aktiv
is_searchableTINYINT(1)1In Suche verfügbar
sort_orderINT0Sortierung in UI
last_synced_atDATETIMENULLLetzte Synchronisation
created_atDATETIMECURRENT_TIMESTAMPErstellungszeitpunkt
updated_atDATETIMECURRENT_TIMESTAMPLetzte Änderung

Aktuelle Collections (Qdrant)

Collections werden in /var/www/scripts/pipeline/config.py definiert:

collection_iddisplay_namevector_sizeZweck
documentsDokumente1024Nextcloud-Dokumente (PDF, DOCX, etc.)
mailE-Mails1024E-Mail-Archiv
entitiesEntitäten1024Extrahierte Entitäten mit Embeddings

Repository-Methoden

// Alle suchbaren Collections abrufen
$collections = $collectionRepository->getSearchable();

// Collection-Details
$collection = $collectionRepository->findById('documents');

// Statistiken aktualisieren (Qdrant-Sync)
$collectionRepository->syncFromQdrant();

Validierung

Bei Multi-Collection-Suche müssen alle Collections die gleiche Embedding-Dimension haben:

$validator = new CollectionValidator($collectionRepository);
$result = $validator->validateSelection(['documents', 'entities']);

if (!$result->isValid()) {
    throw new \InvalidArgumentException($result->getError());
}

UI-Integration

Collections werden als Checkbox-Gruppe in Chat und Content Studio angezeigt:

<?php
$selected = ['documents'];
$variant = 'checkbox';
include __DIR__ . '/../partials/form/collections-select.php';
?>

Siehe auch

Änderungshistorie

DatumÄnderung
2025-12-31Collections korrigiert: entities hinzugefügt, dokumentation entfernt (existiert nicht in Qdrant)
2025-12-21Initial erstellt
]]>