Readme
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { email } from "https://esm.town/v/std/email?v=11";
import { OpenAI } from "npm:openai";
let location = "brooklyn ny";
let lang = "en";
const weather = await fetch(
`https://wttr.in/${location}?lang=${lang}&format=j1`,
).then(r => r.json());
const openai = new OpenAI();
let chatCompletion = await openai.chat.completions.create({
messages: [{
role: "user",
content: `Based the weather data below,
give me suggestions on how warmly to dress,
ie pants or shorts, a light jacket or a warm jacket,
a scarf and gloves or not, if I should carry an umbrella, etc.
In your response, use temperature data from the weather data below
throughout the day to explain your reccomendation.
Be as concice as possible. Assume I'll wear the same thing the whole day.
Do not use a bulleted list. Use 2-3 sentences. Only use Fahrenheit`.replaceAll("\n", ""),
}, {
role: "user",
content: JSON.stringify(weather),
}],
model: "gpt-4-1106-preview",
max_tokens: 150,
});
const text = chatCompletion.choices[0].message.content;
console.log(text);
export async function weatherGPT() {
await email({ subject: "Weather Today", text });
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
v9
May 14, 2024