SSW Foursquare

Do you use Semantic Kernel?

Last updated by Jack Reimers [SSW] 8 months ago.See history

There's lots of awesome AI tools being released, but combining these can become very hard as an application scales.
Semantic Kernel can solve this problem by orchestrating all our AI services for us.

What is Semantic Kernel?

Semantic Kernel is an open source SDK developed by Microsoft for their Copilot range of AI tools.
It acts as an orchestration layer between an application and any AI services it may consume, such as the OpenAI API or Azure OpenAI, removing the need to write boilerplate code to use AI.

Microsoft - What is Semantic Kernel?
Semantic Kernel - GitHub Repo

Why use Semantic Kernel?

Semantic Kernel offers many benefits over manually setting up your AI services.

  • Common AI abstractions

    • Resistant to API changes
    • Services can be easily swapped (i.e. from Azure OpenAI to OpenAI API or vice versa)
  • Faster development time
  • Easier maintenance

Using Semantic Kernel, it's easy to set up a basic console chat bot in under 15 lines of code!

using Microsoft.SemanticKernel;

const string endpoint = Environment.GetEnvironmentVariable("AZUREOPENAI_ENDPOINT")!;
const string key = Environment.GetEnvironmentVariable("AZUREOPENAI_API_KEY")!;
const string model = "GPT35Turbo";

var kernel = Kernel.Builder
    .WithAzureChatCompletionService(model, endpoint, key)

while (true)
    Console.WriteLine("Question: ");
    Console.WriteLine(await kernel.InvokeSemanticFunctionAsync(Console.ReadLine()!, maxTokens: 2000));

For a more in depth walkthrough, please see Stephen Toub's article.

We open source. Powered by GitHub