Skip to content

[Experimental] Intelligent app features provided as prebuilt .NET components

License

Notifications You must be signed in to change notification settings

dotnet/smartcomponents

Repository files navigation

.NET Smart Components

.NET Smart Components shows you how to add genuinely useful AI-powered features to your .NET apps quickly, easily, and without risking wasted effort.

You don't have to spend weeks of dev time redesigning your UX or researching machine learning and prompt engineering. .NET Smart Components are prebuilt end-to-end AI features that you can drop into your existing UIs to upgrade them, truly making your app more productive for your end users.

The .NET Smart Components are provided as sample implementations that we hope will inspire a rich ecosystem of AI-powered component libraries for .NET developers to use.

The easist way to see the .NET Smart Components in action, is to run the prebuilt samples.

You can try out the .NET Smart Components in your own ASP.NET Core apps targeting .NET 6 or later with either:

We may add support for other UI tech (e.g., native apps) later, depending on feedback.

What's included

The set of components and features may expand over time. Currently, .NET Smart Components includes:

Smart Paste

A button that fills out forms automatically using data from the user's clipboard. You can use this with any existing form in your web app. This helps users add data from external sources without re-typing.

Screen capture of Smart Paste feature

Learn more: Smart Paste docs

Smart TextArea

An intelligent upgrade to the traditional textarea. You can configure how it should autocomplete whole sentences using your own preferred tone, policies, URLs, and so on. This helps users type faster and not have to remember URLs etc.

Screen capture of Smart TextArea feature

Learn more: Smart TextArea docs

Smart ComboBox

Upgrades the traditional combobox by making suggestions based on semantic matching. This helps users find what they're looking for.

Screen capture of Smart ComboBox feature

Learn more: Smart ComboBox docs

Local Embeddings

Computes the level of semantic similarity between two natural language strings, or finds the closest match from a set of candidates. This runs entirely locally on your server's CPU, so doesn't need any external AI service.

Example: evaluating the semantic similarity between two strings

var article1 = embedder.Embed("Vacation allowance policy");
var article2 = embedder.Embed("Returning a company vehicle");
var article3 = embedder.Embed("How to get your boss fired");

var searchTerm = embedder.Embed("car");
Console.WriteLine(searchTerm.Similarity(article1)); // Outputs: 0.41
Console.WriteLine(searchTerm.Similarity(article2)); // Outputs: 0.70
Console.WriteLine(searchTerm.Similarity(article3)); // Outputs: 0.38

Example: finding closest matches

// Find closest matches to "ball game"
var candidates = embedder.EmbedRange(["Soccer", "Tennis", "Swimming", "Horse riding", "Golf", "Gymnastics"]);

var closest = LocalEmbedder.FindClosest(
    embedder.Embed("ball game"), candidates, maxResults: 3);

Console.WriteLine(string.Join(", ", closest)); // "Soccer, Golf, Tennis"

Unlike the others, this isn't a prebuilt end-to-end UI feature; it's a general capability you can use to power your own features, such as search or retrieval-augmented generation (RAG).

Learn more: Local Embeddings docs

Running the samples

  1. If you don't already have it, install a current .NET SDK for Windows, Linux, or Mac.

  2. Clone this repo.

    git clone https://github.com/dotnet/smartcomponents.git
    cd smartcomponents
  3. If you want to run the Smart Paste or Smart TextArea samples, you'll need to first configure an OpenAI backend.

    You can skip this if you only want to run the Smart ComboBox or Local Embeddings samples, since they run entirely locally.

  4. Run it.

    cd samples/ExampleBlazorApp
    dotnet run

Once you're ready to add .NET Smart Components to your own app, see:

Feedback

To give feedback on these samples, post an issue here.

Contributing

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.