2024-12-19

A day in the mind of Claude Sonnet

Dan Corin (@danielcorin.com) 2024-12-19T21:21:16.724Z

To create this animation for a day in the mind of Claude Sonnet, I used Sonnet to write the following code

  • to generate the HTML with this Python script
  • capture PNGs with puppeteer
  • use ffmpeg to stitch them together
import llm
import requests
import time
from pathlib import Path
from datetime import datetime, timedelta

MODELS = ["claude-3-5-sonnet-latest"]


def get_temp_weather(hour):
    if hour < 14:
        temp = 30 + (24 * (hour / 14))
    else:
        temp = 54 - (27 * ((hour - 14) / 10))

    if hour < 6:
        weather = "cold"
    elif hour < 18:
        weather = "sunny"
    else:
        weather = "snowing"

    return round(temp), weather


now = str(int(time.time()))
out_dir = Path("out") / now
out_dir.mkdir(parents=True, exist_ok=True)

start_time = datetime.now().replace(hour=0, minute=0, second=0, microsecond=0)
end_time = start_time + timedelta(days=1)
current = start_time

start_time = datetime.now().replace(hour=0, minute=0, second=0, microsecond=0)
specific_times = [
    start_time.replace(hour=2, minute=30),
    start_time.replace(hour=3, minute=0),
    start_time.replace(hour=5, minute=0),
]

for current in specific_times:
    hour = current.hour
    minute = current.minute

    temp, weather = get_temp_weather(hour)
    time_str = current.strftime("%I:%M %p")

    PROMPT = f"""It is {time_str}. {temp}°F and {weather}.
Generate subtle, abstract art using SVG in an HTML page that fills 100% of the browser viewport.
Take inspiration for the style, colors and aesthetic using the current weather and time of day.
Prefer subtle colors but it's ok to use intense colors sparingly.
No talk, no code fences. Code only."""

    timestamp = current.strftime("%H_%M")
    prompt_file = out_dir / f"prompt_{timestamp}.txt"
    prompt_file.write_text(PROMPT)

    for m in MODELS:
        model = llm.get_model(m)
        response = model.prompt(PROMPT, temperature=1.0)
        out_file = out_dir / f"{timestamp}_{m}.html"
        out_file.write_text(response.text())

    current += timedelta(minutes=30)
const puppeteer = require('puppeteer');


async function createGif() {
    const browser = await puppeteer.launch();
    const page = await browser.newPage();

    await page.setViewport({
        width: 800,
        height: 600
    });

    const htmlFiles = [
        // paths to html files
    ];

    for (let i = 0; i < htmlFiles.length; i++) {
        await page.goto(`file://${__dirname}/${htmlFiles[i]}`);
        await page.screenshot({
            path: `frame${i}.png`
        });
    }

    await browser.close();
}

createGif();
ffmpeg -framerate 2 -i timestamped_frame%d.png -c:v libx264 -pix_fmt yuv420p output.mp4

2024-12-17

I’ve been setting up the foundations to add node summaries to Delta. Ideally, I will use the same model to create the node summaries as I use to generate the responses since this will keep the model dependencies minimal. However, my early experiments have yielded some inconsistency in how a shared prompt behaves across models. To try and understand this and smooth it out as much as possible, I plan to set up evals to ensure the summaries are

2024-12-14

Inspired by Simon’s pelican-bicycle repo, I played around a bit with using LLMs to generate visuals with SVGs, Three.js and pure CSS.

I posted about some of the results here.

Inspired by @simonwillison.net's pelican-bicycle repo, here are some CSS sunsets by gpt-4o, claude-3-5-sonnet and gemini-2.0-flash-exp. Sonnet and Gemini animate the birds and clouds. Prompt: Generate pure HTML/CSS art of an extremely detailed, beautiful sunset. No talk or code fences. Code only.

2024-12-12

Got Delta working on other machines. It took a lot longer than I expected. I spent most of the time dealing with build issues regarding:

  • missing dependencies
  • different paths between dev and production
  • loading vec.dylib with sqlite-vec
  • dependencies compiled for the wrong architecture

I tried to write some of this up but it’s been challenging to extract and/or remember the specific circumstances and how I solved it in the context of some minimal example. There are lots of parts that feel a bit wrong or regrettable but were compromises to getting the thing working.

I don’t know anything about rice disease but apparently these are various rice diseases and this is what they look like.

  • Jeremy Howard, Fast.ai Course Lesson 6 I have no idea if Jeremy had this in mind when he said this (alluding to the fact he doesn’t know about the subject area, but when building with ML that doesn’t necessarily matter), but this sentiment is how I feel when building with and learning about anything new with language models, at least to start. I use LLMs to bootstrap my understanding of whatever situation I find myself in, and from there, try to orient myself and gain a better understanding.

It’s incredible to be able to learn from whatever your starting point is rather than needing to try and read less relevant introductory material to start to understand an area. It’s akin to having a CSV and wanting to run SQL queries on your data and needing to start by reading the pandas or sqlite documentation.

The developer space is moving so fast. I went from thinking Cursor’s cmd+k was the greatest thing, to using Windsurf’s Cascade, the new Cursor composer and bolt.new in a week. Powerful tools.

I’m working on a conversation branching tool called “Delta” (for now). The first thing that led me to this idea came from chatting with Llama 3.2 and experimenting with different system prompts. I was actually trying to build myself a local version of an app I’ve been fascinated by called Dot.

I noticed that as conversations with models progressed, they became more interesting. A friend made a point that really stuck in my head about how you “build trust” with a model over multiple conversation turns. While you can write system prompts to steer the model to respond with more details and longer paragraphs, I observed that regardless of the system prompt, as conversations went on longer (more turns, more exchanges, longer message history), the responses became more interesting and better calibrated to what I was looking for. The model seemed to display a more coherent understanding of what I was talking about.

2024-11-16

Would another day of editing fundamentally change the value readers get? Probably not. Ship it and move on to your next idea while you’re still energized.