7import { oneDark } from "https://esm.sh/react-syntax-highlighter@15.5.0/dist/esm/styles/prism";
8
9const CHAT_URL = "/api/chat";
10const STATUS_URL = "/api/status";
11
12const MODELS = [
368
369export default async function server(request: Request): Promise<Response> {
370 // Proxy for DuckDuckGo API calls
371 if (request.method === 'OPTIONS') {
372 return new Response(null, {
379 }
380
381 if (request.url.includes('/api/status')) {
382 try {
383 const statusResponse = await fetch('https://duckduckgo.com/duckchat/v1/status', {
410 }
411
412 if (request.url.includes('/api/chat')) {
413 try {
414 const requestBody = await request.json();
455 <title>DuckDuckGo Chat</title>
456 <meta name="viewport" content="width=device-width, initial-scale=1">
457 <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap" rel="stylesheet">
458 <script src="https://esm.town/v/std/catch"></script>
459 </head>
1Simple AI chat app with markdown reneder utilizing DuckDuckGo Chat API
3// ----- PSE
4
5export const OUTAGES_URL = "https://www.pse.com/api/sitecore/OutageMap/AnonymoussMapListView";
6
7export const PSE_OUTAGES_TABLE_NAME = `pse_outage_checks`;
9To use it on your own Val Town SQLite database, [fork it](https://www.val.town/v/stevekrouse/sqlite_admin/fork) to your account.
10
11It uses [basic authentication](https://www.val.town/v/pomdtr/basicAuth) with your [Val Town API Token](https://www.val.town/settings/api) as the password (leave the username field blank).
4
5This val gets Twitter data via [SocialData](https://socialdata.tools) via
6@stevekrouse/socialDataProxy. Val Town Pro users can call this API
7100 times per day, so be sure not to set this cron to run more than once every 15 min.
8If you want to use it more, get your own [SocialData](https://socialdata.tools)
9API token and pay for it directly.
10
11## 1. Query
13Change the `query` variable for what you want to get notified for.
14
15You can use [Twitter's search operators](https://developer.twitter.com/en/docs/twitter-api/v1/rules-and-filtering/search-operators) to customize your query, for some collection of keywords, filtering out others, and much more!
16
17## 2. Notification
4function fetchRandomJoke() {
5 const response = fetch(
6 "https://official-joke-api.appspot.com/random_joke",
7 );
8 return response;
4async function fetchRandomJoke() {
5 const response = await fetch(
6 "https://official-joke-api.appspot.com/random_joke",
7 );
8 return response.json();
102 <ol>
103 <li>Ensure your Killamix Mini is connected to your computer via USB.</li>
104 <li>Use a Web MIDI API compatible browser (Chrome, Edge, or Opera).</li>
105 <li>Click the "Connect MIDI" button in the app.</li>
106 <li>In the MIDI device selection popup, choose your Killamix Mini.</li>
13 // Los Angeles coordinates with Fahrenheit units
14 const response = await fetch(
15 "https://api.open-meteo.com/v1/forecast?latitude=34.0522&longitude=-118.2437¤t=temperature_2m,relative_humidity_2m,wind_speed_10m,weather_code&temperature_unit=fahrenheit&wind_speed_unit=mph&timezone=America%2FLos_Angeles"
16 );
17
13 try {
14 const response = await fetch(
15 `https://api.open-meteo.com/v1/forecast?latitude=${location.latitude}&longitude=${location.longitude}¤t_weather=true&hourly=temperature_2m,weathercode&daily=weathercode,temperature_2m_max,temperature_2m_min&timezone=auto`
16 );
17 const data = await response.json();
29 try {
30 const response = await fetch(
31 `https://geocoding-api.open-meteo.com/v1/search?name=${cityName}&count=1&language=en&format=json`
32 );
33 const locationData = await response.json();