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
78
79
import { fetch } from "https://esm.town/v/std/fetch";
import process from "node:process";
import { resume as resume2 } from "https://esm.town/v/ajax/resume";
export async function annoy() {
const resume = resume2;
// const boo = await import("https://esm.sh/@atproto/api");
const { default: BskyAgent } = await import("npm:@atproto/api");
console.log(BskyAgent);
const agent = new BskyAgent.BskyAgent({ service: "https://bsky.social" });
await agent.login({
identifier: process.env.BLUESKY_USERNAME!,
password: process.env.BLUESKY_PASSWORD!,
});
// const actor = await agent.getProfile();
// console.log({ actor });
// const followers = await agent.getFollowers();
// console.log(followers);
// const posts = await agent.getPosts({ uris: ["at://lordajax.bsky.social"] });
// console.log({ posts });
const timeline = await agent.getTimeline();
console.log({ timeline });
const mostRecentPost = timeline.data.feed[0];
console.log({ mostRecentPost });
const author = mostRecentPost.post.author.handle;
const recordText = mostRecentPost.post.record.text;
console.log({ author, recordText });
const prompt =
`Choose an esoteric word of the day. You will use this word in the following poem.
Write a poem about how all you want to do is drink and get high using the chosen word.
Make it funny and short. Talk about your friends Pam and Tom.
Make it sound like you are wise.
Be dark and moody.
Make sure your response is no longer than 270 characters.
Put the word first and definition and then the poem below.
The poem MUST contain the chosen word of the day.
You MUST include the definition of the word
Here is an example;
Bifurcate - divide into two branches or forks.
Bifurcate! My life is stale, my friends just wanna inebriate.
Tom wants a coke, Pam needs a beer, they laugh and joke as I just sneer.
Just leave me be, no need to beep, can't you see I just wanna sleep?
---
Copying the example above, find a new word and do as above.
`;
console.log({ prompt });
const response = await fetch("https://api.openai.com/v1/completions", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer " + process.env.OPENAI_API_KEY, // Replace with your OpenAI API Key
},
body: JSON.stringify({
"prompt": prompt,
"model": "text-davinci-003",
"temperature": 1,
"max_tokens": 256,
"top_p": 1,
"frequency_penalty": 0,
"presence_penalty": 0,
}),
});
if (!response.ok) {
console.log(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
console.log(data);
const message = data.choices[0].text.trim();
console.log({ message });
await agent.post({
text: message,
});
return "asd";
}
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!
v62
October 23, 2023