Skip to content

Instantly share code, notes, and snippets.

@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;
}
}
@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 / 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 / 06smarttextinference
Created May 19, 2025 19:57
Gist created from visual studio extension
public class CustomSmartTextAreaInference : SmartTextAreaInference
{
public override ChatParameters BuildPrompt(
SmartTextAreaConfig config, string textBefore, string textAfter)
{
var prompt = base.BuildPrompt(config, textBefore, textAfter);
return prompt;
}
}
@conwid
conwid / 05 smarttextarea
Created May 19, 2025 19:57
Gist created from visual studio extension
<SmartTextArea @bind-Value="@text" UserRole="@userRole" UserPhrases="@userPhrases"/>
@code {
private string? text;
private string userRole = "HR professional replying to applications for a role";
private string[] userPhrases = [
"Thank your for your interest in NEED_INFO",
"We have reviewed your application",
"Unfortunately we have decided not to move forward",
@conwid
conwid / 04 smartpasteinput
Created May 19, 2025 19:56
Gist created from visual studio extension
Hi Gopas,
My name is Akos Nagy. I'm writing to apply for the role AI trainer. I have a master's degree in computer engineering from the Budapest Unviersity of technology and economics and have passed Microsoft AI-900 and AI-102.
@conwid
conwid / 04smartasteinference
Created May 19, 2025 19:55
Gist created from visual studio extension
public class CustomSmartPasteInference : SmartPasteInference
{
public override ChatParameters BuildPrompt(SmartPasteRequestData data)
{
var prompt = base.BuildPrompt(data);
return prompt;
}
}
@conwid
conwid / 01 config
Created May 19, 2025 19:50
Gist created from visual studio extension
"SmartComponents": {
"ApiKey": "AWTI4Cdf1YIcfu7SgHbvKdfpmEQkWFs8d8C3lfHXaawAIqq1lXM9JQQJ99BEAC5RqLJXJ3w3AAABACOGMbXv",
"DeploymentName": "gpt-4.1-nano",
"Endpoint": "https://akos.openai.azure.com/"
}
@conwid
conwid / 01 service setup
Created May 19, 2025 19:49
Gist created from visual studio extension
builder.Services.AddSmartComponents()
.WithInferenceBackend<CustomInferenceBackend>()
.WithAntiforgeryValidation();
@conwid
conwid / 03 editform
Created May 19, 2025 19:48
Gist created from visual studio extension
<EditForm Model="@applyModelSource" OnValidSubmit="SubmitAsync">
<DataAnnotationsValidator />
<ValidationSummary />
<div class="form-group">
<InputText @bind-Value="applyModelSource.Name" />
</div>
<div class="form-group">
<InputText @bind-Value="applyModelSource.Role" />
</div>