• AI/ML - Code

    Code snippet: Hello World agent using Microsoft Agent Framework

    This code snippet demonstrates a sample code which uses Azure OpenAI endpoint to execute an LLM call. # pip install agent-framework python-dotenv import asyncio import os from dotenv import load_dotenv from agent_framework.azure import AzureOpenAIChatClient # Load environment variables from .env file load_dotenv() api_key = os.getenv("AZURE_OPENAI_API_KEY") deployment_name = os.getenv("AZURE_OPENAI_DEPLOYMENT") endpoint = os.getenv("AZURE_OPENAI_ENDPOINT") api_version = os.getenv("AZURE_OPENAI_API_VERSION") agent = AzureOpenAIChatClient( endpoint=endpoint, api_key = api_key, deployment_name=deployment_name, api_version=api_version ).create_agent( instructions="You are a poet", name="Poet" ) async def main(): result = await agent.run("Write a two liner poem on nature") print(result.text) asyncio.run(main()) .env file sample AZURE_OPENAI_API_KEY={paste your api key} AZURE_OPENAI_ENDPOINT=https://{your enpoint}.openai.azure.com/ AZURE_OPENAI_DEPLOYMENT=o4-mini AZURE_OPENAI_API_VERSION=2024-12-01-preview

  • Code

    CaskIA — Kid-friendly, minimal AI Chat

    My 3rd-grade kid has been using modern chat assistants for his hobbies a lot lately. Today he said he wanted his own AI chat bot. He tried building one with GitHub Copilot, but the chain-of-thought prompting pushed him into creating a search engine style chat since he did not realize he needed to connect an actual LLM to make it intelligent. I stepped in and helped him build a simple app using the free version of GitHub Copilot, and also explained how it works. It took about 30 minutes to put everything together. I am sharing it publicly so others…

  • AI/ML - Code

    Tutorial: A basic plugin using Semantic Kernel

    Below source code are for Creating a basic plugin (testplugin.cs), and see how it is being called using prompt from Program.cs. This example uses Weather finding, such as “What is the weather in London on 18th June 2024?”, and it will always return a hard coded value of “29” degrees celsius. You can modify the function to do complex logic. testplugin.cs This is a very basic plugin, which I purposefully did not include any logic. Comments are added inline to explain what each line/function does. Program.cs appsettings.json I used this file to avoid hardcoding sensitive information in the source code…

  • Code - Technology

    How to read Azure KeyVault secrets using Managed Identity in .NET Framework 4.8 C#

    Using Managed Identity to deploy azure resources is considered best practice as it reduces the overhead of keeping additional credentials (tokens/passwords) in config files. This article is about accessing Auzre KeyVault using Managed Identity. I am using .NET Framework 4.8 version for this tutorial. Step 1 – Create KeyVault and secrets First, just go to Azure Portal and create necessary secret values for testing. I would go with a “testkey” and a dummy value. (I am assuming you know the basics of Azure Portal and knows how to create an azure resource such as KeyVault) Also, please take a note…