···11import { AppBskyActorDefs, ComAtprotoLabelDefs } from '@atproto/api';
22-import { DELETE } from './constants.js';
22+import { DELETE, HOUSES } from './constants.js';
33import { BSKY_IDENTIFIER, BSKY_PASSWORD, DID, PORT, SIGNING_KEY } from './config.js';
44import { LabelerServer } from '@skyware/labeler';
55import { generateText, tool } from 'ai';
···95959696 const avatar = await prepareAvatar(data);
9797 const prompt = createPrompt(data);
9898+ const coinFlip = Math.floor(Math.random() * 2);
98999999- await generateText({
100100- model: openai('gpt-4o-mini'),
101101- messages: [
102102- {
103103- role: 'user',
104104- content: [
105105- { type: 'text', text: prompt },
106106- {
107107- type: 'image',
108108- image: avatar.toBuffer(),
109109- experimental_providerMetadata: { openai: { imageDetail: 'low' } },
100100+ if (coinFlip === 0) {
101101+ const label = HOUSES[Math.floor(Math.random() * HOUSES.length)];
102102+ labelerServer.createLabel({
103103+ uri: did,
104104+ val: label,
105105+ });
106106+ console.log(`Labeled ${did} with ${label}`);
107107+ return;
108108+ } else {
109109+ await generateText({
110110+ model: openai('gpt-4o-mini'),
111111+ messages: [
112112+ {
113113+ role: 'user',
114114+ content: [
115115+ { type: 'text', text: prompt },
116116+ {
117117+ type: 'image',
118118+ image: avatar.toBuffer(),
119119+ experimental_providerMetadata: { openai: { imageDetail: 'low' } },
120120+ },
121121+ ],
122122+ },
123123+ ],
124124+ toolChoice: 'required',
125125+ tools: {
126126+ decide: tool({
127127+ parameters: z.object({
128128+ answer: z.union([
129129+ z.literal('gryffindor'),
130130+ z.literal('hufflepuff'),
131131+ z.literal('ravenclaw'),
132132+ z.literal('slytherin'),
133133+ ]),
134134+ }),
135135+ execute: async ({ answer }) => {
136136+ await labelerServer.createLabel({ uri: did, val: answer });
137137+ console.log(`Labeled ${did} with ${answer}`);
110138 },
111111- ],
112112- },
113113- ],
114114- toolChoice: 'required',
115115- tools: {
116116- decide: tool({
117117- parameters: z.object({
118118- answer: z.union([
119119- z.literal('gryffindor'),
120120- z.literal('hufflepuff'),
121121- z.literal('ravenclaw'),
122122- z.literal('slytherin'),
123123- ]),
124139 }),
125125- execute: async ({ answer }) => {
126126- await labelerServer.createLabel({ uri: did, val: answer });
127127- console.log(`Labeled ${did} with ${answer}`);
128128- },
129129- }),
130130- },
131131- });
140140+ },
141141+ });
142142+ }
132143 } catch (err) {
133144 console.error(`Error adding label for ${did}:`, err);
134145 }
···158169 return `
159170You're the Sorting Hat from Harry Potter. Which house does the user with the profile data at the end of this message belong to?
160171172172+Focus on the available information. If the avatar is not available, a 1x1 pixel white image is provided instead as a placeholder. Disregard the placeholder and focus on the user's data.
161173Always return an answer — house name only, all lowercase.
162162-163163-First, flip an imaginary coin and if it's heads, return a random house name, if it's tails, proceed with the logic described below.
164164-165165-Focus on the available information. If the avatar is not available, a 1x1 pixel white image is provided instead. Disregard it and focus on the rest of their data. The user's data may be in any language. Focus on the meaning, not just the surface content Consider traits for all houses, not just intellect.
174174+The user's data may be in any language. Focus on the meaning, not just the surface content.
175175+Consider traits for all houses, not just intellect.
176176+You're mischievous and enjoy sorting based on whims, not always strictly following the user's traits; imagine as if you're a person who likes to play tricks on people.
166177167178The user's data is as follows:
168179