this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

sigh

alice 3792b9a2 e01984db

+47 -36
+47 -36
src/label.ts
··· 1 1 import { AppBskyActorDefs, ComAtprotoLabelDefs } from '@atproto/api'; 2 - import { DELETE } from './constants.js'; 2 + import { DELETE, HOUSES } from './constants.js'; 3 3 import { BSKY_IDENTIFIER, BSKY_PASSWORD, DID, PORT, SIGNING_KEY } from './config.js'; 4 4 import { LabelerServer } from '@skyware/labeler'; 5 5 import { generateText, tool } from 'ai'; ··· 95 95 96 96 const avatar = await prepareAvatar(data); 97 97 const prompt = createPrompt(data); 98 + const coinFlip = Math.floor(Math.random() * 2); 98 99 99 - await generateText({ 100 - model: openai('gpt-4o-mini'), 101 - messages: [ 102 - { 103 - role: 'user', 104 - content: [ 105 - { type: 'text', text: prompt }, 106 - { 107 - type: 'image', 108 - image: avatar.toBuffer(), 109 - experimental_providerMetadata: { openai: { imageDetail: 'low' } }, 100 + if (coinFlip === 0) { 101 + const label = HOUSES[Math.floor(Math.random() * HOUSES.length)]; 102 + labelerServer.createLabel({ 103 + uri: did, 104 + val: label, 105 + }); 106 + console.log(`Labeled ${did} with ${label}`); 107 + return; 108 + } else { 109 + await generateText({ 110 + model: openai('gpt-4o-mini'), 111 + messages: [ 112 + { 113 + role: 'user', 114 + content: [ 115 + { type: 'text', text: prompt }, 116 + { 117 + type: 'image', 118 + image: avatar.toBuffer(), 119 + experimental_providerMetadata: { openai: { imageDetail: 'low' } }, 120 + }, 121 + ], 122 + }, 123 + ], 124 + toolChoice: 'required', 125 + tools: { 126 + decide: tool({ 127 + parameters: z.object({ 128 + answer: z.union([ 129 + z.literal('gryffindor'), 130 + z.literal('hufflepuff'), 131 + z.literal('ravenclaw'), 132 + z.literal('slytherin'), 133 + ]), 134 + }), 135 + execute: async ({ answer }) => { 136 + await labelerServer.createLabel({ uri: did, val: answer }); 137 + console.log(`Labeled ${did} with ${answer}`); 110 138 }, 111 - ], 112 - }, 113 - ], 114 - toolChoice: 'required', 115 - tools: { 116 - decide: tool({ 117 - parameters: z.object({ 118 - answer: z.union([ 119 - z.literal('gryffindor'), 120 - z.literal('hufflepuff'), 121 - z.literal('ravenclaw'), 122 - z.literal('slytherin'), 123 - ]), 124 139 }), 125 - execute: async ({ answer }) => { 126 - await labelerServer.createLabel({ uri: did, val: answer }); 127 - console.log(`Labeled ${did} with ${answer}`); 128 - }, 129 - }), 130 - }, 131 - }); 140 + }, 141 + }); 142 + } 132 143 } catch (err) { 133 144 console.error(`Error adding label for ${did}:`, err); 134 145 } ··· 158 169 return ` 159 170 You're the Sorting Hat from Harry Potter. Which house does the user with the profile data at the end of this message belong to? 160 171 172 + 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. 161 173 Always return an answer — house name only, all lowercase. 162 - 163 - 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. 164 - 165 - 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. 174 + The user's data may be in any language. Focus on the meaning, not just the surface content. 175 + Consider traits for all houses, not just intellect. 176 + 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. 166 177 167 178 The user's data is as follows: 168 179