Search

Results include substring matches and semantically similar vals. Learn more
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}`);
webup avatar
chatSampleFunctionExtraction
@webup
An interactive, runnable TypeScript val by webup
Script
import { chat } from "https://esm.town/v/webup/chat";
export const chatSampleFunctionExtraction = (async () => {
const input =
${input}
const functions = [
name: "information_extraction",
required: ["info"],
const response = await chat(prompt, { functions });
return JSON.parse(response?.arguments);
nealium avatar
myApi
@nealium
An interactive, runnable TypeScript val by nealium
Script
export function myApi(name) {
return "hi " + name;
std avatar
runVal
@std
An interactive, runnable TypeScript val by std
Script
import { fetch } from "https://esm.town/v/std/fetch";
import { API_URL } from "https://esm.town/v/std/API_URL";
export function runVal(name, ...args) {
return fetch(`${API_URL}/v1/run/${name.replace("@", "")}`, {
method: "POST",
andybak avatar
GltfXR
@andybak
An interactive, runnable TypeScript val by andybak
HTTP
export default function server(req: Request): Response {
const html = `
animate();
function init() {
scene = new THREE.Scene();
window.addEventListener('resize', onWindowResize);
function onSelectStart(event) {
this.userData.isSelecting = true;
function onSelectEnd(event) {
this.userData.isSelecting = false;
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
renderer.setSize(window.innerWidth, window.innerHeight);
function animate() {
renderer.setAnimationLoop(render);
function handleController(inputSource) {
const gamepad = inputSource.gamepad;
return null;
function render() {
const session = renderer.xr.getSession();
adagradschool avatar
claude_1044d60c_6ca2_4bb0_a80c_e9eababc3ebd
@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: {
patrickjm avatar
weatherTomorrowGpt3Example
@patrickjm
An interactive, runnable TypeScript val by patrickjm
Script
export let weatherTomorrowGpt3Example = weatherTomorrowGpt3({
city: "New York City",
openAiKey: process.env.openai_key,
jonbo avatar
nearbyJonBo
@jonbo
// Forked from @tmcw.big_story_visualization
Script
<script>
raw(`
function fetchTest() {
console.log("hi");
fetch("https://api.val.town/v1/run/jonbo.fetchBcycleCounts")
easrng avatar
getCaller
@easrng
An interactive, runnable TypeScript val by easrng
Script
import { dynamicImport } from "https://esm.town/v/easrng/dynamicImport";
export async function getCaller() {
if (arguments[0])
const realGetStore = AsyncLocalStorage.prototype.getStore;
AsyncLocalStorage.prototype.getStore = function (...a) {
asyncLocalStorage = this;
// i tried caching the asyncLocalStorage,
// but it seemingly gets replaced with null at the end of the function call
(getCaller2 as any)(true);
zzz avatar
TokenizerDemo
@zzz
// Demo of tokenizer to mimic behavior of https://platform.openai.com/tokenizer
Script
import { Tokenizer } from "https://esm.town/v/zzz/Tokenizer";
// Demo of tokenizer to mimic behavior of https://platform.openai.com/tokenizer
// Tokenizer uses "gpt-3.5-turbo" model by default but this demo uses davinci to match the playground
export const TokenizerDemo = (async () => {
dhvanil avatar
val_i4JBy56gt2
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_i4JBy56gt2(req) {
try {
// This demonstrates how simple rules can create complex, meaningful patterns
function createLSystem(axiom, rules, iterations) {
let result = axiom;
return result;
function interpretLSystem(instructions, angle) {
let x = 0, y = 0;
return path;
function visualizePath(path, width, height) {
// Normalize path to fit in our viewport
janpaul123 avatar
valle_tmp_9571549127942918010434925760972602
@janpaul123
@jsxImportSource https://esm.sh/react
HTTP
import OpenAI from "npm:openai";
unless strictly necessary, for example use APIs that don't require a key, prefer internal function
functions where possible. Unless specified, don't add error handling,
The val should create a "export default async function main" which is the main function that gets
// The val should create a "export default async function main() {" which
// is the main function that gets executed, without any arguments. Don't return a Response object,
function write(text) {
function updateValName(valName) {
function saveVal() {
function openTab(tab) {
dhvanil avatar
val_0gHzAuvnHy
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_0gHzAuvnHy(req) {
try {
// Execute the code directly and capture its result
tfayyaz avatar
honoJsPyodide
@tfayyaz
@jsxImportSource npm:hono/jsx
HTTP
const code = document.getElementById("code");
function addToOutput(s) {
console.log(code.value)
// init Pyodide
async function main() {
let pyodide = await loadPyodide();
let pyodideReadyPromise = main();
async function evaluatePython() {
let pyodide = await pyodideReadyPromise;
mjweaver01 avatar
PriestGPT
@mjweaver01
PriestGPT You are a helpful assistant for a reverent priest. Ask him about books or verses in the bible, and he will be sure to give you a short homily about it! If you want to know more about him, he'll be happy to tell you DEMO: https://mjweaver01-priestGPT.web.val.run/ask/proverbs If you fork this, you'll need to set OPENAI_API_KEY in your Val Town Secrets .
HTTP
DEMO: https://mjweaver01-priestGPT.web.val.run/ask/proverbs
If you fork this, you'll need to set `OPENAI_API_KEY` in your [Val Town Secrets](https://www.val.town/settings/secrets).
import { Hono } from "npm:hono";
import { OpenAI } from "npm:openai";
const priestGPT = async (verse: string, about?: boolean) => {
const openai = new OpenAI();
let chatCompletion = await openai.chat.completions.create({
messages: [