Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob] Show score if query contains score threshold

Neeraj Guptaaaebef5b2208
diff --git a/mobile/lib/models/file/file.dart b/mobile/lib/models/file/file.dart
index 40d4a388af..979cf27059 100644
--- a/mobile/lib/models/file/file.dart
+++ b/mobile/lib/models/file/file.dart
@@ -268,9 +268,11 @@ class EnteFile {
}
String? get caption {
- return pubMagicMetadata?.caption;
+ return debugCaption ?? pubMagicMetadata?.caption;
}
+ String? debugCaption;
+
String get thumbnailUrl {
if (localFileServer.isNotEmpty) {
return "$localFileServer/thumb/$uploadedFileID";
diff --git a/mobile/lib/services/machine_learning/semantic_search/semantic_search_service.dart b/mobile/lib/services/machine_learning/semantic_search/semantic_search_service.dart
index 44c90964e2..f8354f49c9 100644
--- a/mobile/lib/services/machine_learning/semantic_search/semantic_search_service.dart
+++ b/mobile/lib/services/machine_learning/semantic_search/semantic_search_service.dart
@@ -144,12 +144,14 @@ class SemanticSearchService {
String query, {
double? scoreThreshold,
}) async {
+ bool showScore = false;
// if the query starts with 0.xxx, the split the query to get score threshold and actual query
if (query.startsWith(RegExp(r"0\.\d+"))) {
final parts = query.split(" ");
if (parts.length > 1) {
scoreThreshold = double.parse(parts[0]);
query = parts.sublist(1).join(" ");
+ showScore = true;
}
}
final textEmbedding = await _getTextEmbedding(query);
@@ -165,6 +167,11 @@ class SemanticSearchService {
dev.log("Query: $query, Score: ${result.score}, index $i");
}
+ final Map<int, double> fileIDToScoreMap = {};
+ for (final result in queryResults) {
+ fileIDToScoreMap[result.id] = result.score;
+ }
+
final filesMap = await FilesDB.instance
.getFilesFromIDs(queryResults.map((e) => e.id).toList());
@@ -177,8 +184,13 @@ class SemanticSearchService {
for (final result in queryResults) {
final file = filesMap[result.id];
if (file != null && !ignoredCollections.contains(file.collectionID)) {
+ if (showScore) {
+ file.debugCaption =
+ "${fileIDToScoreMap[result.id]?.toStringAsFixed(3)}";
+ }
results.add(file);
}
+
if (file == null) {
deletedEntries.add(result.id);
}
diff --git a/mobile/lib/ui/viewer/file/thumbnail_widget.dart b/mobile/lib/ui/viewer/file/thumbnail_widget.dart
index 86e6cd1c41..4ace74da94 100644
--- a/mobile/lib/ui/viewer/file/thumbnail_widget.dart
+++ b/mobile/lib/ui/viewer/file/thumbnail_widget.dart
@@ -201,6 +201,8 @@ class _ThumbnailWidgetState extends State<ThumbnailWidget> {
viewChildren.add(TrashedFileOverlayText(widget.file as TrashFile));
} else if (GalleryContextState.of(context)?.type == GroupType.size) {
viewChildren.add(FileSizeOverlayText(widget.file));
+ } else if (widget.file.debugCaption != null) {
+ viewChildren.add(FileOverlayText(widget.file.debugCaption!));
}
// todo: Move this icon overlay to the collection widget.
if (widget.shouldShowArchiveStatus) {