Search

Results include substring matches and semantically similar vals. Learn more
dpetrouk avatar
myApi
@dpetrouk
An interactive, runnable TypeScript val by dpetrouk
Script
export function myApi(name) {
return "hi " + name;
siveshs avatar
myApi
@siveshs
An interactive, runnable TypeScript val by siveshs
Script
export function myApi(name) {
return "hi " + name;
sl8r000 avatar
myApi
@sl8r000
An interactive, runnable TypeScript val by sl8r000
HTTP
export function myApi(name) {
return "hi " + name;
theo avatar
thanksPiazza
@theo
An interactive, runnable TypeScript val by theo
Script
export function thanksPiazza() {
console.log("good find!");
dhvanil avatar
web_AXDuIDWzNX
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function web_AXDuIDWzNX(req) {
return new Response(`<!DOCTYPE html>
<html>
dhvanil avatar
val_TJmKk47yej
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_TJmKk47yej(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
// Test 1: Check for patterns in random number generation
function testRandomness() {
const samples = 1000;
const numbers = [];
maxm avatar
HTreeTreeP
@maxm
H🌳🌳P H-Tree-Tree-P https://maxm-htreetreep.web.val.run/
HTTP
const TIMEOUT = 5 * oneSecond;
const DEFAULT_HANDLER = `export default async function (req: Request): Promise<Response> {
console.log(req.url)
logIt();
function parseResultSet<T>(row: ResultSet): T[] {
return row.rows.map((r) => Object.fromEntries(r.map((c, i) => [row.columns[i], c]))) as T[];
const real = target[key];
if (typeof real === "function" && typeof key === "string") {
const fn = function(...args: any[]) {
logs.push({
// The script we run within the worker. Don't reference anything
// outside of this function as it won't be available within the worker.
const workerScript = () => {
const real = target[key];
if (typeof real === "function" && typeof key === "string") {
const fn = function(...args: any[]) {
logs.push({
return fn;
async function evaluate(url) {
try {
stevekrouse avatar
calories
@stevekrouse
Calorie Count via Photo Uploads your photo to ChatGPT's new vision model to automatically categorize the food and estimate the calories.
HTTP
import { modifyImage } from "https://esm.town/v/stevekrouse/modifyImage";
import { chat } from "https://esm.town/v/stevekrouse/openai";
import { Hono } from "npm:hono@3";
function esmTown(url) {
return fetch(url, {
</div>,
export async function calorieEstimate(file: File) {
const dataURL = await fileToDataURL(file);
dereko avatar
myApi
@dereko
An interactive, runnable TypeScript val by dereko
Script
export function myApi(name) {
return "hi " + name;
stevekrouse avatar
upgradeHTTPPreviewVals
@stevekrouse
Auto-Upgrade for HTTP Preview This val is experimentally testing if we can use an LLM to determine if an old-style HTTP val needs to be upgraded for the new HTTP runtime, currently in preview. You can read more about the breaking change and upgrade proccess here: https://blog.val.town/blog/http-preview/#breaking-changes In some light testing, it seems like ChatGPT 3.5 and 4o both are bad at this task, so I'm pausing experimenting with this for now. Example output from 4o: [ { "name": "harlequinChickadee", "probabilityUpgradeNeeded": true, "reason": "The current code structure has several functions and program logic outside the main handler, including word selection, game state management, and SVG generation. These parts would not re-run with the new runtime, potentially affecting functionality. They need to be moved inside the handler to ensure consistent behavior across requests." }, { "name": "redElephant", "probabilityUpgradeNeeded": "100%", "reason": "The initialization of `fs` and `vscode` objects should occur \n inside the handler in the new runtime in order to ensure that they are \n freshly created for each request. This is critical since the new runtime \n does not rerun code outside of the handler for each request.." }, { "name": "untitled_indigoNightingale", "probabilityUpgradeNeeded": false, "reason": "The code initializes and configures the Hono app outside of the handler, but it does not appear to have any stateful logic that would need to be re-calculated with each request. Each request will call the handler provided by Hono and should behave the same in the new runtime." }, { "name": "untitled_pinkRoundworm", "probabilityUpgradeNeeded": true, "reason": "The functions `addComment` and `getComments` as well as the initialization \nof the KEY variable perform actions that are intended to be run per request. These need to be moved \ninside the relevant HTTP handler to ensure the behavior remains consistent in the new runtime." }, { "name": "untitled_harlequinIguana", "probabilityUpgradeNeeded": false, "reason": "The provided code defines the handler directly without any side effects or additional code outside the handler. The behavior should remain the same in the new runtime." }, { "name": "untitled_moccasinHeron", "probabilityUpgradeNeeded": false, "reason": "The code outside the handler is just a constant string declaration, which does not change behavior between requests. The handler itself handles requests correctly and independently." }, { "name": "untitled_maroonSwallow", "probabilityUpgradeNeeded": false, "reason": "All the code, including the check for authentication,\n is inside the handler function. This means the behavior will stay \n the same with the new runtime." }, { "name": "wikiOG", "probabilityUpgradeNeeded": true, "reason": "The function `getWikipediaInfo` defined outside of the handler makes network requests and processes data for each request. In the new runtime, this function would only be executed once and cached. To ensure the same behavior in the new runtime, this function should be moved into the handler." }, { "name": "parsePostBodyExample", "probabilityUpgradeNeeded": false, "reason": "All the code is inside the handler, so the behavior will remain consistent in the new runtime." }, { "name": "discordEventReceiver", "probabilityUpgradeNeeded": false, "reason": "All the relevant code for handling requests and logging input is inside the handler.\n No code needs to be moved for the new runtime to function correctly." } ] Feel free to fork this and try it yourself! If you could get it working, it'd be a big help for us as we upgrade the thousands of HTTP vals. Future ideas: Better LLM (Claude 3.5) Better prompt More examples JSON mode having it reply with upgraded code send pull requests to users with public vals that probably need upgrading
Script
"reason": "The current code structure has several functions and program logic outside the main handler, including word se
"reason": "The functions `addComment` and `getComments` as well as the initialization \nof the KEY variable perform actio
ode, including the check for authentication,\n is inside the handler function. This means the behavior will stay \n
import OpenAI from "npm:openai";
async function getVals(username, type, limit) {
async function checkHTTPPreviewUpgrade(code) {
const openai = new OpenAI();
const completion = await openai.chat.completions.create({
export default function(req: Request) {
export default async function(req: Request): Promise<Response> {
dhvanil avatar
web_J0B5T4JyqD
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function web_J0B5T4JyqD(req) {
return new Response(`<!DOCTYPE html>
<html>
ianjkaplan avatar
myApi
@ianjkaplan
An interactive, runnable TypeScript val by ianjkaplan
Script
export function myApi(name) {
return "hi " + name;
adagradschool avatar
glowingBronzeQuelea
@adagradschool
An interactive, runnable TypeScript val by adagradschool
HTTP
export default function handler(req) {
return new Response(`"\n <!DOCTYPE html>\n <html>\n <head>\n <title>Claude Chat Conversation</title
headers: {
dhvanil avatar
web_GgRfBRQZjp
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function web_GgRfBRQZjp(req) {
return new Response(`<!DOCTYPE html>
<html>
pomdtr avatar
valTownSearch
@pomdtr
Val Town Search Search for vals using the Github API. Either use the provided UI, or the query param: https://val-town-search.pomdtr.me/search?q=fetchJSON How does it work ? I've wrote about it! Todos [x] Embed the results in the UI [x] Refresh the vals on a cron using a github action [ ] Improve layout on small screens [ ] Support json Accept header [ ] Add pagination params [ ] Allow to filter by authors
HTTP
import { render } from "npm:preact-render-to-string";
const githubQuery = (query: string) => encodeURIComponent(`${query} repo:pomdtr/val-town-mirror path:vals/`);
async function handler(req: Request) {
const url = new URL(req.url);
if (url.pathname == "/opensearch.xml") {