Skip to content

Instantly share code, notes, and snippets.

View skylarbpayne's full-sized avatar
💔
CI/CD Failed

Skylar Payne skylarbpayne

💔
CI/CD Failed
View GitHub Profile
@skylarbpayne
skylarbpayne / unprocessable_entity_err.py
Created June 18, 2025 16:52
Reproduction of lilypad error
from mirascope import llm, Messages
from mirascope.mcp import sse_client
import lilypad
from pydantic import BaseModel, Field, ValidationError
from tenacity import retry, stop_after_attempt
from fastmcp import FastMCP
from dotenv import load_dotenv
import asyncio
load_dotenv()
@skylarbpayne
skylarbpayne / hl_example.py
Created June 18, 2025 06:40
Human Layer String Errors Minimal Reproduction
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "humanlayer==0.7.9",
# "pydantic==2.11.5",
# ]
# ///
import humanlayer
from datetime import date
@skylarbpayne
skylarbpayne / ai_evals_synthetic_data_hw.py
Created May 21, 2025 22:21
AI Evals Synthetic Data Homework 1
"""Script for generating queries for a recipe search engine.
This script can be used to generate synthetic queries for a recipe search engine.
Following best practices from Hamel and Shreya's AI Evals course, we:
- Generate a set of dimensions that can be used to generate queries; these are attributes that significantly change what the query is about or how it is written.
- For each set of attributes ("Dimensions") we generate a query that matches those attributes.
To ensure that the synthetic generation is better aligned, we first try handwriting the queries using the --manual flag.
This gives us labeled examples to use few shot in our synthetic generation.
# Agents can fail in fantastic ways, and stacktraces are unfortunately not always helpful enough.
# Fortunately, Pydantic AI agents keep track of messages, so as long as you save them you can view them and aid your debugging!
# This gist shows a simple `try_run` implementation which will log out the messages on error.
# You can imagine any number of things to do with the messages: send to logfire, store in a database, write to file, etc
# Pro tip: these form a helpful subset of data input/outputs to help refine your agent! Taking some time to store them
# appropriately for review (and possibly fine tuning / use in prompts / etc in the future) will pay off!!
These are examples where your agent actually failed!
from __future__ import annotations
import asyncio
# I found it surprising that tools had to return a JSON-like type; but didn't support Pydantic BaseModels!
# Perhaps that's by design. However, this simple decorator allows you to implement tools with structured output
# and slap a simple decorator to convert to JSON which the Pydantic AI tool format accepts.
# This is a minimal example
from __future__ import annotations
import asyncio
from collections.abc import Coroutine
from dataclasses import dataclass
# This is a modification of the Pydantic AI weather example from:
# https://ai.pydantic.dev/examples/weather-agent/
# It has been modified to add rate limiting, since the required APIs have tiny rate limits!
# I am using asynciolimiter: uv add asynciolimiter with a custom decorator to apply the rate limits
# Let me know if you know of a better/cleaner way!
# This means we can easily rate limit tools!
from __future__ import annotations as _annotations
@skylarbpayne
skylarbpayne / smart_revert.gitconfig
Created July 24, 2021 20:16
A git alias for smart reversions
# 'Smart Revert'
# Uses git reset to perform a revert such that:
# - Git history stays intact
# - Works across merge commits
# See this stack overflow answer for information on the solution:
# https://stackoverflow.com/a/1470452
# This takes a single argument: a git commit. Note: this can be either
@skylarbpayne
skylarbpayne / install_kfctl.sh
Last active July 23, 2021 01:14
Install kfctl
# Taken from the book: "Kubeflow for Machine Learning: From Lab to Production"
# Provided as-is
PLATFORM=$(uname)
export PLATFORM
mkdir -p ~/bin
export KF_TAG=1.0.1
KF_BASE="https://api.github.com/repos/kubeflow/kfctl/releases"
KFCTL_URL=$(curl -s ${KF_BASE} |\
grep http |\
@skylarbpayne
skylarbpayne / .bashrc
Created October 4, 2016 04:38
Bash Configuration
export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h: \[\033[1;31m\]\w\[\033[m\]\$ "
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
@skylarbpayne
skylarbpayne / .vimrc
Created October 4, 2016 02:58
Vim Configuration
" This must be first, because it changes other options as side effect
set nocompatible
" To make compatible with vundle
filetype off
" Use pathogen to easily modify the runtime path to include all
" plugins under the ~/.vim/bundle directory
call pathogen#helptags()
call pathogen#infect()