valleBlogV0README.md1 match
1* Fork this val to your own profile.
2* Create a [Val Town API token](https://www.val.town/settings/api), open the browser preview of this val, and use the API token as the password to log in.
3
dailyDadJokeREADME.md2 matches
113. 🤣🤣🤣🤣
1213## API
1415This val uses the [icanhazdadjoke API](https://icanhazdadjoke.com/api). You can find [more docs here](https://github.com/15Dkatz/official_joke_api), such as how to [filter by type](https://github.com/15Dkatz/official_joke_api?tab=readme-ov-file#grab-jokes-by-type).
dailyDadJokemain.tsx1 match
34export async function dailyDadJoke() {
5let { setup, punchline } = await fetchJSON("https://official-joke-api.appspot.com/random_joke");
6return email({
7text: punchline,
legitimateTanTigermain.tsx12 matches
1/**
2* This code creates a search engine prototype with autocomplete functionality using the Cerebras LLM API.
3* It uses React for the frontend and the Cerebras API for generating autocomplete suggestions.
4* The suggestions are cached in the browser to reduce API calls.
5* It implements a two-step LLM process: first to get initial suggestions, then to filter them for sensibility and ethics.
6* If the second LLM call fails, it displays "Failed to fetch" instead of showing results.
104if (request.method === "POST" && new URL(request.url).pathname === "/suggestions") {
105const { query } = await request.json();
106const apiKey = Deno.env.get("CEREBRAS_API_KEY");
107const initialSuggestions: string[] = [];
108109if (!apiKey) {
110return new Response(JSON.stringify({ error: "API key not found" }), {
111status: 500,
112headers: { "Content-Type": "application/json" },
115116try {
117const response = await fetch("https://api.cerebras.ai/v1/chat/completions", {
118method: "POST",
119headers: {
120"Content-Type": "application/json",
121"Authorization": `Bearer ${apiKey}`,
122},
123body: JSON.stringify({
137138if (!response.ok) {
139throw new Error("Failed to fetch from Cerebras API");
140}
141146147// Second LLM call to filter suggestions
148const filterResponse = await fetch("https://api.cerebras.ai/v1/chat/completions", {
149method: "POST",
150headers: {
151"Content-Type": "application/json",
152"Authorization": `Bearer ${apiKey}`,
153},
154body: JSON.stringify({
189});
190} catch (error) {
191console.error("Error calling Cerebras API:", error);
192return new Response(JSON.stringify({ error: "Failed to fetch" }), {
193status: 500,
1/**
2* This code creates a geocoder widget similar to the Google Maps API search widget.
3* It uses React for the frontend, the Cerebras API for LLM-based geocoding,
4* and Leaflet for displaying the map.
5*/
124const { query } = await request.json();
125126const prompt = `You are a geocoding API. Return up to 5 possible matches.
127Respond with only the completions, separated by newlines.`;
128129try {
130const response = await fetch("https://api.cerebras.ai/v1/chat/completions", {
131method: "POST",
132headers: {
133"Content-Type": "application/json",
134"Authorization": `Bearer ${Deno.env.get("CEREBRAS_API_KEY")}`,
135},
136body: JSON.stringify({
146147if (!response.ok) {
148throw new Error("Failed to fetch from Cerebras API");
149}
150157});
158} catch (error) {
159console.error("Error calling Cerebras API:", error);
160return new Response(JSON.stringify({ error: "Failed to fetch suggestions" }), {
161status: 500,
oss_pledgemain.tsx1 match
2"name": "Val Town",
3"urlSquareLogoWithBackground": "https://avatars.githubusercontent.com/u/114268765?s=200&v=4",
4"description": "Val Town is a website to build apps, APIs, and scheduled functions.",
5"urlLearnMore": "https://blog.val.town/blog/oss",
6"annualReports": [
lootGenAPIREADME.md2 matches
1# Loot Generator API
23## How It Works
5### Components
67The Loot Generator API creates random loot items by combining:
89- 30 adjectives
dataUriGenAppmain.tsx1 match
6* - Copy button to easily copy the generated data URI
7*
8* We'll use the FileReader API for file handling and data URI generation.
9* The application will be built using HTML, CSS, and JavaScript, served by a Hono app.
10*/
dailyDadJokeREADME.md2 matches
113. 🤣🤣🤣🤣
1213## API
1415This val uses the [icanhazdadjoke API](https://icanhazdadjoke.com/api). You can find [more docs here](https://github.com/15Dkatz/official_joke_api), such as how to [filter by type](https://github.com/15Dkatz/official_joke_api?tab=readme-ov-file#grab-jokes-by-type).
dailyDadJokemain.tsx1 match
34export async function dailyDadJoke() {
5let { setup, punchline } = await fetchJSON("https://official-joke-api.appspot.com/random_joke");
6return email({
7text: punchline,