Skip to content

Instantly share code, notes, and snippets.

View gbaeke's full-sized avatar

Geert Baeke gbaeke

View GitHub Profile
@gbaeke
gbaeke / search.py
Created January 20, 2025 22:20
LLM Search with Bing and scraping
import os
import requests
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel
from bs4 import BeautifulSoup
from openai import OpenAI
from sentence_transformers import SentenceTransformer
from sklearn.metrics.pairwise import cosine_similarity
import numpy as np
import uvicorn
@gbaeke
gbaeke / realtime.py
Created October 2, 2024 16:32
OpenAI realtime API example
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import asyncio
import base64
import os
import pyaudio
import wave
import numpy as np
import soundfile as sf
@gbaeke
gbaeke / assistant.py
Last active November 14, 2023 10:01
OpenAI Assistant Demo
import streamlit as st
import openai
import dotenv
from PIL import Image
from io import BytesIO
import os
import pickle
from collections import OrderedDict
@gbaeke
gbaeke / Program.cs
Created May 28, 2023 20:20
Semantic Kernel Demo
using Microsoft.Extensions.Logging;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.AI.ImageGeneration;
using System.Diagnostics;
using Microsoft.SemanticKernel.Planning;
using System.Text.Json;
var kernelSettings = KernelSettings.LoadSettings();
import requests
import json
# url uses a hardcoded identity endpoint
url = "http://127.0.0.1:40342/metadata/identity/oauth2/token?api-version=2019-11-01&resource=https%3A%2F%2Fvault>
headers = {"Metadata": "true"}
# do token request to IMDS, this will fail
r = requests.get(url, headers=headers)
from azure.appconfiguration.provider import (
AzureAppConfigurationProvider,
SettingSelector,
AzureAppConfigurationKeyVaultOptions
)
from azure.keyvault.secrets import SecretClient
from azure.identity import DefaultAzureCredential
def retrieve_secret(uri):
try:
@gbaeke
gbaeke / linkerd-nginx.md
Last active December 17, 2024 18:59
Linkerd with Nginx Ingress

Linkerd with Nginx Ingress

Azure Kubernetes Service

I installed Linkerd and Nginx on an AKS cluster. You will need an Azure subscription and deploy a basic cluster.

Install Linkerd CLI

Install the Linkerd CLI: see https://linkerd.io/2.11/getting-started/#step-1-install-the-cli. You can also install the cli with brew:

@gbaeke
gbaeke / appsvcarc.md
Last active June 19, 2022 16:21
Run Azure App Services anywhere with Azure Arc

Run Azure App Services anywhere with Azure Arc

Prerequisites

All commands in the gist should be run from bash. You can use WSL (Windows Subsystem for Linux) to run the commands. You can also use the Azure Cloud Shell and select Bash instead of PowerShell.

Install Azure CLI (not needed in Azure Cloud Shell, CLI is pre-installed) and add the following Azure CLI extensions:

az extension add --name connectedk8s
@gbaeke
gbaeke / aca-revisions.md
Created January 9, 2022 13:32
Azure Container Apps - Revisions

Azure Container Apps: Revisions

Deploy with Bicep

param image string = 'ghcr.io/gbaeke/super:1.0.5'

resource la 'Microsoft.OperationalInsights/workspaces@2021-06-01' = {
  name: 'la-aca' 
  location: resourceGroup().location
@gbaeke
gbaeke / aca_scaling.md
Last active August 22, 2022 11:57
Azure Container Apps - Bicep and scaling

Azure Container Apps: Bicep and scaling

Azure Service Bus

Create namespace and topic:

az group create --name rg-aca --location northeurope

namespaceName=MyNameSpace$RANDOM