Skip to content
This repository has been archived by the owner on Aug 20, 2024. It is now read-only.

Smart ComboBox always posts 5 as the value of similarityThreshold #64

Open
Mimisss opened this issue Jul 9, 2024 · 1 comment
Open

Comments

@Mimisss
Copy link

Mimisss commented Jul 9, 2024

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:

If you run the application, you'll see it now does suggest semantic matches. For example, if you type "cat" it will suggest "Pet Care", whereas if you type "plane" it will suggest "Travel".

Actual behavior:
Nothing happens. No error(s).

@Mimisss
Copy link
Author

Mimisss commented Jul 31, 2024

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);
}

@Mimisss Mimisss changed the title [ExampleMvcRazorPagesApp]: Smart ComboBox sample does not work [ExampleMvcRazorPagesApp]: Smart ComboBox always posts 5 as the value of similarityThreshold Jul 31, 2024
@Mimisss Mimisss changed the title [ExampleMvcRazorPagesApp]: Smart ComboBox always posts 5 as the value of similarityThreshold Smart ComboBox always posts 5 as the value of similarityThreshold Jul 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant