Skip to content

Instantly share code, notes, and snippets.

View cpfiffer's full-sized avatar
🤙
LOVING IT

Cameron Pfiffer cpfiffer

🤙
LOVING IT
View GitHub Profile
@cpfiffer
cpfiffer / memory_upload.py
Created July 23, 2025 21:04
Code to upload arbitrary text to a Letta agent's memory
"""
Letta Agent Memory Migration Script
This script demonstrates how to migrate arbitrary text strings to a Letta agent's memory system.
It provides a complete workflow for creating agents and adding persistent memory passages.
Process Overview:
1. Initialize Letta client with API key from environment
2. Search for existing agent by name (configurable via LETTA_AGENT_NAME)
3. If agent doesn't exist:
@cpfiffer
cpfiffer / fetch_llms_txt.py
Created July 14, 2025 21:02
Letta tool to retrieve llms.txt files
def fetch_llms_txt(url: str, timeout: int = 10):
"""
Fetch content from URLs ending in 'llms.txt'.
Args:
url (str): The URL to fetch (must end with 'llms.txt')
timeout (int): Request timeout in seconds (default: 10)
Returns:
str: Text content of the llms.txt file
@cpfiffer
cpfiffer / the-future.cbl
Created June 12, 2025 21:24
it was all shit after cobol
IDENTIFICATION DIVISION.
PROGRAM-ID. MICROSERVICE-ARCHITECTURE.
AUTHOR. SOME-BOOMER-WHO-INVENTED-THIS-STUFF.
DATE-WRITTEN. 1959.
DATE-COMPILED. BEFORE-YOUR-FRAMEWORK-EXISTED.
* REVOLUTIONARY NEW CONCEPT: SEPARATING BUSINESS LOGIC!
* (WE'VE ONLY BEEN DOING THIS FOR 65 YEARS)
ENVIRONMENT DIVISION.
start: recipe
recipe: declaration_section ingredient_section instruction_section notes_section end
// The declaration of the recipe
declaration_section: declaration
declaration: "# " recipe_name
recipe_name: /[a-zA-Z0-9 ]+\n/
// The ingredients of the recipe
@cpfiffer
cpfiffer / buildings.py
Last active April 29, 2025 20:15
Some building stuff
# LLM stuff
import outlines
import torch
from transformers import AutoProcessor
from pydantic import BaseModel, Field
from typing import Literal, Optional, List
# Image stuff
from PIL import Image
import requests
@cpfiffer
cpfiffer / cleanlab-wrong.py
Last active April 17, 2025 23:58
An example of using Cleanlab to detect a slightly incorrect data extraction value.
"""
NOTE: This example is designed to produce mildly incorrect output --
see the definition of `IncomeData` and note that it fixes the earnings_per_share to 2.33.
To make this function normally, simply remove the `__init__` method or the
`self.earnings_per_share = 2.33` line.
"""
import warnings
warnings.filterwarnings('ignore')
@cpfiffer
cpfiffer / cleanlab-legal.py
Created April 17, 2025 23:49
Using Cleanlab to check data extraction fidelity.
emotions:
- connection_to_content:
relationship: CAUSES
strength: 0.5
emotionType: enthusiasm
text: There is a sense of excitement and energy surrounding the launch of Comind,
an open-source project aimed at developing a cognitive layer for ATProto. Mr.
Dr. Cameron Pfiffer expresses a passionate invitation for contributors, showcasing
enthusiasm for the project's potential in building a network of AI agents.
- connection_to_content:
@cpfiffer
cpfiffer / recursion.py
Last active March 25, 2025 20:38
Recursive knowledge concept map using Outlines
# Setup instructions:
# pip install 'outlines[transformers]'
import outlines
from transformers import AutoTokenizer
import json
# MODEL_STRING = "HuggingFaceTB/SmolLM2-135M-Instruct" # Small model
# MODEL_STRING = "HuggingFaceTB/SmolLM2-1.7B-Instruct" # Larger but kind of boring
MODEL_STRING = "NousResearch/Hermes-3-Llama-3.1-8B"
@cpfiffer
cpfiffer / text_to_sql.py
Created February 7, 2025 20:03
Ultra-simple text-to-SQL with Outlines, using a small subset of the SQL grammar.
import outlines
import os
from pydantic import BaseModel, Field
from transformers import AutoTokenizer
model_str = 'Qwen/Qwen2.5-7B-Instruct-1M'
model = outlines.models.transformers(
model_str,
device='cuda'
)