Open Mimisss opened 4 months ago
Must be foul play with the similarity-threshold
parameter of the component. The value posted is always 5. For example, both:
<smart-combobox id="accounting-category" url="~/api/suggestions/accounting-categories" />
and
<smart-combobox id="accounting-category" url="~/api/suggestions/accounting-categories" similarity-threshold="0.5f" />
always post 5 as the value of similarity threshold instead of 0.5.
As a result, FindClosest
returns no matches.
I've tested it by implementing the API endpoint manually:
public IActionResult ExpenseCategories([FromForm] SuggestionsParams request)
{
var expenseCategories = _embedder.EmbedRange(new[]
{ "Groceries", "Utilities", "Rent", "Mortgage", "Car Payment", "Car Insurance", "Health Insurance", "Life Insurance", "Home Insurance", "Gas", "Public Transportation", "Dining Out", "Entertainment", "Travel", "Clothing", "Electronics", "Home Improvement", "Gifts", "Charity", "Education", "Childcare", "Pet Care", "Other" });
var similarityQuery = new SmartComponents.Inference.SimilarityQuery()
{
SearchText = request.inputValue,
MaxResults = request.maxResults,
MinSimilarity = request.similarityThreshold // <--- always 5
};
var result = _embedder.FindClosest(similarityQuery, expenseCategories);
return Ok(result);
}
Smart ComboBox always posts 5 as the value of similarityThreshold. As a result, the MVC/Razor Pages example does not work out of the box.
Sample https://github.com/dotnet-smartcomponents/smartcomponents/tree/main/samples/ExampleMvcRazorPagesApp
Page https://localhost:7227/smartcombobox
Expected behavior:
Actual behavior: Nothing happens. No error(s).