Skip to content

Instantly share code, notes, and snippets.

View pamelafox's full-sized avatar

Pamela Fox pamelafox

View GitHub Profile
@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'
@pamelafox
pamelafox / embed_videos.py
Created August 22, 2024 15:59
Add embeddings to a PostgreSQL database table (Python/Psycopg2/pgvector)
import os
import psycopg2
import openai
import azure.identity
import numpy as np
from dotenv import load_dotenv
from pgvector.psycopg2 import register_vector
load_dotenv()
@pamelafox
pamelafox / comparison.md
Last active July 29, 2024 22:11
Function calling for RAG Query Rewriting: GPT 3.5 vs Llama 3.1:8B

This is a comparison of calls made to either OpenAI gpt-35-turbo or Ollama Llama3.1 with a function calling request. The geneal goal of the function is to take a user query and turn it into a search query, along with optional price filter or brand filter. See the file below this one for the tools definition.

User question: "Best shoe for hiking"

gpt-35: 😊

{"search_query":"Best shoe for hiking"}

llama3.1: 😊

@pamelafox
pamelafox / phi3deployment.bicep
Created July 2, 2024 19:16
Phi3 deployment with Bicep
param location string
param aiHubName string
param aiProjectName string
param modelName string
param modelVersion string
param deploymentName string
param tags object = {}
param publicNetworkAccess string
param aiServicesName string
@pamelafox
pamelafox / links.md
Created April 4, 2024 23:34
Links for PyCascades