fleet/website/scripts/test-ai-decision.js
Mike McNeil 94aa200424
More ai helpers (#29027)
I will upstream these ahead of next week into sails-hook-organics.
2025-05-12 17:01:43 -05:00

54 lines
1.1 KiB
JavaScript
Vendored

module.exports = {
friendlyName: 'Test ai decision',
description: '',
fn: async function () {
sails.log('Running custom shell script... (`sails run test-ai-decision`)');
let posts = [
{
id: 1,
author: 'mikermcneil',
tweet: 'I fed this one stray cat and now I have 20 stray cats coming to my house',
},
{
id: 2,
author: 'fancydoilies',
tweet: 'My cat is named Rory'
},
{
id: 3,
author: 'koo',
tweet: 'Sails.js is the best JavaScript framework'
},
{
id: 4,
author: 'koo',
tweet: 'The 4th annual SailsConf is coming up in May in Abuja!'
},
];
let topPosts = [];
await ƒ.simultaneouslyForEach(posts, async (post)=>{
let postClassification = await ƒ.decide(post, {
'Top post': 'A social media post that is both (a) VERY interesting and (b) in reasonably good taste',
'n/a': 'Anything else',
});
if (postClassification === 'Top post') {
topPosts.push(post);
}
});//∞
return topPosts;
}
};