5 Assembling Building Blocks with Native and Semantic Functions

 

This chapter covers

  • Introducing kernel functions
  • Building native functions
  • Building semantic functions
  • Testing semantic functions

Imagine you're building an intelligent assistant for Robby, the robot car. You've got a powerful, large language model acting like a friendly AI assistant, but it's like a brain without hands or eyes. Kernel functions are linking pieces that give the ability to interact with the world. Think of them as specialized skills the AI can learn and use to solve problems.

In this chapter, we'll explore how to add a diverse set of skills to your AI assistant, enabling it to reason, make decisions, and take intelligent actions. We'll accomplish this by diving deep into the concepts of kernel functions and plugins, the core mechanisms for extending the capabilities of any Semantic Kernel-powered agent.

5.1 Introduction to Kernel Functions

Kernel functions are the fundamental building blocks of Microsoft Semantic Kernel applications, representing units of functionality that can be executed by the kernel. At the same time, kernel functions make the code more testable and reusable. These kernel functions come in two flavors: semantic functions, which leverage generative artificial intelligence for natural language processing, and native functions, which are traditional code. This section will explore both types in detail, emphasizing their importance when interacting with large language models (LLMs).

5.2 Building Native Functions from Traditional Code

5.2.1 Creating Native Functions in an Imperative Way

5.2.2 Creating Native Functions in a Declarative Way

5.3 Building Semantic Functions from Prompts

5.3.1 Creating Semantic Functions from Plain Text Prompts

5.3.2 Creating Semantic Functions Using PromptTemplateConfig

5.3.3 Creating Semantic Functions from Kernel Native Template Files

5.3.4 Creating Semantic Functions from YAML Files

5.3.5 Examples

5.4 Testing Semantic Functions

5.4.1 Unit Testing

5.4.2 Integration Testing

5.5 Summary