Semantic Kernel in 7 mins

Charles Calapini
Dev Genius
Published in
4 min readNov 9, 2023
Youtube thumbnail for SK Video: https://www.youtube.com/watch?v=90hhJHTWz50

Welcome to our comprehensive exploration of Microsoft’s Semantic Kernel. Over the next seven minutes, let’s unpack the essence of Semantic Kernel and guide you through getting started with this transformative technology.

What is Semantic Kernel?

https://www.youtube.com/watch?v=90hhJHTWz50

Imagine your application not just as a tool but as a living, learning entity. This is the vision behind Semantic Kernel. It equips your app with a simulated brain and a responsive body — allowing it to remember interactions and learn progressively. The “brain” is a suite of connectors, and the “body” comprises AI plugins that interact with the real world through various prompts and actions. This makes integrating AI services into your app not just possible, but seamless.

Why use Semantic Kernel?

As a developer, you can harness the individual components of Semantic Kernel or blend them to unleash their collective power. Whether you’re seeking an abstraction over OpenAI and Azure services or aiming to create a complex orchestration of AI capabilities, Semantic Kernel is your toolbox.

But what does this mean practically for you and your projects? Simply put, Semantic Kernel allows you to craft an orchestration of AI plugins from a variety of sources — OpenAI, Bing, Microsoft 365 Copilot, Azure, and even Hugging Face — right within the architecture of your application.

Let’s Make an LLM Application with Semantic Kernel

To give you a taste of Semantic Kernel in action, we’ve prepared a tutorial series, starting from the very basics.

Install Microsoft Semantic Kernel

Youtube Link: https://www.youtube.com/90hhJHTWz50?si=fHrV6YwKp5-A3d-v&start=99

We begin by installing the necessary dependencies, assuming Python is already part of your toolkit. The installation process for Semantic Kernel is straightforward, and we’ll complement it with the Semantic Kernel Tools plugin for VS Code to facilitate the creation of functions.

Our journey takes us through the creation of semantic functions, starting with a plugin folder in our project directory, then adding specific skills — cooking, in this case. We employ Semantic Kernel Tools to craft a new function, aptly named “Recipe Generator,” which takes an input and outputs a recipe for the specified dish.

The heart of our semantic functions lies in an SK prompt.txt file, where we craft the prompts that will be sent to OpenAI. Here, we ask ChatGPT to provide recipes based on the user’s input, incorporating any specified formats.

Skprompt file

Main LLM Python Program

Moving on to our Python program, we import Semantic Kernel along with the necessary libraries, instantiate the kernel, and prepare our environment for Chat Services. For this tutorial, we’re utilizing OpenAI’s GPT-3.5 model. We meticulously add our API keys and organization ID to an .env file to securely interface with OpenAI’s services.

Now comes the exciting part — importing the functions we’ve developed. We demonstrate the execution of the “Recipe Function” with a personal touch, requesting a recipe for Chicken Adobo, Filipino style — a dish close to the heart.

Chaining Prompts

Following the successful retrieval of the recipe, we delve into more advanced uses of Semantic Kernel by chaining functions. This process is akin to LangChain, allowing us to pass the output from one function as input to another. We craft an “Advert” function, which takes the recipe and generates a compelling advertisement for it.

Congratulations! In less than seven minutes, you’ve not only witnessed Semantic Kernel in action but grasped the basics to start building your own pipelines for large language model applications.

To delve deeper, we recommend visiting the Semantic Kernel GitHub repository to explore its full potential. Stay tuned for more tutorials on Semantic Kernel, and don’t forget to subscribe to keep up with the latest.

Did this tutorial light a spark of inspiration? Drop a like to support our content, and feel free to share your thoughts or queries in the comments below. If you’re shy, just share your favorite food, and who knows, it might be the next recipe we generate!

You can also checkout how we can implement the semantic kernel with Streamlit and build a data analysis application:

Thank you for joining us on this journey into the world of AI-powered applications. Happy coding!

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Published in Dev Genius

Coding, Tutorials, News, UX, UI and much more related to development

Written by Charles Calapini

Data Science, Artificial Intelligence, Blockchain and Research Papers Summarized

No responses yet

What are your thoughts?