Search
myApi
@mateuszrusyn
An interactive, runnable TypeScript val by mateuszrusyn
Script
export function myApi(name) {
return "hi " + name;
connect4_mcts_agent
@saolsen
Connect4 agent that uses Monte-Carlo tree search to simulate 10,000 random games from each possible action and pick the one with the highest win rate.
Ported from a version I made in rust. https://github.com/saolsen/connect4 https://www.steveindusteves.com/p/connect4-mcts
HTTP
const SIMULATIONS = 10000;
function rand_action(state: connect4.State): connect4.Action {
const player = state.next_player;
return action;
function score_action(
current_state: connect4.State,
return score / SIMULATIONS;
function agent(state: connect4.State): connect4.Action {
// For each action we could take, simulate multiple random games from the resulting state.
val_9vc52PbAY5
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_9vc52PbAY5(req) {
try {
// Execute the code directly and capture its result
runPythonAsync
@joshuahhh
An interactive, runnable TypeScript val by joshuahhh
Script
const { loadPyodide } = await import("https://www.unpkg.com/pyodide/pyodide.mjs");
const pyodide = await loadPyodide();
export function runPythonAsync(s) {
return pyodide.runPythonAsync(s);
MuxAITranscript
@decepulis
Generate CuePoints and transcripts for your Mux video Adapted from the blog post, Build an AI-powered interactive video transcript with Mux Player CuePoints This Val exposes an HTTP endpoint that takes a Mux Asset ID and a list of speakers and Uses Mux's auto-generated captions to generate a CuePoints object for Mux Player Uses AssemblyAI for speaker labeling (diarization) Uses GPT-4o to format text Fork it and use it as a foundation for your own interactive video transcript project. Usage: Required environment variables: Mux Access token details ( MUX_TOKEN_ID , MUX_TOKEN_SECRET ) This endpoint requires an existing Mux asset that's ready with an audio-only static rendition associated with it. You can run this val to create a new one for testing. AssemblyAI API key ( ASSEMBLYAI_API_KEY ). Get it from their dashboard here OpenAI API key ( OPENAI_API_KEY ). Get it from their dashboard here Make a POST request to the Val's endpoint with the following body, replacing the values with your own asset ID and the list of speakers. Speakers are listed in order of appearance. {
"asset_id": "00OZ8VnQ01wDNQDdI8Qw3kf01FkGTtkMq2CW901ltq64Jyc",
"speakers": ["Matt", "Nick"]
} Limitations This is just a demo, so it's obviously not battle hardened. The biggest issue is that it does this whole process synchronously, so if the any step takes longer than the Val's timeout, you're hosed.
HTTP
- OpenAI API key (`OPENAI_API_KEY`). Get it [from their dashboard here](https://platform.openai.com/api-keys)
import OpenAI from "npm:openai";
import { zodResponseFormat } from "npm:openai/helpers/zod";
const openai = new OpenAI({
async function getMuxAsset(assetId: string) {
function createSpeakersObject(speakersArray: string[]) {
async function getCuePointsFromMux(asset: Mux.Video.Assets.Asset): Promise<MuxCuePoint[]> {
async function getCuePointsFromAssemblyAI(
async function formatTextWithGPT4o(aaiCuePoints: AssemblyAICuePoint[]) {
const completion = await openai.chat.completions.create({
export default async function(req: Request): Promise<Response> {
myApi
@eagle251
An interactive, runnable TypeScript val by eagle251
Script
export function myApi(name) {
return "hi " + name;
myApi
@danielraffel
An interactive, runnable TypeScript val by danielraffel
Script
export function myApi(name) {
return "hi " + name;
valle_tmp_40006751975257874463561930335375
@janpaul123
// Define the main function that will be executed on each HTTP request
HTTP
// Define the main function that will be executed on each HTTP request
export default async function main(req: Request): Promise<Response> {
// Return a simple "Hello, World!" response
return new Response("Hello, World!", { headers: { "Content-Type": "text/plain" } });
myApi
@steveb1313
An interactive, runnable TypeScript val by steveb1313
Script
export function myApi(name) {
return "hi " + name;
mgsrBotEndpoint2
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
HTTP
import { example1 } from "https://esm.town/v/stevekrouse/example1?v=3";
import process from "node:process";
export async function mgsrBotEndpoint(request) {
const signatureTimestamp = request.headers.get("X-Signature-Timestamp");
const signatureEd25519 = request.headers.get("X-Signature-Ed25519");
status: status,
headers: { "Content-Type": "application/json" },
async function handleApplicationCommands(body) {
let response;
switch (body.data.name) {
GistGPT
@weaverwhale
GistGPT A helpful assistant who provides the gist of a gist How to use / and /gist - Default response is to explain this file. I believe this is effectively real-time recursion ? /gist?url={URL} - Provide a RAW file URL from Github, BitBucket, GitLab, Val Town, etc. and GistGPT will provide you the gist of the code. /about - "Tell me a little bit about yourself"
HTTP
import { Hono } from "npm:hono";
import { OpenAI } from "npm:openai";
const gistGPT = async (input: string, about?: boolean) => {
const chatInput = about ? input : await (await fetch(input)).text();
const openai = new OpenAI();
let chatCompletion = await openai.chat.completions.create({
messages: [
myApi
@genevra
An interactive, runnable TypeScript val by genevra
Script
export function myApi(name) {
return "hi " + name;
cerebras_coder
@stevekrouse
This is an AI code assistant powered by Cerebras , running llama3.3-70b. Inspired by Hassan's Llama Coder . Setup Sign up for Cerebras Get a Cerebras API Key Save it in a Val Town environment variable called CEREBRAS_API_KEY
HTTP
function Hero({
Turn your ideas into fully functional apps in{" "}
function App() {
function handleStarterPromptClick(promptItem: typeof prompts[number]) {
async function handleSubmit(e: React.FormEvent | string) {
function handleVersionChange(direction: "back" | "forward") {
function client() {
function extractCodeFromFence(text: string): string {
async function generateCode(prompt: string, currentCode: string) {
export default async function cerebras_coder(req: Request): Promise<Response> {
aqiNotifier
@realog
An interactive, runnable TypeScript val by realog
Script
import { databaseVal } from "https://esm.town/v/realog/databaseVal";
import { easyAQI } from "https://esm.town/v/stevekrouse/easyAQI?v=3";
export async function aqiNotifier(location) {
// The realtime Air Quality Index (AQI) for any location
const myAQI = await easyAQI({