Skip to content

Instantly share code, notes, and snippets.

View pamelafox's full-sized avatar

Pamela Fox pamelafox

View GitHub Profile
@pamelafox
pamelafox / asyncio.py
Created May 1, 2025 17:15
AsyncIO example - concurrency in task group
import asyncio
import httpx
async def fetch_url(url):
print(f"Fetching {url}")
async with httpx.AsyncClient(timeout=httpx.Timeout(10.0)) as client:
r = await client.get(url)
print(f"Received {url} with status code {r.status_code}")
return r.text
@pamelafox
pamelafox / experiments.py
Created April 24, 2025 20:36
pymupdf experiments
import logging
import os
import azure.identity
import openai
import pymupdf4llm
from dotenv import load_dotenv
from pydantic import BaseModel
from rich import print
@pamelafox
pamelafox / readme.md
Created April 3, 2025 23:08
Example of Learn YAML for README top
@pamelafox
pamelafox / mcp_server.py
Created March 31, 2025 16:44
MCP Server for azure-search-openai-demo (Basic)
import io
import os
import traceback
from enum import Enum
from azure.identity.aio import (
AzureDeveloperCliCredential,
)
from azure.search.documents.aio import SearchClient
from azure.search.documents.models import (
@pamelafox
pamelafox / ai-environment.bicep
Last active February 24, 2025 21:49
Azure AI Project/Hub (start with main.bicep)
@minLength(1)
@description('Primary location for all resources')
param location string
@description('The AI Hub resource name.')
param hubName string
@description('The AI Project resource name.')
param projectName string
@description('The Storage Account resource ID.')
param storageAccountId string = ''
@pamelafox
pamelafox / azure_token.py
Last active February 19, 2025 13:16
Pydantic AI with Azure or GitHub Models
# pip install azure-identity
# pip install pydantic-ai
from openai import AsyncAzureOpenAI
from azure.identity.aio import (
AzureCliCredential,
get_bearer_token_provider,
)
from pydantic_ai import Agent
@pamelafox
pamelafox / tutor_eval.py
Last active March 5, 2025 16:12
tutor_eval.py
---
name: Tutorness
description: Evaluates how well the responses simulate a tutor
model:
api: chat
parameters:
temperature: 0.0
max_tokens: 800
top_p: 1.0
presence_penalty: 0
@pamelafox
pamelafox / prompty_safety.py
Created February 13, 2025 21:01
Prompty with Content Safety Error Handling
import openai
import prompty
import prompty.azure
# execute the prompt
try:
response = prompty.execute("approaches/prompts/chat_answer_question.prompty",
configuration={
"api_version": "2024-06-01",
"azure_endpoint": "https://cog-xxk4qzq3tahic.openai.azure.com",
@pamelafox
pamelafox / generate_simulations.py
Created February 6, 2025 23:24
Using Azure AI Evaluations simulator with Azure AI Search
import asyncio
import json
import logging
import os
from pathlib import Path
from typing import Any, Dict, List, Optional
import requests
from azure.ai.evaluation.simulator import Simulator
from azure.identity import AzureDeveloperCliCredential
@pamelafox
pamelafox / deepseek_azure_openai.py
Last active March 18, 2025 20:10
Using Azure AI SDK and OpenAI SDK with AIServices deepseek deployment
import logging
import os
from azure.identity import AzureDeveloperCliCredential, get_bearer_token_provider
from dotenv import load_dotenv
from openai import AzureOpenAI
load_dotenv(override=True)
logging.basicConfig(level=logging.DEBUG)