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
import { chat } from "https://esm.town/v/stevekrouse/openai?v=19";
export async function getGPT4oEmoji(url) {
const response = await chat([
{
role: "system",
// Respond ONLY in a JSON array with values conforming to: {emoji: string}
content: `
You are a helpful assistant.
I will provide you with a photo, and I would like an emoji that best captures the essence of the photo.
Reply with 1 to 5 emojis that the image evokes. Prefer fewer emojis.
`,
},
// {
// role: "user",
// // content: "A chocolate donut with sprinkles",
// content: [{
// type: "image_url",
// image_url: {
// url: "https://brokenovenbaking.com/wp-content/uploads/2022/04/chocolate-donuts-with-sprinkles-11-1.jpg",
// },
// }],
// },
// {
// role: "assistant",
// content: `🍩`,
// },
{
role: "user",
content: [{
type: "image_url",
image_url: {
url,
},
}],
},
], {
model: "gpt-4o",
max_tokens: 100,
});
return response.content;
}
// console.log(
// await getGPT4oEmoji(
// // "https://images.squarespace-cdn.com/content/v1/62015f66f840ef671da14ae7/4161edfa-ebba-4c13-90a4-90383f26260e/Photographing-NYC-skyline.jpg",
// "https://i.imgur.com/FaNnVND.png",
// ),
// );
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!
May 18, 2024