Jason Haley

Ramblings from an Independent Consultant

Semantic Kernel Hello World Plugins Part 3

Last week I blogged Part 2 showing the creation of a native function plugin, in this post I want to take that native function a step further and use the OpenAI Function calling. This will allow us to not provide the current date when making the call to get a historic daily fact and have OpenAI call a function to get the current date.

I’ve added the HelloWorld.Plugin3.Console project to the GitHub repo for the code in this blog entry.


Semantic Kernel Hello World Plugins Part 2

Two weeks ago I blogged Part 1, in which I moved the prompt to a prompt template. In this part, I implement a native function that will take in the current date and make the call to the LLM.

I’ve put the code for this blog in the HelloWorld.Plugin2.Console project in the same repo as the other SK entries: semantic-kernel-getting-started.

Semantic Kernel Plugin: Native Function

There is a good Microsoft Learn module: Give your AI agent skills that walks you through the details of what a native function is and how to implement them.


My Session at Boston Global Azure Bootcamp

This past weekend was Boston Azure’s Edition of the annual Global Azure Bootcamp. This year we focused on AI and hands-on-labs.

The odd thing about when we scheduled the meetup was we had a lot of people sign up for the group just to rsvp - before most of the existing members had gotten around to rsvp’ing. We did not expect that. It is a mystery as how they heard about the event so quick. We only had one room reserved, so there really was a hard cap on how many people we could let in.


Semantic Kernel Hello World Plugins Part 1

A couple of weeks ago, in my last entry I created a simple Hello World application with Semantic Kernel. Since then, I’ve worked my way through the MS Learning path: APL-2005 Develop AI agents using Azure OpenAI and the Semantic Kernel SDK - which I highly recommend if you are also learning SK.

In this entry I’m going to start with the code from the last entry and extract the prompt to a plugin. I’ve put the code for this blog in the same repo as the last entry: semantic-kernel-getting-started


Semantic Kernel Hello World

This past Thursday night after the Virtual Boston Azure meetup, Bill Wilder (@codingoutloud) created an AI mini-workshop (hands on) for the attendees that were interested in getting hands on with code using the Azure OpenAI API.

This post is me using the same idea but with Semantic Kernel.

OpenAI Chat Hello World C#

Bill provided the following code for us to get a simple OpenAI chat working:

using Azure;
using Azure.AI.OpenAI;


string? key = "...";
string? endpoint = "...";
string? deployment = "...";

// output today's date just for fun
Console.WriteLine($"\n----------------- DEBUG INFO -----------------");
var today = DateTime.Now.ToString("MMMM dd");
Console.WriteLine($"Today is {today}");
Console.WriteLine("----------------------------------------------");


var client = new OpenAIClient(new Uri(endpoint), new AzureKeyCredential(key));

// TODO: CHALLENGE 1: does the AI respond accurately to this prompt? How to fix?
var prompt = $"Tell me an interesting fact from world about an event " +
            $"that took place on {today}. " +
            $"Be sure to mention the date in history for context.";

CompletionsOptions completionsOptions = new()
{
    Temperature = 0.7f,
    DeploymentName = deployment,
    Prompts = { prompt },
    MaxTokens = 250,  // PLEASE DON'T MAKE LARGER THAN 250 (but see what happens at 25)
};

Response<Completions> completionsResponse = client.GetCompletions(completionsOptions);

Console.WriteLine($"\nPROMPT: \n\n{prompt}");

int i = 0;
foreach (var choice in completionsResponse.Value.Choices)
{    
    Console.WriteLine($"\nRESPONSE {++i}/{completionsResponse.Value.Choices.Count}:" +
        $"{choice.Text}");
}

Console.WriteLine($"\n----------------- DEBUG INFO -----------------");
Console.WriteLine($"Tokens used: {completionsResponse.Value.Usage.CompletionTokens}/{completionsOptions.MaxTokens}");
Console.WriteLine("----------------------------------------------");

When you run this code (you’ll of course need to add in you own values for the key, endpoint and deployment), you will get a response like this:


Boston Code Camp 36 Sessions

Yesterday was Boston Code Camp 36 hard to believe it has been going on for 20+ years now. For me it is one of those regular events for the Boston tech community that is well worth spending a Saturday attending.

It was nice to see a lot of regular faces and meet some new people.

Talk: Getting Started with Retrieval Augmented Generation (RAG)

RAG Slide 1

I was surprise the room was full, it was good to see so many developers, students and architects - mostly with .NET backgrounds looking to get started with RAG applications.


Demo Review: Azure Vector Search AI Assistant

Demo Review: Azure Vector Search AI Assistant

This is the fourth C# demo in The RAG Demo Chronicles (Blog Series) and is the first demo so far that saves its history to a database.

This Retrieval Augmented Generation (RAG) demo is a little different than the last three because it primarily uses data from a database as the content to search instead of documents. It also uses Semantic Kernel more than other demos have, which is neat to see too.


Demo Review: Azure Search OpenAI Demo (Python)

Demo Review: Azure Search OpenAI Demo (Python)

This is the last in the family of Azure Search OpenAI demos that I’m covering (I’m not looking at the Java version). I reviewed the C# version and the Javascript/Typescript version earlier this month. Of the three I’m covering, this one seems to be the most active, popular and have the most documentation.

At the beginning of this month, the Hack Together: The AI Chat App Hack used this demo at the sample repository, marking it as a solid reference implementation for RAG.


Demo Review: Azure Search OpenAI Javascript/Typescript

Demo Review: Azure Search OpenAI Javascript/Typescript

This is the second in the family of Azure Search OpenAI demos that I’m reviewing. Last week I reviewed the C# version. As you’ll see below, the Javascript version is a bit different.

The user interface (UI) functionality is provided by a set of web components that you can add to about any web application (ie. React, Angular, Vue, etc.) - in fact the web application in the demo is written in React. Also the chat communication is written to match the HTTP protocol for AI chat app which means the frontend can communicate with any backend that matches that protocol.


Demo Review: Azure Search OpenAI Demo C#

Demo Review: Azure Search OpenAI Demo C#

If you are looking for Retrieval Augmented Generation (RAG) demos that utilize Azure Search and Azure OpenAI (along with several other supporting Azure services), then there is a set of related demos that do just that in GitHub.

This family of RAG demos consists of:

  1. azure-search-openai-demo-csharp - written in C#.
  2. azure-search-openai-demo - written in python.
  3. azure-search-openai-javascript - written in javascript/typescript.
  4. azure-search-openai-demo-java - written in java.

This post is about #1 above, I will cover #2 and #3 in later posts, but I will leave the Java version to someone else to review.