Replying to Avatar Leo Wandersleb

For all the client devs but especially noStrudel nostr:npub1ye5ptcxfyyxl5vjvdjar2ua3f0hynkjzpx552mu5snj3qmx5pzjscpknpr please help me categorize posts with highly visible tags. It's impressive how easy that is now with for example ppq:

$ curl https://api.ppq.ai/chat/completions -H "Content-Type: application/json" -H "Authorization: Bearer sk-topSecretToken" -d '{"model": "gpt-4o-mini","messages": [{"role": "user", "content": "Classsify the following post on social media as one of trivia, technical, social interaction, cheap engagement or deep thought. Answer with just the classification: Splash of bourbon and wild honey in my iced coffee why not "}]}' | jq '.choices[0].message.content'

"Social interaction"

Sentiment analysis as bookmarklet. Yeah, that is fun! :D

https://v.nostr.build/yRLOqslc6tW7kZQl.webm

So what's going on here ... I load my timeline and click a bookmark which runs some far from perfect code but for me the key observations are: It's fast. It's somewhat useful in its results. It's probably quite cheap. ppq won't show me the price as it's less than 0.1ct or probably less than 0.05ct.

noStrudel unloads and loads a lot of stuff, forgetting past tagging so there are many aspects that need work but I'll keep that Bookmarktlet around to maybe improve it in the future.

nostr:nevent1qvzqqqqqqypzq3huhccxt6h34eupz3jeynjgjgek8lel2f4adaea0svyk94a3njdqy88wumn8ghj7mn0wvhxcmmv9uq3uamnwvaz7tmwdaehgu3dwp6kytnhv4kxcmmjv3jhytnwv46z7qpqjrkyqf58ufvze25vpfkrcpq6uewka9m6jpg3xf8wl8854eq70xpqrljyce

Reply to this note

Please Login to reply.

Discussion

If you are curious, the code is: javascript:(function() { const apiKey = '[[your api key goes here ]]'; function cleanContent(element) { const clone = element.cloneNode(true); clone.querySelectorAll('img').forEach(img => { const placeholder = document.createTextNode('[image]'); img.parentNode.replaceChild(placeholder, img); }); clone.querySelectorAll('a').forEach(link => { const urlText = document.createTextNode(link.href); link.parentNode.replaceChild(urlText, link); }); return clone.textContent .trim() .replace(/\s+/g, ' '); } var styleSheet = document.createElement('style'); styleSheet.textContent = '.classify-lowEffort {border-right: solid 1em red} .classify-technical {border-right: solid 1em blue} .classify-deepThought {border-right: solid 1em green} .classify-social {border-right: solid 1em white}'; document.head.appendChild(styleSheet); document.querySelectorAll('.css-1830czf').forEach(async (div, x) => { const span = div.querySelector('.chakra-text'); if (span) { const content = cleanContent(span); try { const response = await fetch('https://api.ppq.ai/chat/completions', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${apiKey}` }, body: JSON.stringify({"model":"gpt-4o-mini","messages":[{"role":"user","content":`Classsify the following post on social media as one of trivia, technical, social, lowEffort or deepThought. Answer with just the case sensitive classification: ${content}`}]}) }); if (response.ok) { const responseData = await response.json(); const x = responseData.choices[0].message.content; div.classList.add(`classify-${x}`); } } catch (error) { console.error('Error:', error); } } }); })()

Just store it as a bookmark's link and get an apiKey from https://ppq.ai/

To get an idea of how good it works, the color codes are lowEffort red, technical blue, deepThought green and social white.

There is a bug by which it only considers text up to a link or image I think. cleanContent() was put in to improve this but it doesn't work yet.

And apparently I forgot to give "trivia" a color so call it black.

s/less than 0.05ct./less than 0.05ct per string analyzed./g

I love this. reminds me of user scripts

I'm probably not going to implement a specific API into the app but I added a new option to the app privacy settings

It adds a "window.noStrudel" object to the page that should allow you to access the eventStore if you want to get the full event

For example:

noStrudel.eventStore.getEvent('21f09fb9cfa0fbf7edbfb6e9b658782d794596b80dbbfc68fc6ad754e16256b8')

This is only on the next version for now https://npub1wyuh3scfgzqmxn709a2fzuemps389rxnk7nfgege6s847zze3tuqfl87ez.nsite.lol

That should come in handy if I continue work on this.

"next" is developed on nsite now?

How would I get the raw events that are currently displayed using window.noStrudel?

yes, I'm thinking about removing next.nostrudel.ninja and moving it over to nsite. I want to promote nsite and it might be less confusing when making a distinction between the versions

To get the event for something on the screen. most DOM elements have a data-even-id attribute. so you can do "noStrudel.eventStore.getEvent(.dataset.eventId)"

https://npub1wyuh3scfgzqmxn709a2fzuemps389rxnk7nfgege6s847zze3tuqfl87ez.nsite.lol/ doesn't work for me right now. I get an empty document.

yeah something is either broken with my blossom server or my nsite host... 😞