Skip to content

Instantly share code, notes, and snippets.

View ColeMurray's full-sized avatar

Cole Murray ColeMurray

View GitHub Profile
@ColeMurray
ColeMurray / open-hands-demo-faiss-server.py
Created September 8, 2024 01:22
Example using OpenHands to create a vector database server
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel
from typing import List, Optional, Dict
import faiss
import numpy as np
import os
app = FastAPI()
@ColeMurray
ColeMurray / prompt_caching_conversation_demo.py
Created September 5, 2024 06:50
Demo testing of anthropic's prompt caching for conversations
import asyncio
import aiohttp
import os
from dotenv import load_dotenv
# Load environment variables
load_dotenv()
API_KEY = os.getenv("ANTHROPIC_API_KEY")
API_URL = "https://api.anthropic.com/v1/messages"
@ColeMurray
ColeMurray / groq-transcribe.py
Created September 3, 2024 22:36
Transcription of video using groq
import os
import subprocess
from pydub import AudioSegment
from groq import Groq
import argparse
# Initialize the Groq client
client = Groq()
def convert_video_to_audio(video_path, audio_path):
@ColeMurray
ColeMurray / automated-crawl.py
Created August 10, 2024 23:29
Automated Website Data Extraction
import json
import logging
import time
from typing import Dict, Any
import requests
from bs4 import BeautifulSoup
from openai import OpenAI
from requests.exceptions import RequestException
from tenacity import retry, stop_after_attempt, wait_random_exponential
@ColeMurray
ColeMurray / email-auto-labeler.py
Created August 8, 2024 06:07
Using GPT to auto-label gmail
import os
import base64
import json
import logging
from datetime import datetime, timedelta
from typing import List
from google.oauth2.credentials import Credentials
from google_auth_oauthlib.flow import InstalledAppFlow
from googleapiclient.discovery import Resource, build
from googleapiclient.errors import HttpError
import json
import logging
import csv
from typing import List, Dict, Any, Optional
from pydantic import BaseModel, create_model, Field, validator, field_validator
from openai import OpenAI
import time
# Set up logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
@ColeMurray
ColeMurray / snowflake-overview.md
Created June 25, 2024 06:40
Azure Snowflake DBT

Complete Tutorial: Azure, Snowflake, DBT, and Python with Medallion Architecture

Table of Contents

  1. Introduction
  2. Architecture Overview
  3. Setting Up the Environment 3.1. Azure Setup 3.2. Snowflake Setup 3.3. DBT Setup 3.4. Python Environment Setup
#!/bin/bash
# Update and upgrade Homebrew
echo "Updating Homebrew..."
brew update
brew upgrade
# Install nvm (Node Version Manager)
echo "Installing nvm..."
# settings we’re about to change
osascript -e 'tell application "System Preferences" to quit'
# Ask for the administrator password upfront
sudo -v
# Keep-alive: update existing `sudo` time stamp until `.macos` has finished
while true; do
sudo -n true
sleep 60
kill -0 "$$" || exit
@ColeMurray
ColeMurray / gist:6f615e105aac4d93650c7089b16fc279
Created November 12, 2023 00:29
basic google search custom engine
import json
import sys
from article_agent.config import my_api_key, my_cse_id
from googleapiclient.discovery import build
def get_search_results(search_term: str, num_search_results: int = 10) -> json:
"""Perform a Google search using Custom Search API"""
# Build request