Search

Results include substring matches and semantically similar vals. Learn more
ylno avatar
whiteSnail
@ylno
An interactive, runnable TypeScript val by ylno
Script
import { OpenAI } from "https://esm.town/v/std/openai";
const openai = new OpenAI();
const completion = await openai.chat.completions.create({
messages: [
{ role: "user", content: "Tell a story" },
model: "gpt-4",
max_tokens: 30,
console.log(completion.choices[0].message.content);
nbaschez avatar
htmlExample
@nbaschez
HTML example This is an example of how to return an HTML response. You can also preview it at https://andreterron-htmlExample.web.val.run?name=Andre
HTTP (deprecated)
# HTML example
This is an example of how to return an HTML response.
You can also preview it at https://andreterron-htmlExample.web.val.run?name=Andre
// View at https://andreterron-htmlExample.web.val.run?name=Andre
export default async function(req: Request): Promise<Response> {
const query = new URL(req.url).searchParams;
// Read name from the querystring or body. Defaults to "you" if not present.
const name = query.get("name") || (await req.json().catch(() => ({}))).name || "you";
// Returns the HTML response
return new Response(
metart43 avatar
webhookHandler
@metart43
An interactive, runnable TypeScript val by metart43
Script
export async function webhookHandler(req: express.Request, res: express.Response) {
let page;
const ftRSSFeedRes = await fetchRSS(
"https://www.ft.com/news-feed?format=rss",
const rssFeedItems = ftRSSFeedRes?.channel?.item;
const channel = ftRSSFeedRes?.channel;
if (rssFeedItems) {
page = generateHTMLFromRSS({
rssFeedItems,
categoryLink: channel.link,
janpaul123 avatar
valle_tmp_82429476471184249764330565705816
@janpaul123
// This val will respond with a styled HTML form for users to input their name
HTTP (deprecated)
// This val will respond with a styled HTML form for users to input their name
export default async function (req: Request): Promise<Response> {
if (req.method === "POST") {
const formData = new URLSearchParams(await req.text());
const name = formData.get("name") ?? "Stranger"; // Default to "Stranger" if no name provided
return new Response(`<h1 style="color: #333; text-align: center;">Hello, ${name}!</h1>`, { headers: { "Content-Type": "te
return new Response(`
<html>
<head>
<title>Greetings Form</title>
zhsumei avatar
chatSampleSystemRoleSimple
@zhsumei
An interactive, runnable TypeScript val by zhsumei
Script
import { chat } from "https://esm.town/v/webup/chat?v=23";
export const chatSampleSystemRoleSimple = (async () => {
const messages = [
{ role: "system", content: "你是⼀个助⼿,请以 Seuss 苏斯博⼠的⻛格做出回答" },
{ role: "assistant", content: "就快乐的⼩鲸⻥为主题给我写⼀⾸短诗" },
return await chat(messages);
tal avatar
DOEMenuTypes
@tal
An interactive, runnable TypeScript val by tal
Script
export const DOEMenuTypes = {
"High-School-Express-Cold-Lunch-Menu": {
title: "High School Express Cold Lunch",
"high-school-express-hot-lunch-menu": {
title: "High School Express Hot Lunch",
"high-school-lunch-menu": {
title: "High School Lunch",
"Infant-Toddler-Lunch-Menu": {
title: "Infant Toddler Lunch Menu",
"j-h-s-middle-school-lunch-menu": {
janpaul123 avatar
mybool
@janpaul123
An interactive, runnable TypeScript val by janpaul123
Script
import { bool } from "https://esm.town/v/stevekrouse/bool?v=1";
export let mybool = bool
ooo_ooo_oooooh avatar
myApi
@ooo_ooo_oooooh
An interactive, runnable TypeScript val by ooo_ooo_oooooh
Script
export function myApi(question, answer) {
return `${question}? - ${answer}`;
iamseeley avatar
Setup
@iamseeley
An interactive, runnable TypeScript val by iamseeley
Script
await sqlite.execute(`
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
username TEXT UNIQUE,
email TEXT UNIQUE,
password TEXT,
name TEXT,
bio TEXT,
profile_image BLOB
await sqlite.execute(`
iamseeley avatar
pyodidePowersVis
@iamseeley
An interactive, runnable TypeScript val by iamseeley
HTTP (deprecated)
export const pyodideExample = () => {
const html = `
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>My Pyodide App</title>
<script type="text/javascript" src="https://cdn.jsdelivr.net/pyodide/v0.25.1/full/pyodide.js"></script>
</head>
<body>
tempdev avatar
handler
@tempdev
An interactive, runnable TypeScript val by tempdev
Script
// HTML renderer
primewireApiKey,
primewireBase,
} from "https://raw.githubusercontent.com/Ciarands/mw-providers/dev/src/providers/sources/primewire/common.ts";
interface Meta {
current_quality: string;
id: string;
imdb_id: string;
title: string;
tvdb_id?: null | string;
stevekrouse avatar
sqlite_explorer
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
HTTP (deprecated)
export { default } from "https://esm.town/v/nbbaier/sqliteExplorerApp?v=81";
substrate avatar
gifStory
@substrate
Generates a story and then a storyboard with 5 animated frames. Note : You'll need to fork this example (and un-comment some code) to run it with new input. Currently it renders cached output, for demo purposes (running takes 30-60s). 🪩 To fork, sign up for Substrate to get your own API key and $50 free credits
HTTP (deprecated)
Generates a story and then a storyboard with 5 animated frames.
**Note**: You'll need to fork this example (and un-comment some code) to run it with new input.
Currently it renders cached output, for demo purposes (running takes 30-60s).
🪩 To fork, [sign up for Substrate](https://substrate.run/signin) to get your own API key and $50 free credits
const substrate = new Substrate({ apiKey: Deno.env.get("SUBSTRATE_API_KEY") });
const topic = "a traveler lost in a rainforest";
const story = new ComputeText({
prompt: `tell me a story about ${topic}`,
story.cache_age = 60 * 60 * 24 * 7;
const sentencesSchema = z.object({
neverstew avatar
sleep
@neverstew
An interactive, runnable TypeScript val by neverstew
Script
export function sleep(milliseconds = 3000) {
return new Promise(resolve => setTimeout(resolve, milliseconds));
maxm avatar
sqlite_explorer
@maxm
An interactive, runnable TypeScript val by maxm
HTTP (deprecated)
export { default } from "https://esm.town/v/nbbaier/sqliteExplorerApp?v=86";