Brief Summary
This guide provides a quick start to building AI agents with Semantic Kernel in Python, .NET, or Java. It covers installing the necessary packages, creating a back-and-forth conversation with an AI, enabling an AI agent to run your code, and watching the AI create plans on the fly. The guide also includes step-by-step instructions and code snippets to help you get started.
- Installing the Semantic Kernel SDK for different languages.
- Setting up a console application and integrating Semantic Kernel.
- Understanding the core components such as importing packages, adding AI services, and incorporating plugins.
Installing the SDK
This chapter provides instructions for installing the Semantic Kernel SDK in Python, .NET, and Java. For .NET, you can install the Microsoft.SemanticKernel
package using the dotnet add package Microsoft.SemanticKernel
command. For Python, use pip install semantic-kernel
. For Java, the instructions detail how to add the Semantic Kernel dependencies to your project's pom.xml
file, including the semantickernel-bom
, semantickernel-api
, and semantickernel-aiservices-openai
artifacts.
Quickly Get Started with Notebooks
This chapter describes how to quickly get started with Semantic Kernel using notebooks for Python and C# developers. It involves cloning the Semantic Kernel repository, opening it in Visual Studio Code, navigating to the appropriate directory (_/python/samples/getting_started
or _/dotnet/notebooks
), and opening the 00-getting-started.ipynb
notebook to set up the environment and create your first AI agent.
Writing Your First Console App
This chapter guides you through creating a new .NET Console project using the dotnet new console
command and installing the necessary .NET dependencies, including Microsoft.SemanticKernel
, Microsoft.Extensions.Logging
, and Microsoft.Extensions.Logging.Console
. It provides code snippets for C#, Python, and Java to demonstrate how to set up a back-and-forth chat with an AI, add plugins, and enable planning.
Understanding the Code
This chapter breaks down the sample code used to build an AI agent with Semantic Kernel, focusing on key steps such as importing packages, adding AI services, incorporating enterprise components, building the kernel, adding plugins, enabling planning, and invoking the AI agent. It explains the purpose of each step and provides code examples in C#, Python, and Java.
Import Packages
This chapter details the necessary packages to import for each language (C#, Python, Java) to use Semantic Kernel. These packages include those for core functionality, chat completion, and OpenAI connectors.
Add AI Services
This chapter explains how to add AI services to the Semantic Kernel, focusing on using Azure OpenAI chat completion services. It notes that while Azure OpenAI is used in the example, other chat completion services can also be used.
Add Enterprise Services
This chapter discusses the benefits of using Semantic Kernel for enterprise-grade services, specifically adding the logging service to the kernel to aid in debugging the AI agent. It provides code snippets for C# and Python to demonstrate how to add logging.
Build the Kernel and Retrieve Services
This chapter describes how to build the kernel after adding services and how to retrieve the chat completion service for later use. It notes that in Python, you can access services directly from the kernel object without explicitly building the kernel.
Add Plugins
This chapter explains how to add plugins to the Semantic Kernel to enable the AI agent to run code, retrieve information from external sources, or perform actions. It uses the example of a LightsPlugin to demonstrate how to create a native plugin that can manipulate a light bulb's state.
Planning
This chapter discusses how Semantic Kernel uses function calling to provide planning capabilities. It explains how to enable automatic function calling by creating the appropriate execution settings, allowing the AI agent to automatically invoke functions when requested.
Invoke
This chapter explains how to invoke the AI agent with the plugin. It provides code snippets for generating a non-streaming response and mentions the availability of the GetStreamingChatMessageContentAsync
method for generating a streaming response.