34
35 const dist_nowcast_warnings =
36 "https://reactjs.imd.gov.in/geoserver/imd/wms?service=WMS&request=GetMap&layers=imd%3ANowcast_StateDistrict_Merged&styles=&format=image%2Fsvg&transparent=true&version=1.1.1&width=256&height=256&srs=EPSG%3A4326&bbox="
37 + bbox;
38
39 // env=day:Day1_Color
40 const dist_warnings_today =
41 "https://reactjs.imd.gov.in/geoserver/imd/wms?service=WMS&request=GetMap&layers=imd%3AWarnings_StateDistrict_Merged&styles=&format=image%2Fsvg&transparent=true&version=1.1.1&env=day%3ADay1_Color&width=256&height=256&srs=EPSG%3A4326&bbox="
42 + bbox;
43
44 // env=day:Day2_Color
45 const dist_warnings_today_plus_1 =
46 "https://reactjs.imd.gov.in/geoserver/imd/wms?service=WMS&request=GetMap&layers=imd%3AWarnings_StateDistrict_Merged&styles=&format=image%2Fsvg&transparent=true&version=1.1.1&env=day%3ADay2_Color&width=256&height=256&srs=EPSG%3A4326&bbox="
47 + bbox;
48
49 // env=day:Day3_Color
50 const dist_warnings_today_plus_2 =
51 "https://reactjs.imd.gov.in/geoserver/imd/wms?service=WMS&request=GetMap&layers=imd%3AWarnings_StateDistrict_Merged&styles=&format=image%2Fsvg&transparent=true&version=1.1.1&env=day%3ADay3_Color&width=256&height=256&srs=EPSG%3A4326&bbox="
52 + bbox;
53
54 // env=day:Day4_Color
55 const dist_warnings_today_plus_3 =
56 "https://reactjs.imd.gov.in/geoserver/imd/wms?service=WMS&request=GetMap&layers=imd%3AWarnings_StateDistrict_Merged&styles=&format=image%2Fsvg&transparent=true&version=1.1.1&env=day%3ADay4_Color&width=256&height=256&srs=EPSG%3A4326&bbox="
57 + bbox;
58
59 // env=day:Day5_Color
60 const dist_warnings_today_plus_4 =
61 "https://reactjs.imd.gov.in/geoserver/imd/wms?service=WMS&request=GetMap&layers=imd%3AWarnings_StateDistrict_Merged&styles=&format=image%2Fsvg&transparent=true&version=1.1.1&env=day%3ADay5_Color&width=256&height=256&srs=EPSG%3A4326&bbox="
62 + bbox;
63 /*
4
5<div align="center">
6<img src="https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/67a1d35e-c37c-41a4-0e5a-03a9ba585d00/public" width="700px"/>
7</div>
218 functions where possible. Unless specified, don't add error handling,
219 make sure that errors bubble up to the caller.
220 Avoid external images or base64 images, use emojis, unicode symtols, or icon fonts/libraries instead, unless that's
221 not practical for the user's request (e.g. if they ask for a particular animated gif).
222 If the user asks for something that requires persistence, use the Val Town Blob storage API, unless
280functions where possible. Unless specified, don't add error handling,
281make sure that errors bubble up to the caller.
282Avoid external images or base64 images, use emojis, unicode symtols, or icon fonts/libraries instead, unless that's
283not practical for the user's request (e.g. if they ask for a particular animated gif).
284If the user asks for something that requires persistence, use the Val Town Blob storage API, unless
315 ---
316
317 Val Town comes with blob storage built-in. It allows for storing any data: text, JSON, images. You can access it via [\`std/blob\`](https://www.val.town/v/std/blob).
318
319 Blob storage is scoped globally to your account. If you set a blob in one val, you can retrieve it by the same key in another val. It's backed by Cloudflare R2.
29 "User-Agent":
30 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36",
31 "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8",
32 "Accept-Language": "en-US,en;q=0.5",
33 "Sec-Fetch-Site": "cross-site",
3Protect your vals behind a password. Use session cookies to persist authentication.
4
5
6
7## Demo
31 "highlights": [
32 "Built an event management platform with secure authentication and full CRUD capabilities, streamlining client operations.",
33 "Crafted a website for a food truck that captures their unique branding and playful image. The site features a fun, user-centric interface that facilitates online inquiries and enhances user engagement.",
34 "Designed and developed a responsive, accessibility-focused website for a law firm, improving client accessibility and increasing inquiries by 20%."
35 ]
51 "highlights": [
52 "Enhanced scene consistency with seed settings and introduced controls for motion, quality, and frame rate adjustments.",
53 "Integrated GPT-3.5 for prompt enhancement, significantly improving image and video quality.",
54 "Overcame the challenge of running FFmpeg client-side in Next.js, enabling real-time video processing in the browser."
55 ],
21 const response = await fetch(`/generate?prompt=${encodeURIComponent(prompt)}`);
22 if (!response.ok) {
23 throw new Error(`Failed to generate image: ${response.statusText}`);
24 }
25 const data = await response.json();
26 setFaviconUrl(data.imageUrl);
27 } catch (err) {
28 setError(err.message);
74}
75
76async function generateImage(prompt: string) {
77 const FAL_KEY = Deno.env.get("FAL_KEY");
78 if (!FAL_KEY) {
88 body: JSON.stringify({
89 prompt: prompt,
90 image_size: "square",
91 num_inference_steps: 2,
92 guidance_scale: 1,
93 num_images: 1,
94 }),
95 });
98 const errorText = await response.text();
99 console.error("fal.ai API error:", response.status, response.statusText, errorText);
100 throw new Error(`Failed to generate image: ${response.status} ${response.statusText}`);
101 }
102
104 console.log("API response:", data);
105
106 if (!data.images || data.images.length === 0 || !data.images[0].url) {
107 console.error("Unexpected API response format:", data);
108 throw new Error("Unexpected API response format");
109 }
110
111 return data.images[0].url;
112}
113
126
127 try {
128 const imageUrl = await generateImage(prompt);
129 console.log("Generated image URL:", imageUrl);
130 return new Response(JSON.stringify({ imageUrl }), {
131 headers: { "Content-Type": "application/json" },
132 });
121 "div",
122 { key: index, className: "border-b border-gray-200 pb-4 last:border-b-0 flex" },
123 result.image && React.createElement(
124 "div",
125 { className: "mr-4 flex-shrink-0" },
126 React.createElement("img", {
127 src: result.image,
128 alt: result.label || "Entity image",
129 className: "w-32 h-32 object-cover rounded",
130 })
233 score,
234 explanation,
235 image: result.thumbnail ? result.thumbnail[0] : null
236 };
237 }).sort((a, b) => b.score - a.score);
1An API and basic interface for entity searching from DBPedia, enhanced with images
1// This tool uses the DBpedia Lookup API and SPARQL endpoint to find entities and their details, including images.
2// It provides a web interface and a JSON API endpoint for entity search, including hero images.
3
4// Helper function to strip HTML tags and decode HTML entities
73 "div",
74 { key: index, className: "border-b border-gray-200 pb-4 last:border-b-0 flex" },
75 result.image && React.createElement(
76 "div",
77 { className: "mr-4 flex-shrink-0" },
78 React.createElement("img", {
79 src: result.image,
80 alt: result.label,
81 className: "w-32 h-32 object-cover rounded"
134 const uri = doc.resource[0];
135 const sparqlQuery = `
136 SELECT ?abstract ?image
137 WHERE {
138 <${uri}> dbo:abstract ?abstract .
139 OPTIONAL { <${uri}> dbo:thumbnail ?image }
140 FILTER (lang(?abstract) = "en")
141 }
154 label: sanitizeHtml(doc.label[0]),
155 description: bindings?.abstract?.value ? sanitizeHtml(bindings.abstract.value) : "No description available",
156 image: bindings?.image?.value || null,
157 };
158 }));