removeSource method

Future<void> removeSource(
  1. int sourceId
)

Remove a source and all its chunks from the database.

Implementation

Future<void> removeSource(int sourceId) async {
  try {
    await rust_rag.deleteSourceInCollection(
      collectionId: collectionId,
      sourceId: sourceId,
    );
    await _markDirty(); // Mark index as dirty (Persistent)
  } on RagError catch (e) {
    debugPrint(
      '[SmartError] Failed to remove source $sourceId: ${e.message}',
    );
    rethrow;
  }
  // Note: HNSW index is not automatically updated.
  // It's recommended to call rebuildIndex() if many sources are deleted.
}