Skip to content

Instantly share code, notes, and snippets.

View pamelafox's full-sized avatar

Pamela Fox pamelafox

View GitHub Profile
@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)
@pamelafox
pamelafox / python_instructions.json
Created January 17, 2025 21:15
python_instructions.json from Python Pulse stream
{
"github.copilot.chat.codeGeneration.instructions": [
{
"text": "Always add a comment: 'Generated by Copilot'."
},
{
"text": "In Python always adhere to PEP8. Prefer pandas over polars. Prefer argparse over click."
},
{
"text": "Use type annotations when writing python function signatures and classes."
@pamelafox
pamelafox / raghack_blogpost.py
Created December 19, 2024 21:07
raghack_blogpost.py
import json
import os
import requests
from datetime import datetime
import urllib.parse
from bs4 import BeautifulSoup
from rich import print
import openai
from pydantic import BaseModel
from azure.identity import AzureDeveloperCliCredential, get_bearer_token_provider
@pamelafox
pamelafox / extract_npr_article.py
Created December 2, 2024 21:39
Extract entities from NPR article with gpt-4o structured outputs
import os
import bs4
import requests
import rich
from openai import OpenAI
from pydantic import BaseModel
client = OpenAI(
base_url="https://models.inference.ai.azure.com",
@pamelafox
pamelafox / fstrings.py
Created September 21, 2024 22:18
Python 3.12 f strings
# print python version
import sys
print(sys.version)
import math
if True:
wow = f"""this is a multiline f string with triple quotes {math.pi:0.2f} :
1. Line 1
2. Line 3 {math.pi:0.2f}"""
@pamelafox
pamelafox / hacks_tools.py
Created September 10, 2024 18:52
GitHub issue processing
import os
import json
from dotenv import load_dotenv
from openai import AzureOpenAI
import requests
load_dotenv(".env", override=True)
@pamelafox
pamelafox / search.sql
Created September 5, 2024 22:10
Hybrid search with real time translation. Combining pgvector, postgis, azure_local_ai, azure_ai, Azure Language Services
-- Hybrid search with real time translation. Combining pgvector, postgis, azure_local_ai, azure_ai, Azure Language Services
WITH listings_cte AS (
SELECT l.listing_id, name, listing_location, summary FROM listings l
INNER JOIN calendar c ON l.listing_id = c.listing_id
WHERE ST_DWithin(
listing_location::geography,
ST_GeographyFromText('POINT(-122.349358 47.620422)')
,3218 )
AND c.date = '2016-01-13'
AND c.available = 't'