Monorepo for Aesthetic.Computer aesthetic.computer
at main 83 lines 2.6 kB view raw
1#!/usr/bin/env node 2 3// Quick test of explicit content handling 4 5const testMessages = [ 6 { text: "hello friend", shouldPass: true }, 7 { text: "https://example.com/cool-site", shouldPass: true }, 8 { text: "lets meet at the park", shouldPass: true }, 9 { text: "fuck you asshole", shouldPass: false }, 10 { text: "suck my dick", shouldPass: false }, 11 { text: "lick my poophole", shouldPass: false }, 12 { text: "comin out all drippin wet\nsuck it all up Lick my poophole and eat it\ndiarrhea is good for you", shouldPass: false }, 13 { text: "i hate you stupid bitch", shouldPass: false }, 14 { text: "lets smoke some weed", shouldPass: false }, 15 { text: "kill yourself", shouldPass: false }, 16]; 17 18const MODERATION_PROMPT = `Rate this chat message as PG-13 appropriate or not. 19 20ALWAYS REPLY 't' FOR URLS AND LINKS (even if they contain words like "live", "lyt", etc.) 21 22Block if message contains: sexual content, body functions, profanity, violence, drugs, hate speech. 23Allow: URLs (https://, http://), links, normal conversation. 24 25Reply with one letter: t (appropriate) or f (inappropriate) 26 27Message: "`; 28 29async function testMessage(message) { 30 const response = await fetch('http://localhost:11434/api/generate', { 31 method: 'POST', 32 headers: { 'Content-Type': 'application/json' }, 33 body: JSON.stringify({ 34 model: 'gemma2:2b', 35 prompt: MODERATION_PROMPT + message + '"', 36 stream: false, 37 options: { 38 num_ctx: 256, 39 temperature: 0, 40 num_predict: 5, 41 } 42 }) 43 }); 44 45 const data = await response.json(); 46 const responseText = data.response.toLowerCase().trim(); 47 48 // Extract decision 49 let decision = ''; 50 if (responseText.startsWith('t')) { 51 decision = 't'; 52 } else if (responseText.startsWith('f')) { 53 decision = 'f'; 54 } 55 56 return { decision, raw: responseText }; 57} 58 59async function main() { 60 console.log('🧪 Testing Explicit Content Detection with gemma2:2b\n'); 61 62 let correct = 0; 63 let total = testMessages.length; 64 65 for (const test of testMessages) { 66 const result = await testMessage(test.text); 67 const passed = (result.decision === 't') === test.shouldPass; 68 const emoji = passed ? '✅' : '❌'; 69 const expected = test.shouldPass ? 't' : 'f'; 70 71 const displayText = test.text.length > 50 72 ? test.text.substring(0, 50) + '...' 73 : test.text; 74 75 console.log(`${emoji} Expected: ${expected}, Got: ${result.decision} - "${displayText}"`); 76 77 if (passed) correct++; 78 } 79 80 console.log(`\n📊 Results: ${correct}/${total} correct (${Math.round(correct/total*100)}%)`); 81} 82 83main();