Skip to content

Instantly share code, notes, and snippets.

View jeffmylife's full-sized avatar
🌊
building

Jeffrey Lemoine jeffmylife

🌊
building
View GitHub Profile
@jeffmylife
jeffmylife / Makefile
Created May 20, 2023 23:14
Makefile with yaml configuration for AWS Batch Job project. Defines variables in Makefile based on a target's dependencies.
.phony: all
all: push
# configuration setup
PROJECT_FILE_NAME=project.yml
CONFIG := python3 -c "import yaml; import json; from pathlib import Path; print(json.dumps(yaml.safe_load(Path(\"$(PROJECT_FILE_NAME)\").read_text())))"
OS := $(shell python3 -c "import platform; print(platform.system())")
# defaults
@jeffmylife
jeffmylife / equity_sampler.py
Created January 4, 2024 21:20
Sampling without replacement to acheive the most balanced representation across skewed distributions
import pandas as pd
def sample_dataframe(df, date_column, N):
"""
Samples a pandas DataFrame to achieve a balanced representation across different date groups.
This function ensures that smaller date groups (those with counts less than an average size)
are fully represented in the sample. Larger date groups are sampled uniformly to contribute
towards a total sample size of N. If the initial sampling process results in a total sample size
@jeffmylife
jeffmylife / desc.md
Last active December 17, 2024 03:46
Convert natural language dates and time expressions (like "next Tuesday", "in 2 weeks", "next summer") into Python datetime objects using Claude/LLM. Parse relative dates, fuzzy time expressions, and human language into structured timestamps.

Natural Language Time Parser using LLM

A Python utility that converts natural language time expressions into structured datetime objects using LLMs. Perfect for parsing user inputs like "next Tuesday", "in a few months", or "sometime next summer".

Features:

  • Converts natural language to precise dates
  • Handles relative time expressions
  • Season awareness
  • Configurable word translations (e.g., "few" = 3-4, "several" = 5-6)
  • Returns structured output with confidence indicators
@jeffmylife
jeffmylife / compare_llm_latency.py
Created January 2, 2025 21:13
Latency comparison command line tool between LLM's
import argparse
import json
import os
import statistics
import time
from statistics import mean, stdev
from typing import List, Dict
import plotext as plt
from litellm import completion
@jeffmylife
jeffmylife / langchain-get-and-set-history-with-tools.md
Created January 17, 2025 20:02
LangChain with Tools and Chat History Guide

LangChain with Tools and Chat History: A Guide

Welcome to this guide on using LangChain with tools and chat history management. This guide will explain how to set up and use tools with LangChain, manage chat history, and handle tool interactions within your conversation flow.

Table of Contents

  1. Overview
  2. Setting Up Your Environment
  3. Tools Overview
  4. Handling Chat History
  5. Message Flow with Tools