[mob] Allow injecting score threshold in query

This commit is contained in:
Neeraj Gupta 2024-08-14 15:37:29 +05:30
parent b7acd3033d
commit 0c20be98d7

View File

@ -144,6 +144,14 @@ class SemanticSearchService {
String query, {
double? scoreThreshold,
}) async {
// 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(" ");
}
}
final textEmbedding = await _getTextEmbedding(query);
final queryResults = await _getSimilarities(