Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/SemanticKernel/src/SemanticKernelMemoryStoreCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,22 @@
{
request = request ?? throw new ArgumentNullException(nameof(request));
settings ??= new VectorSearchSettings();
var results = await store.GetNearestMatchesAsync(Name, request.Embeddings.First(), limit: settings.NumberOfResults, cancellationToken: cancellationToken)
var results = await store.GetNearestMatchesAsync(Name, request.Embeddings.First(), limit: settings.NumberOfResults, cancellationToken: cancellationToken, minRelevanceScore: settings.ScoreThreshold ?? 0)
.ToListAsync(cancellationToken).ConfigureAwait(false);
return new VectorSearchResponse { Items = results.Select(x => new Vector { Text = x.Item1.Metadata.ExternalSourceName }).ToList() };
return new VectorSearchResponse { Items = results.Select(x => new Vector
{
Text = x.Item1.Metadata.ExternalSourceName,
Metadata = !string.IsNullOrEmpty(x.Item1.Metadata.AdditionalMetadata)
? x.Item1.Metadata.AdditionalMetadata
.Split('#')
.Where(part => !string.IsNullOrEmpty(part) && part.Contains('&'))

Check warning on line 82 in src/SemanticKernel/src/SemanticKernelMemoryStoreCollection.cs

View workflow job for this annotation

GitHub Actions / Build and test / Build, test and publish

'string.Contains(char)' has a method overload that takes a 'StringComparison' parameter. Replace this call in 'LangChain.Databases.SemanticKernel.SemanticKernelMemoryStoreCollection.SearchAsync(LangChain.Databases.VectorSearchRequest, LangChain.Databases.VectorSearchSettings?, System.Threading.CancellationToken)' with a call to 'string.Contains(char, System.StringComparison)' for clarity of intent. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1307)

Check warning on line 82 in src/SemanticKernel/src/SemanticKernelMemoryStoreCollection.cs

View workflow job for this annotation

GitHub Actions / Build and test / Build, test and publish

'string.Contains(char)' has a method overload that takes a 'StringComparison' parameter. Replace this call in 'LangChain.Databases.SemanticKernel.SemanticKernelMemoryStoreCollection.SearchAsync(LangChain.Databases.VectorSearchRequest, LangChain.Databases.VectorSearchSettings?, System.Threading.CancellationToken)' with a call to 'string.Contains(char, System.StringComparison)' for clarity of intent. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1307)

Check warning on line 82 in src/SemanticKernel/src/SemanticKernelMemoryStoreCollection.cs

View workflow job for this annotation

GitHub Actions / Build and test / Build, test and publish

'string.Contains(char)' has a method overload that takes a 'StringComparison' parameter. Replace this call in 'LangChain.Databases.SemanticKernel.SemanticKernelMemoryStoreCollection.SearchAsync(LangChain.Databases.VectorSearchRequest, LangChain.Databases.VectorSearchSettings?, System.Threading.CancellationToken)' with a call to 'string.Contains(char, System.StringComparison)' for clarity of intent. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1307)

Check warning on line 82 in src/SemanticKernel/src/SemanticKernelMemoryStoreCollection.cs

View workflow job for this annotation

GitHub Actions / Build and test / Build, test and publish

'string.Contains(char)' has a method overload that takes a 'StringComparison' parameter. Replace this call in 'LangChain.Databases.SemanticKernel.SemanticKernelMemoryStoreCollection.SearchAsync(LangChain.Databases.VectorSearchRequest, LangChain.Databases.VectorSearchSettings?, System.Threading.CancellationToken)' with a call to 'string.Contains(char, System.StringComparison)' for clarity of intent. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1307)
.Select(part => part.Split('&'))
.Where(split => split.Length == 2)
.ToDictionary(split => split[0], split => (object)split[1])
: null,
RelevanceScore = (float)x.Item2
}).ToList()
};
}

Task<IReadOnlyList<Vector>> IVectorCollection.SearchByMetadata(Dictionary<string, object> filters, CancellationToken cancellationToken)
Expand Down