Trending Vals
241
242
244
245
246
vtdocs
resyGetMatchingSlot
Script
(Part of: https://www.val.town/v/vtdocs.resyBot) This val attempts to return a single valid slot (per the time range requirements). If there are no valid slots, it throws an error. When there are multiple valid slots, it picks the middle slot (by ordering, not necessarily by time).
1
248
249
251
252
256
258
259
torlanco
shirtGenScript
HTTP
👕 Shirtgen API Endpoint Shirtgen lets you generate AI-powered t-shirt designs with just a prompt! 🖋️ Choose between the standard "Flux Schnell" model or the enhanced "Pro" model. Perfect for creating unique custom apparel in seconds! 🚀 💡 How it Works Send a POST request to the endpoint with your design prompt. Toggle between Standard and Pro models using the useProModel flag. The AI generates a high-quality t-shirt design based on your prompt. 📥 Expected POST Data {
"prompt": "A retro sunset with palm trees 🌴🌅",
"useProModel": true
}
0
260
266
pomdtr
code_search_is_easy
HTTP
Code Search is Easy Earlier this week, Tom MacWright posted Code Search is Hard . He describes the research he his doing to improve the code search experience of Val Town . It was a great read, and you might have seen it trending on Hacker News . As Val Town's most active user (behind Steve Krouse, one of the founders of Val Town), I for sure agree with Tom that the search feature needs improvements. But while reading his post, I immediately thought of a different approach to the problem. And a few hours later, Val Town Search was born. Do things that don't scale How does this new shiny search engine work? Well, it's quite simple. I wrote a Deno script that fetches all vals from the Val Town API. #!/usr/bin/env -S deno run -A
import * as path from "https://deno.land/std/path/mod.ts";
const dir = path.join(import.meta.dirname!, "..", "vals");
const blocklist = Deno.readTextFileSync(
path.join(import.meta.dirname!, "blocklist.txt")
)
.split("\n")
.map((line) => line.trim())
.filter((line) => line.length > 0);
let url = `https://api.val.town/v1/search/vals?limit=100&query=+`;
const vals = [];
while (true) {
console.log("fetching", url);
const resp = await fetch(url);
if (!resp.ok) {
console.error(resp.statusText);
Deno.exit(1);
}
const { data, links } = await resp.json();
vals.push(...data);
if (!links.next) {
break;
}
url = links.next;
}
Deno.removeSync(dir, { recursive: true });
Deno.mkdirSync(dir, { recursive: true });
for (const val of vals) {
const slug = `${val.author.username}/${val.name}`;
if (blocklist.includes(slug)) {
console.log("skipping", slug);
continue;
}
const userDir = path.join(dir, val.author.username);
Deno.mkdirSync(userDir, { recursive: true });
Deno.writeTextFileSync(path.join(userDir, `${val.name}.tsx`), val.code);
} I pushed the data to a Github Repository (now private) I added a Github Action that runs the script every hour to refresh the data. #!/usr/bin/env -S deno run -A
import * as path from "https://deno.land/std/path/mod.ts";
const dir = path.join(import.meta.dirname!, "..", "vals");
const blocklist = Deno.readTextFileSync(
path.join(import.meta.dirname!, "blocklist.txt")
)
.split("\n")
.map((line) => line.trim())
.filter((line) => line.length > 0);
let url = `https://api.val.town/v1/search/vals?limit=100&query=+`;
const vals = [];
while (true) {
console.log("fetching", url);
const resp = await fetch(url);
if (!resp.ok) {
console.error(resp.statusText);
Deno.exit(1);
}
const { data, links } = await resp.json();
vals.push(...data);
if (!links.next) {
break;
}
url = links.next;
}
Deno.removeSync(dir, { recursive: true });
Deno.mkdirSync(dir, { recursive: true });
for (const val of vals) {
const slug = `${val.author.username}/${val.name}`;
if (blocklist.includes(slug)) {
console.log("skipping", slug);
continue;
}
const userDir = path.join(dir, val.author.username);
Deno.mkdirSync(userDir, { recursive: true });
Deno.writeTextFileSync(path.join(userDir, `${val.name}.tsx`), val.code);
} I created a simple frontend on top of the Github Search API that allows you to search the data. It's hosted on Val Town (obviously). That was it. I didn't have to build a complex search engine, I just used the tools that were available to me. Is this a scalable solution for Val Town? Probably not. Am I abusing the Github API? Maybe. Does it work better than the current search feature of Val Town? Absolutely! I hope that the val.town engineers will come up with a search feature that will put my little project to shame. But for now, you won't find a better way to search for vals than Val Town Search . PS: This post was written / is served from Val Town
1
267
ashryanio
openAiProxy
HTTP
openAiProxy Overview This val is a proxy server that interacts with the OpenAI API to generate responses based on prompts in the request body. The function handles incoming HTTP POST requests, processes the prompt, and returns a response generated by the LLM. Prerequisites Server-side: (Optional) An active OpenAI API key Client-side: Something that can make POST requests (browser code, Postman, cURL, another Val, etc) Usage Endpoint The primary endpoint for this function is designed to handle HTTP POST requests. Request Method : POST Content-Type : application/json Body : JSON object containing a prompt field (e.g. {"prompt": "Help me make a boat."} ) Example Request curl -X POST https://ashryanio-openaiproxy.web.val.run -H "Content-Type: application/json" -d '{"prompt": "Hello, OpenAI!"}' Response Content-Type : application/json Body : JSON object containing the response from the OpenAI language model. Example Response {
"llmResponse": "Hi there! How can I assist you today?"
} Error Handling 400 Bad Request : Returned if the prompt field is missing in the request body. 405 Method Not Allowed : Returned if any method other than POST or OPTIONS is used. 500 Internal Server Error : Returned if there is an error processing the request.
1
269
270
dthyresson
bedtimeStoryMaker
HTTP
Bedtime Story Maker Inspired from a RedwoodJS demo I mde last year, this adds generative art powered by Fal to the bedtime story maker. Start writing a story by picking a style (spooky, colofrol, adventurous an animal (penguin, mouse, unicorn, whale ...) a color for the animal and activity (befriends aliens, goes to the doctor, rides a rollercoaster, bakes a cake for friends) It uses OpenAI to write a children's bedtime story title summary story for a "fantastical story about a green whale who rides the bus" or the "spooky story about the tomato fox who explores a cave". Then using the summary, OpenAI geenrates another prompt to describe the instructions to geneate a childrens story book image. That's sent to Fal to generate an image. Stories get saved to bedtime_stories in SQLite for viewing, searching and maybe sharing. You then get a bedtime story to enjoy!
2