So the stove's in your kitchen. You can finally start cooking. The last section felt a little bit boring, a little too much blah blah blah, but you have the oven, the stove, the big object ready to cook your AI. We're going to cook on this stove. You're going to cook functions, semantic functions. What kind of cooking are you going to do? Business style stuff. We're going to cook up SWOTs. Strength, weakness, opportunity, threats. Boring business stuff and make it sing on your stove top with AI. Let's see what happened. Semantic functions, functions made out of words, so-called prompts, and basically do things that you might not expect are possible, which is scale the kind of AI that you're trying to build. not just scale the number of people that can use it, but scale the kind of system you can build with it. There are two kind of functions in the Semantic Kernel world. One is a Native function, classic computer code, you type it in and it runs. or semantic functions, composed of text that is parameterized. There's some kind of configuration attached to it and it produces output as well as a native function, but you'll find that these semantic functions are unusually powerful. Reminder what the SWOT. SWOT is strength, weaknesses, opportunities, and threats. It's a good matrix to use when helping a business of any scale understand what it should be worried about. Okay, we're going to get a kernel ready. and I'm going to grab from the semantic_kernel as sk. You'll see me type this a lot and you'll get bored very quickly, so let me just copy and paste a bunch of stuff and we're going to run that. The kernel is now ready. Next up, what we're going to do is we're going to make our first semantic function. Okay, let's do this. So what we're going to do is we're going to make a prompt. a templated prompt. Let's read this for a second. It's a Python string, so it's a multi-line string. It has a certain input and the prompt is to summarize whatever's above in less than 140 characters. We're then going to take a detour to make a semantic function that takes this prompt template. There's some other parameters, that's some boilerplate. Let me just add that for a second. Here we go. I'm adding a description. I'm telling how many tokens to use, setting the temperature, and giving the top_p to describe the range of words to be used in the response, the completion response. And as a reminder, because this is going to run, you won't see anything happen. Let me just remind myself that what it's doing is it's making a semantic function for summarization and now it's registered. So next up, if you notice this value input, I want to be able to attach some value to that. and I'm going to take text from a TED talk from Andrew Ng about a pizza shop owner who could use some help from AI, he thinks. and I'm going to then compute the following. I'm going to generate a result by having the kernel do a run async. This is now adding the summary function. into the pipeline. And I'm going to give it at the head of the pipeline, sk_input. And let's print this out in a pretty way. I'm going to use my display markdown thing. And let's see how it does. Let's see how we do it. It's running. Great. It took this information and it summarized it. What did it do? It basically took this summary_function, it stuffed this input into the summary_function. and then it generated, sparkle, this short summary of that long text. You know, long text, nothing's wrong with it, long form is good. Okay, how are you feeling so far? Kind of cool, right? Let me just show you there's another shorthand way of calling these different functions without using the kernel. Uh in this case, I'm just going to call the function directly. It's kind of like calling a procedure. You'll see this used once in a while by people they want to show that you don't have to use it, uh, with an explicit kernel. Uh and there it is. It did it the same way, but this is much more compact. It doesn't using this await kernel.run_async. But it does the same thing, same result. See that? Okay. How you feeling? Okay, we're we're going to go a little harder now in the world of native functions. Native functions. are not semantic functions and they require a lot of so-called syntactic sugar, meaning they they're they're wrapped in a bunch of things that I I could type, but pardon me for typing fast, meaning cut and paste. Let's pull these things in. We're going to make an exotic language plugin. It's going to convert anything into Pig Latin. As you can see what it's doing is I define a semantic kernel function, I give it a description, I give it a name, I tell it what is this input variable, you know, this input, like what do I do with the input, what is it? What do I do? Do this. What is it? It's this kind of text. It takes in pig latin. Sentence comes in. It walks over the words and of course, it processes it. So here I'm going to say ExoticLanguagePlugin, I'm going to register it in the kernel. I'm going to register this plugin. See that? A lot of syntax, right? But wait for it, this is the exciting part. I'm going to define the function. This is... this is kind of... what's it called again? Um, this is not going to feel awesome. But know this is a big deal. You're taking a native function and you're wrapping it in a format that Semantic Kernel can use. In the same way that Semantic Kernel can process semantic functions, it can process native functions. And next up, what we want to do is we want to run a pipeline of functions. the summary_function and the pig_latin_function with the input. So the Andrew Ng long form will go into summary_function. It'll be fed as an output into the pig_latin_function and guess what's going to happen. I'll assume you'll guess what's going to happen, but um, yeah. It's basically that sentence before, AI can blah blah blah, turned into Pig Latin. Okay. But now you can see that it's using a native function and a semantic function. So you can interchange them. Pretty cool, huh? And You know, in all this like techno stuff, you can get lost. I'll get lost pretty quickly myself because it's so powerful. But at the end of the day, all you're doing is writing code to solve a problem. So the TED talk that Andrew Ng gave about how to help small businesses and in particular a pizza shop owner, struck a chord with me and for that reason, I have built this entire lesson for you to not just write code, but think in business terms. So, let's sort of take off by First of all, thinking of the SWOT instrument to create a SWOT, you have to create a list of questions. And this is a fairly good list of questions that I composed to to figure out, like, the small business owner, like, what are their strengths, weaknesses, opportunities, and threats. And if you organize these in a SWOT chart, the way they look is this. Let me show you this. I love a 2x2, don't you? So these are the strengths. Look at them quickly. Unique garlic pizza recipe, owner trained in Sicily. Weaknesses, don't have calzones, had a flood in the area, the seating areas are in disrepair. Opportunities, not they don't do catering or cater to the local tech startup community. There's also an annual food fair. This is ways they can actually make new revenue. And there's threats. There are cheaper pizza shops. There's going to be street construction, the cost of cheese is going up. And so this is a snapshot of SWOT. So, what does this have to do with large language models and Semantic Kernel? Good question. Well, first off, remember, it is a way to solve AI problems, Semantic Kernel, but it doesn't matter if you don't have a good problem. Now, uh, let's make a kernel again. I'm going to make a kernel. This is very familiar to you and again, I just put print statements in to just remind myself. Made a kernel. I made a kernel. And now what I want to do is I want to take these SWOT responses, analyses, and I want to convert them to a different domain. Uh, why would I want to do that? Well, because as they say, the mountain's there, so you can, and AI gives you the ability to climb mountains so quickly, it's unbelievable. So let me show how that works. So what I've done here is I've taken the SWOT interview And I'm making a semantic function that converts the analysis into a different business domain. It's kind of weird, huh? And what I'm going to do is I'm going to take this interview text and I'm going to ask it to apply it to the construction management domain. And I'm going to run it. And what happens is it takes questions that were geared for a pizza shop. And now I could give them to someone in construction management, which sounds kind of science fictiony, but here, it's changed all the pizza-esque things into construction methods, materials, budget overruns. Do you see that zoning regulations and so, it basically like shifted the context of the text. And that is something you cannot write in a native function, but in a semantic function, it's unusually easy to do. Let's throw in another because we like to chain things together. Let me show you another type of semantic function. This says a rewrite. Rewrite the text above to be understood by a blank level. So what we're doing is we're making a new function to be able to change the reading level of whatever comes into it. And what I'm going to do is I'm going to redo the shift_domain_function. shift the questions into another domain, construction management. I'm going to flow that in the pipeline to changing the reading level of whatever comes into it, to the level of a child. It's a little bit easier to read. The good things, the bad things, the good chances, the bad chances, and there you have it. And I'd like you to change in these parameters and see what happens and I think you'll get pretty excited because I don't think you've ever written programs like this. Oh if you're an LLM person or ML person in general, this is no surprise to you. But for someone working primarily in the domain of problems, it's extraordinary. And you want to remember that we are using this, the right hand I talked about, the SEMANTIC COMPLETION ability, fill in the blanks. This is the magic that we're experiencing right now. But there's this other type of AI capability that we're using out there called SEMANTIC SIMILARITY. I haven't touched upon that yet. So, just just be ready for when you notice that you can use both hands in the equation.