delete table option

This commit is contained in:
laurenspriem
2025-05-09 12:57:44 +05:30
parent d411d91966
commit 2f5a02ec43
2 changed files with 13 additions and 17 deletions

View File

@@ -111,6 +111,17 @@ class ClipVectorDB {
}
}
Future<void> deleteIndex() async {
final db = await _vectorDB;
try {
await db.deleteIndex();
_vectorDbFuture = null;
} catch (e, s) {
_logger.severe("Error deleting index", e, s);
rethrow;
}
}
Future<(int, int, int)> getIndexStats() async {
final db = await _vectorDB;
try {

View File

@@ -211,7 +211,7 @@ class _MLDebugSectionWidgetState extends State<MLDebugSectionWidget> {
sectionOptionSpacing,
MenuItemWidget(
captionedTextWidget: const CaptionedTextWidget(
title: "Empty ClipVectorDB",
title: "Delete/Empty ClipVectorDB",
),
pressedColor: getEnteColorScheme(context).fillFaint,
trailingIcon: Icons.chevron_right_outlined,
@@ -219,22 +219,7 @@ class _MLDebugSectionWidgetState extends State<MLDebugSectionWidget> {
onTap: () async {
try {
final clipVectorDB = ClipVectorDB.instance;
final stats = await clipVectorDB.getIndexStats();
logger.info("ClipVectorDB stats: size: ${stats.$1}, "
"capacity: ${stats.$2}, dimensions: ${stats.$3}");
showShortToast(
context,
"ClipVectorDB stats: size: ${stats.$1}, "
"capacity: ${stats.$2}, dimensions: ${stats.$3}");
await clipVectorDB.deleteAllEmbeddings();
final statsAfter = await clipVectorDB.getIndexStats();
logger.info("ClipVectorDB stats after: size: ${statsAfter.$1}, "
"capacity: ${statsAfter.$2}, dimensions: ${statsAfter.$3}");
showShortToast(
context,
"ClipVectorDB stats after: size: ${statsAfter.$1}, "
"capacity: ${statsAfter.$2}, dimensions: ${statsAfter.$3}");
await clipVectorDB.deleteIndex();
} catch (e, s) {
logger.warning('ClipVectorDB cleanup failed ', e, s);
await showGenericErrorDialog(context: context, error: e);