310 <head>
311 <title>Map of Italy</title>
312 <link href="https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;700&family=Lora&display=swap" rel="stylesheet">
313 <meta name="viewport" content="width=device-width, initial-scale=1">
314 <style>${css}</style>
187
188 try {
189 const response = await fetch("/api/combine", {
190 method: "POST",
191 headers: {
286 const key = "infiniteUICombinations_3";
287
288 if (url.pathname === "/api/combinations") {
289 const { blob } = await import("https://esm.town/v/std/blob");
290 const storedCombinations = await blob.getJSON(key) || [];
294 }
295
296 if (url.pathname === "/api/combine" && request.method === "POST") {
297 const { item1, item2, model } = await request.json();
298 console.log("Server: Combining elements", item1, item2);
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
79 };
80
81 const API_CONFIG = {
82 url: "https://willthereader-openaidefiner.web.val.run",
83 method: "POST",
203 };
204
205 async function processApiResponse(response) {
206 const reader = response.body.getReader();
207
235 try {
236 const originalSelection = isFollowUp ? popup.dataset.originalSelection : selectedText;
237 const response = await makeApiRequest(selectedText, isFollowUp ? originalSelection : null);
238 await processApiResponse(response);
239 if (isFollowUp) {
240 store.dispatch({
406 }
407
408 async function makeApiRequest(text, originalSelection = null) {
409 console.log(`makeApiRequest called with text: "${text}", originalSelection: "${originalSelection}"`);
410 try {
411 const extractedContext = extractSettingTags();
418 console.log(`Request body: ${body}`);
419
420 const response = await fetch(API_CONFIG.url, {
421 ...API_CONFIG,
422 body: body,
423 });
424
425 console.log(`API response status: ${response.status}`);
426
427 if (!response.ok) {
431 return response;
432 } catch (error) {
433 console.error(`Error in makeApiRequest: ${error.message}`);
434 throw new Error(`Failed to fetch definition from the server. Please try again. Error: ${error.message}`);
435 }
1Docs: https://docs.lumalabs.ai/docs/api#how-to-get-a-callback-when-generation-has-an-update
2
3you can now pass callback_url in the body of api / create function on python/js sdks.
4available on version 1.1.0
5
14 const fetchScores = async () => {
15 try {
16 const response = await fetch('/api/scores');
17 if (!response.ok) {
18 throw new Error('Failed to fetch scores');
47 <p>
48 <small>
49 Data source: <a href="http://statsapi.mlb.com">MLB Stats API</a> |{" "}
50 <a href={import.meta.url.replace("esm.town", "val.town")}>View source</a>
51 </small>
66 const url = new URL(request.url);
67
68 if (url.pathname === '/api/scores') {
69 try {
70 const mlbResponse = await fetch('https://statsapi.mlb.com/api/v1/schedule/games/?sportId=1');
71 const mlbData = await mlbResponse.json();
72
93 <div>
94 <h2>Urgent Support for Kenyan Youth</h2>
95 <p>We're here to help you. Please start chatting with our AI therapist below.</p>
96 <p>If you're in immediate danger, please contact these helplines:</p>
97 <ul>
121 <div>
122 <h2>{stage === "therapy" ? "AI Therapy Session" : "Follow-up Support"}</h2>
123 <p>Chat with your AI therapist below:</p>
124 </div>
125 );
129 return (
130 <div className="app">
131 <h1>AI Mental Health Therapist - {country}</h1>
132 {renderContent()}
133 <div className="chat">
221 let systemMessage = "";
222 if (stage === "urgent" || user.urgent) {
223 systemMessage = "You are an AI mental health therapist specializing in helping depressed Kenyan youth. Provide empathetic, culturally sensitive support, and focus on immediate coping strategies. If the user expresses suicidal thoughts, strongly encourage them to contact the provided helplines.";
224 } else if (stage === "questionnaire") {
225 systemMessage = "You are an AI assistant conducting a neuroscience-based questionnaire for a Kenyan youth. Guide the user through the questions and provide a summary at the end, with a focus on identifying signs of depression.";
226 } else if (stage === "therapy") {
227 systemMessage = "You are an AI mental health therapist specializing in treating depression in Kenyan youth. Provide empathetic and culturally sensitive support, focusing on cognitive-behavioral techniques and mindfulness practices.";
228 } else if (stage === "followup") {
229 systemMessage = "You are an AI mental health therapist providing follow-up support for a Kenyan youth who may be experiencing depression. Check on their progress, offer additional guidance, and encourage the development of healthy coping mechanisms.";
230 }
231
262 <html>
263 <head>
264 <title>AI Mental Health Therapist</title>
265 <style>${css}</style>
266 </head>
3This val creates an email address that posts forwarded emails to a [Campsite](https://campsite.com) channel.
4
5It uses GPT-4 to extract a readable version of the forwarded email from the raw body. If you don't want to use GPT-4, omit the `OPENAI_API_KEY` and the raw body will be included in the post. Other providers are available via [Vercel's AI SDK](https://sdk.vercel.ai/docs/introduction#model-providers).
6
7For help with creating integrations, check out the [Campsite API docs](https://app.campsite.com/campsite/p/notes/campsite-api-docs-l07d7gm5n5rm). You'll need to create an integration and get an API key.
13## Authentication
14
15Login to your SQLite Explorer with [password authentication](https://www.val.town/v/pomdtr/password_auth) with your [Val Town API Token](https://www.val.town/settings/api) as the password.
16
17## Todos / Plans
27 <head>
28 <title>SQLite Explorer</title>
29 <link rel="preconnect" href="https://fonts.googleapis.com" />
30
31 <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
32 <link
33 href="https://fonts.googleapis.com/css2?family=Fira+Code:wght@300..700&family=Source+Sans+3:ital,wght@0,200..900;1,200..900&display=swap"
34 rel="stylesheet"
35 />