12 try {
13 const response = await fetch(
14 `https://api.open-meteo.com/v1/forecast?latitude=${location.latitude}&longitude=${location.longitude}¤t_weather=true&hourly=temperature_2m,relativehumidity_2m,windspeed_10m`,
15 );
16
3
4const AUTH_TOKEN = process.env.RAINDROP_TEST_TOKEN;
5const API_BASE_URL = "https://api.raindrop.io/rest/v1";
6const HEADERS = {
7 Authorization: `Bearer ${AUTH_TOKEN}`,
11 try {
12 const csvExportResponse = await fetch(
13 `${API_BASE_URL}/raindrops/0/export.csv`,
14 {
15 headers: HEADERS,
31 try {
32 const response = await fetch(
33 `https://api.open-meteo.com/v1/forecast?latitude=${location.latitude}&longitude=${location.longitude}¤t_weather=true&hourly=temperature_2m,relativehumidity_2m,windspeed_10m&daily=temperature_2m_max,temperature_2m_min,sunrise,sunset&timezone=auto`
34 );
35 const data = await response.json();
46 try {
47 const geocodeResponse = await fetch(
48 `https://geocoding-api.open-meteo.com/v1/search?name=${encodeURIComponent(cityName)}&count=1&language=en&format=json`
49 );
50 const geocodeData = await geocodeResponse.json();
8
91. Click `Fork`
102. Change `location` (Line 4) to describe your location. It accepts fairly flexible English descriptions which it turns into locations via [nominatim's geocoder API](https://www.val.town/v/stevekrouse/nominatimSearch).
113. Click `Run`
12
346 <head>
347 <title>Safe & Sound</title>
348 <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap" rel="stylesheet">
349 <meta name="viewport" content="width=device-width, initial-scale=1">
350 <style>
141. Copy this Val and save it as an Email Val (choose Val type in top-right corner of editor)
15
162. Add your OpenAI API key to line 8 (or use an environment variable: https://docs.val.town/reference/environment-variables/)
17
183. Copy the email address of the Val (click 3 dots in top-right > Copy > Copy email address)
5// main controller function
6export async function emailValHandler(receivedEmail) {
7 const openaiUrl = "https://api.openai.com/v1/chat/completions";
8 const apiKey = Deno.env.get("OPENAI_KEY"); // replace this entire line with your OpenAI API key as a string, e.g., "sk-123..." or use environment variable: https://docs.val.town/reference/environment-variables/
9 const model = "gpt-4o-mini";
10
11 if (!apiKey) {
12 throw new Error(
13 "OPENAI_KEY environment variable is not set. Please set it or replace this line with your API key.",
14 );
15 }
36
37 // step 4: send prompt to openai
38 const openaiResponse = await sendRequestToOpenAI(prompt, openaiUrl, apiKey, model);
39
40 // log the openai response
122
123// helper function to send a request to openai
124async function sendRequestToOpenAI(prompt, openaiUrl, apiKey, model) {
125 try {
126 // prepare the openai messages payload
148 headers: {
149 "Content-Type": "application/json",
150 Authorization: `Bearer ${apiKey}`,
151 },
152 });
212 } catch (error) {
213 Toastify({
214 text: "We may have hit our Cerebras Usage limits. Try again later or fork this and use your own API key.",
215 position: "center",
216 duration: 3000,
1024 };
1025 } else {
1026 const client = new Cerebras({ apiKey: Deno.env.get("CEREBRAS_API_KEY") });
1027 const completion = await client.chat.completions.create({
1028 messages: [
1149 <meta name="viewport" content="width=device-width, initial-scale=1.0">
1150 <title>CerebrasCoder</title>
1151 <link rel="preconnect" href="https://fonts.googleapis.com" />
1152 <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
1153 <link
1154 href="https://fonts.googleapis.com/css2?family=DM+Mono:ital,wght@0,300;0,400;0,500;1,300;1,400;1,500&family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&display=swap"
1155 rel="stylesheet"
1156 />
1165 <meta property="og:description" content="Turn your ideas into fully functional apps in less than a second – powered by Llama3.3-70b on Cerebras's super-fast wafer chips. Code is 100% open-source, hosted on Val Town."">
1166 <meta property="og:type" content="website">
1167 <meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">
1168
1169
483 <title>QR Scan Pro</title>
484 <meta name="viewport" content="width=device-width, initial-scale=1">
485 <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600&display=swap" rel="stylesheet">
486 <script src="https://esm.town/v/std/catch"></script>
487 <style>
460 <title>NoteSphere</title>
461 <meta name="viewport" content="width=device-width, initial-scale=1">
462 <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600&display=swap" rel="stylesheet">
463 <script src="https://esm.town/v/std/catch"></script>
464 <style>