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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import serve, { events, forward, sleep } from "https://esm.town/v/jeffreyyoung/poe_bot?v=45";
export default serve({
async *handleMessage(req) {
const lastMessage = req.query.at(-1)?.content;
for await (
const event of forward({
accessKey: Deno.env.get("botToken1"),
query: req,
toBotName: "StableDiffusionXL",
})
) {
if (event.event !== "done") {
yield event;
}
}
yield formUI();
yield events.done();
},
settings: {
allow_attachments: true,
introduction_message: "hi",
server_bot_dependencies: {
"StableDiffusionXL": 1,
},
},
});
function formUI() {
return `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Image Generation Form</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 600px;
margin: 0 auto;
padding: 20px;
}
.form-container {
display: flex;
flex-direction: column;
gap: 10px;
}
input, select {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 16px;
}
button {
background-color: #4CAF50;
color: white;
padding: 10px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
}
button:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<div class="form-container">
<input id="description" type="text" placeholder="Image description">
<input id="exclude" type="text" placeholder="Things to exclude in the image">
<select id="aspect-ratio">
<option value="1:1">1:1</option>
<option value="7:4">7:4</option>
<option value="4:7">4:7</option>
<option value="9:7">9:7</option>
<option value="7:9">7:9</option>
<option value="19:13">19:13</option>
<option value="13:19">13:19</option>
<option value="12:5">12:5</option>
<option value="5:12">5:12</option>
</select>
<button onclick="submitForm()">Generate Image</button>
</div>
<script>
function submitForm() {
const description = document.getElementById('description').value;
const exclude = document.getElementById('exclude').value;
const aspect = document.getElementById('aspect-ratio').value;
const message = [description, "--no", exclude, "--aspect", aspect].join(" ");
window.Poe.sendMessage(message);
}
</script>
</body>
</html>
`;