Skip to content

Instantly share code, notes, and snippets.

@conwid
conwid / 07 smartcombobox
Created May 19, 2025 19:57
Gist created from visual studio extension
<form>
<SmartComboBox Url="api/list-toys" @bind-Value=@toy />
</form>
@code {
string? toy;
}
@conwid
conwid / 08 smartcomobboxservice
Created May 19, 2025 19:58
Gist created from visual studio extension
var embedder = app.Services.GetRequiredService<LocalEmbedder>();
var toys = embedder.EmbedRange(["lightsaber", "soccer ball", "rc truck"]);
app.MapSmartComboBox("/api/list-toys",
request =>
{
LocalEmbedder embedder = request.HttpContext.RequestServices.GetRequiredService<LocalEmbedder>();
return embedder.FindClosest(request.Query, toys);
});
@conwid
conwid / 09 inferencebackend
Created May 19, 2025 19:59
Gist created from visual studio extension
public class CustomInferenceBackend(IConfiguration configuration) : IInferenceBackend
{
private readonly OpenAIInferenceBackend openAIInferenceBackend = new OpenAIInferenceBackend(configuration);
public async Task<string> GetChatResponseAsync(ChatParameters options)
{
var resp = await openAIInferenceBackend.GetChatResponseAsync(options);
return resp;
}
}