Search

Results include substring matches and semantically similar vals. Learn more
proto avatar
pokeMe
@proto
An interactive, runnable TypeScript val by proto
Script
let { pokes } = await import("https://esm.town/v/__proto__/pokes");
export function pokeMe() {
pokes = (pokes || 0) + 1;
console.email(pokes);
dhvanil avatar
val_LOKsjYBC40
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_LOKsjYBC40(req) {
try {
// Execute the code directly and capture its result
olivercole avatar
myApi
@olivercole
An interactive, runnable TypeScript val by olivercole
Script
export function myApi(name) {
return "hi " + name;
dhvanil avatar
val_IRL0Iqm2q4
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_IRL0Iqm2q4(req) {
try {
// Execute the code directly and capture its result
stevekrouse avatar
serverlessMatrixEchoBot
@stevekrouse
// https://stevekrouse-serverlessMatrixEchoBot.express.val.run/_matrix/push/v1/notify
Express (deprecated)
// https://stevekrouse-serverlessMatrixEchoBot.express.val.run/_matrix/push/v1/notify
export async function serverlessMatrixEchoBot(req, res) {
res.send(req.path);
sboesen avatar
r1
@sboesen
R1 Email AI Assistant Chat with R1 (with PDF attachment support) What It Does This script allows you to: Send emails to R1. The text will be treated as the prompt Parse PDF attachments and include their contents in the AI's analysis. Get response directly to your inbox. Thinking response is included below the reply. Setup guide Copy this Val and save it as an Email Val (choose Val type in top-right corner of editor) Add your Fireworks (or openai API compatible) API key to line 8 (or use an environment variable: https://docs.val.town/reference/environment-variables/) Copy the email address of the Val (click 3 dots in top-right > Copy > Copy email address) Write your email, include any attachments, and send it to the Val email address. The AI will respond after a few seconds.
Email
2. Add your Fireworks (or openai API compatible) API key to line 8 (or use an environment variable: https://docs.val.town/ref
import OpenAI from "https://esm.sh/openai@4.24.1";
// main controller function
export default async function(receivedEmail) {
async function extractAttachments(email) {
async function extractPdfText(attachments) {
// helper function to generate a prompt for AI
function generatePrompt(email, pdfTexts, emailText) {
// helper function to send a request to Fireworks.ai
async function sendRequestToFireworks(prompt, apiKey, model) {
const client = new OpenAI({
AppleLamps avatar
VEOPROMPTER
@AppleLamps
@jsxImportSource https://esm.sh/react@18.2.0
HTTP
import React, { useEffect, useState } from "https://esm.sh/react@18.2.0";
function App() {
const [input, setInput] = useState("");
</div>
function client() {
createRoot(document.getElementById("root")).render(<App />);
client();
export default async function server(request: Request): Promise<Response> {
if (request.method === "POST") {
if (url.pathname === "/generate-prompts") {
const { OpenAI } = await import("https://esm.sh/openai@4.11.1");
const openai = new OpenAI({
apiKey: Deno.env.get("OPENAI_API_KEY"),
const body = await request.json();
try {
const completion = await openai.chat.completions.create({
model: "chatgpt-4o-latest", // Changed from "gpt-4o-latest" to "chatgpt-4o-latest"
if (!response) {
throw new Error("No response from OpenAI");
const [conciseSection, detailedSection] = response.split("\n\n");
stevekrouse avatar
passkeys_demo
@stevekrouse
Passkeys Demo Passkeys are pretty neat! I wanted to get a demo working in Val Town so I ported over https://github.com/maximousblk/passkeys-demo. One challenge was that the original extensively uses DenoKV store with compound keys and values. I created @stevekrouse/DenoSyntheticKV as a replacement for DenoKV. It uses SuperJSON to encode the keys and values. You can find the client-side script for the main page here: @stevekrouse/passkey_script
HTTP
// UTILS
function generateJWT(userId: string) {
return new SignJWT({ userId }).setProtectedHeader({ alg: "HS256" }).sign(SECRET);
function verifyJWT(token: string) {
return jwtVerify(token, SECRET);
function generateRandomString() {
return Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
nbbaier avatar
draftReadme
@nbbaier
Code Documentation Assistant The Code Documentation Assistant is an AI-powered tool that helps generate documentation for code. It uses the OpenAI GPT-3.5 Turbo model to generate readme files in GitHub-flavored markdown based on the provided code. Usage Importing the Code Documentation Assistant import { draftReadme, writeReadme } from "code-doc-assistant"; Function: draftReadme async function draftReadme(options: WriterOptions): Promise<string> The draftReadme function generates a readme file based on the provided options. Parameters options (required): An object containing the following properties: username (string): The username of the code owner. valName (string): The name of the Val containing the code. model (optional, default: "gpt-3.5-turbo"): The OpenAI model to use for generating the readme. userPrompt (optional): Additional prompt to include in the documentation. Return Value A promise that resolves to a string representing the generated readme file. Function: writeReadme async function writeReadme(options: WriterOptions): Promise<string> The writeReadme function generates a readme file and updates the readme of the corresponding Val with the generated content. Parameters options (required): An object containing the following properties: username (string): The username of the code owner. valName (string): The name of the Val containing the code. model (optional, default: "gpt-3.5-turbo"): The OpenAI model to use for generating the readme. userPrompt (optional): Additional prompt to include in the documentation. Return Value A promise that resolves to a string indicating the success of the readme update. Example import { draftReadme, writeReadme } from "code-doc-assistant"; const options = { username: "your-username", valName: "your-val-name", }; const generatedReadme = await draftReadme(options); console.log(generatedReadme); const successMessage = await writeReadme(options); console.log(successMessage); License This project is licensed under the MIT License .
Script
s an AI-powered tool that helps generate documentation for code. It uses the OpenAI GPT-3.5 Turbo model to generate readme fi
### Function: draftReadme
async function draftReadme(options: WriterOptions): Promise<string>
import OpenAI, { type ClientOptions } from "npm:openai";
function createPrompt(code: string, userPrompt?: string) {
async function getVal(username: string, valName: string) {
async function performOpenAICall(prompt: string, model: string, openaiOptions: ClientOptions) {
const openai = new OpenAI(openaiOptions);
const response = await openai.chat.completions.create({
throw new Error("No response from OpenAI");
throw new Error("No readme returned by OpenAI. Try again.");
async function updateReadme(id: string, readme: string) {
async function draftReadme(options: WriterOptions) {
dnishiyama avatar
dailySlackStandup
@dnishiyama
// Depending on the day do one of these:
Cron
import { fetch } from "https://esm.town/v/std/fetch";
import { OpenAI } from "https://esm.town/v/std/openai";
import process from "node:process";
const openai = new OpenAI();
// Depending on the day do one of these:
console.log(prompt);
const completion = await openai.chat.completions.create({
messages: [
carts avatar
motionlessPurpleBat
@carts
An interactive, runnable TypeScript val by carts
HTTP
import { OpenAI } from "https://esm.town/v/std/openai?v=4";
const prompt = "Tell me a dad joke. Format the response as JSON with 'setup' and 'punchline' keys.";
const style = "<style>body{font-family:system-ui,sans-serif;margin:0;padding:32px}</style>";
export default async function dailyDadJoke(req: Request): Response {
const openai = new OpenAI();
const resp = await openai.chat.completions.create({
messages: [
pomdtr avatar
playground
@pomdtr
playground edit, run, and embed vals without requiring an account (or even js enabled!) caveats: logs don't stream I haven't set up codemirror only script vals supported everything else should be fully functional. you can prefill the editor with code: https://easrng-playground.web.val.run/?code=console.log(1) a val: https://easrng-playground.web.val.run/?load=easrng/playground some other url: https://easrng-playground.web.val.run/?load=https://any/other/url
Script
- only script vals supported
everything else should be fully functional.
you can prefill the editor with
args: unknown[];
async function execute(
code: string,
const markStackEnd = crypto.randomUUID();
function cleanStack(stack: string) {
let lines: string[] = [];
const real = target[key];
if (typeof real === "function" && typeof key === "string") {
const fn = function(...args: any[]) {
logs.push({
return fn;
async function run() {
try {
stevekrouse avatar
runs
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Script
import { searchParams } from "https://esm.town/v/stevekrouse/searchParams";
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
export function runs({ token, error, source, since, until, offset, limit }: {
token: string;
error?: boolean;
nbbaier avatar
WriterOptions
@nbbaier
An interactive, runnable TypeScript val by nbbaier
Script
import { type ClientOptions } from "npm:openai";
export interface WriterOptions extends ClientOptions {
model?: string;
CoachCompanion avatar
efficientAmberUnicorn
@CoachCompanion
@jsxImportSource https://esm.sh/react@18.2.0
HTTP
// ... (previous code remains unchanged)
async function server(request: Request): Promise<Response> {
if (request.method === "POST" && new URL(request.url).pathname === "/generate-training") {
console.warn("YouTube API key (YOUTUBE_API_KEY2) is not set. Falling back to search URL method.");
const { OpenAI } = await import("https://esm.town/v/std/openai");
const regenerateKey = request.headers.get("Regenerate-Key") || "0";
const openai = new OpenAI();
const { sport, skillLevel, ageGroup, groupSize, selectedTopics, sessionDuration } = await request.json();
headers: { "Content-Type": "application/json" },
// ... (rest of the server function remains unchanged)
async function getYouTubeVideoData(query, sport, apiKey, useApiKey = true) {
if (useApiKey) {
return null;
function isVideoRelevant(videoData, sport, query) {
const relevanceScore = calculateRelevanceScore(videoData, sport, query);
return relevanceScore > 0.6; // Threshold for relevance
function calculateRelevanceScore(videoData, sport, query) {
let score = 0;
return Math.min(score, 1); // Ensure score doesn't exceed 1
function getFallbackYouTubeLink(query, sport) {
const searchQuery = encodeURIComponent(`${sport} ${query}`);