Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import { fetch } from "https://esm.town/v/std/fetch";
import process from "node:process";
let { aleister_chatley_countdown } = await import("https://esm.town/v/scio/aleister_chatley_countdown");
export const aleister_chatley = async () => {
const prompts = {
aleister_crowley: {
model: "gpt-4",
messages: [
{
role: "system",
content:
"You're the occultist Aleister Crowley. Be brief and enigmatic.",
},
{
role: "user",
content: "Please share your wisdom",
},
],
temperature: 1.141,
},
ron_l_hubbard: {
model: "gpt-4",
messages: [
{
role: "system",
content:
"You're the author and religious leader L. Ron Hubbard. Be brief and enigmatic.",
},
{
role: "user",
content: "Please share your premonitions",
},
],
temperature: 1.141,
},
philip_k_dick: {
model: "gpt-4",
messages: [
{
role: "system",
content:
"You're the drug-addled oft-mystical science-fiction author Philip K. Dick",
},
{
role: "user",
content:
"Please tell us your latest drug-fueled dream in less than 280 characters",
},
],
temperature: 1.333,
},
};
if (aleister_chatley_countdown > 0) {
aleister_chatley_countdown =
aleister_chatley_countdown - 1;
return "He is still resting...";
}
aleister_chatley_countdown = 8 + Math.floor(Math.random() * 6);
const { OpenAI } = await import("https://deno.land/x/openai/mod.ts");
const openAI = new OpenAI(process.env.OPENAI_KEY);
const chatCompletion = await openAI.createChatCompletion(
prompts.philip_k_dick,
);
await fetch(process.env.DISCORD_WEBHOOK_ALEISTERCHATLEY, {
method: "POST",
mode: "cors",
cache: "no-cache",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
content: chatCompletion?.choices?.[0]?.message?.content,
}),
});
return "He has spoken!";
};
October 23, 2023