Skip to content

Instantly share code, notes, and snippets.

View simonw's full-sized avatar

Simon Willison simonw

View GitHub Profile
@simonw
simonw / response.json
Created November 29, 2024 01:38
GPT-4o audio response
{
"id": "chatcmpl-AYkFZgbbiEHMbPep0zSJqZgKy98tb",
"object": "chat.completion",
"created": 1732844301,
"model": "gpt-4o-audio-preview-2024-10-01",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
@simonw
simonw / response.json
Created November 28, 2024 17:26
GPT-4o audio response
{
"id": "chatcmpl-AYcVyamO3LWB0bHxdEce5LIQFxiyr",
"object": "chat.completion",
"created": 1732814566,
"model": "gpt-4o-audio-preview-2024-10-01",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
@simonw
simonw / response.json
Created November 28, 2024 17:21
GPT-4o audio response
{
"id": "chatcmpl-AYcUExCrHXAgXBMCwrAZMgEzCo3FI",
"object": "chat.completion",
"created": 1732814458,
"model": "gpt-4o-audio-preview-2024-10-01",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
@simonw
simonw / response.json
Created November 28, 2024 17:16
GPT-4o audio response
{
"id": "chatcmpl-AYcOayqBxD4u71IOw9suremupLmnB",
"object": "chat.completion",
"created": 1732814108,
"model": "gpt-4o-audio-preview-2024-10-01",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
# /// script
# dependencies = [
# "atproto"
# ]
# ///
from atproto import Client
import getpass
import time
@simonw
simonw / mlx_whisper_realtime.py
Last active November 23, 2024 19:10 — forked from ivanfioravanti/mlx_whisper_realtime.py
mlx-whisper real time audio
# /// script
# dependencies = [
# "SpeechRecognition",
# "mlx-whisper",
# "pyaudio",
# ]
# ///
import speech_recognition as sr
import numpy as np
/**
* Creates a private GitHub Gist
* @param {string} description - Gist description
* @param {Object.<string, string>} files - Object with filenames as keys and content as values
* @param {string} token - GitHub Personal Access Token with gist scope
* @returns {Promise<Object>} - GitHub Gist API response object
* @throws {Error} - If the API request fails
*/
async function createPrivateGist(description, files, token) {
if (!token) {
import base64
import httpx
import llm
from PIL import Image
import io
@llm.hookimpl
def register_embedding_models(register):
@simonw
simonw / rag-demo.ts
Created June 20, 2024 17:17
Val.Town demo from this morning
import { basicAuth } from "https://esm.town/v/pomdtr/basicAuth?v=65";
import Anthropic from "npm:@anthropic-ai/sdk@0.24.0";
const anthropic = new Anthropic();
async function suggestKeywords(question) {
const message = await anthropic.messages.create({
max_tokens: 128,
model: "claude-3-5-sonnet-20240620",
tools: [{
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[338],{578:(e,t,r)=>{e.exports=r.p+"7cf7ced34f0a1ece31b4.wasm"},338:(e,t,r)=>{var n;r.r(t),r.d(t,{default:()=>a});const a=(n="file:///private/tmp/node_modules/@jitl/quickjs-wasmfile-release-sync/dist/emscripten-module.browser.mjs",function(e={}){var t,a,o=e;function i(e){e={log:e||function(){}};for(const t of i.za)t(e);return o.quickJSEmscriptenExtensions=e}o.ready=new Promise(((e,r)=>{t=e,a=r})),i.za=[],o.quickjsEmscriptenInit=i,i.za.push((e=>{e.getWasmMemory=function(){return Q}}));var _,u=Object.assign({},o),l="./this.program",s="object"==typeof window,f="function"==typeof importScripts,S="";(s||f)&&(f?S=self.location.href:"undefined"!=typeof document&&document.currentScript&&(S=document.currentScript.src),n&&(S=n),S=0!==S.indexOf("blob:")?S.substr(0,S.replace(/[?#].*/,"").lastIndexOf("/")+1):"",f&&(_=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}));var c,T=o.print||con