• Code - Technology

    Python revision notes

    Sharing my Python revision notes here. I created these while revisiting the fundamentals and thought they might be useful for beginners or anyone brushing up on the basics. GitHub URL: https://github.com/ninethsense/code-share/tree/master/Python

  • Architecture - Code - Data

    Redis integration tutorial – C# and Python – for Beginners

    I will be demonstrating a “Cache-Aside” pattern, which is a basic Redis integration to an app. What it basically does is: Find the GitHub code – https://github.com/ninethsense/code-share/tree/master/RedisSample Prerequcites Step 1: Setup Docker with Redis Use the below docker-compose.yml Next, you can create the image using command below: This is my command window looks like: Additionally, you can verify on Docker Desktop if you use one Optionally, you can check in the browser if Redis Dashboard is working – http://localhost:8001/ Step 2 – .NET Program Create your .net project using Visual Studio Code or .NET CLI. You require a dependency to…

  • Code

    Kafka integration for C# beginners

    Every technology feels like rocket science until you take the first step. I am trying to demonstrate a quick tutorial on setting up Kafka and writing two programs to consume from it. I am purposefully ignoring the what and why of Kafka and its event-driven architecture behaviour, as you can find tons of tutorials and interview material on that. I will be using Docker Desktop to host Kafka. You can find my Visual Studio solution on GitHub – https://github.com/ninethsense/code-share/tree/master/KafkaIntegrationSample Step 0: Prerequisites Step 1: Setup Kafka We will be using KRaft method instead of old Zookeeper. Use the below docker-compose.yml…

  • 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…