diff --git a/website/api/helpers/ai/improve-prompt.js b/website/api/helpers/ai/improve-prompt.js new file mode 100644 index 0000000000..f2184d2cc8 --- /dev/null +++ b/website/api/helpers/ai/improve-prompt.js @@ -0,0 +1,60 @@ +module.exports = { + + + friendlyName: 'Improve prompt', + + + description: '', + + + sideEffects: 'cacheable', + + + inputs: { + + prompt: { type: 'string', required: true, example: 'Who is running macOS 15?' }, + cycles: { type: 'number', defaultsTo: 1 } + + }, + + + exits: { + + success: { + outputFriendlyName: 'Improved prompt', + outputDescription: 'The new and improved prompt.', + outputType: 'string', + outputExample: 'Who is running macOS 15?', + }, + + }, + + + fn: async function ({ prompt: originalPrompt, cycles }) { + + let newPrompt = originalPrompt; + for (let i=0; i{ + // FUTURE: Add an option to run multiple times. + let parsedPromptResponse = await sails.helpers.ai.prompt.with({ + baseModel: 'o4-mini-2025-04-16', + prompt: improverPrompt, + }); + return parsedPromptResponse; + }).retry(); + }//∞ + + return newPrompt; + } + + +}; + diff --git a/website/scripts/test-ai-decision.js b/website/scripts/test-ai-decision.js index 3e97881764..fc01386896 100644 --- a/website/scripts/test-ai-decision.js +++ b/website/scripts/test-ai-decision.js @@ -27,11 +27,6 @@ module.exports = { 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 = []; diff --git a/website/scripts/test-ai-improve-prompt.js b/website/scripts/test-ai-improve-prompt.js new file mode 100644 index 0000000000..19733cec38 --- /dev/null +++ b/website/scripts/test-ai-improve-prompt.js @@ -0,0 +1,49 @@ +module.exports = { + + + friendlyName: 'Test ai improve prompt', + + + description: '', + + + fn: async function () { + + sails.log('Running custom shell script... (`sails run test-ai-improve-prompt`)'); + + let prompt1 = ( + 'Given some data and a set of possible choices, decide which choice most accurately classifies the data. Data: ```\n'+ + JSON.stringify([ + { + 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' + }, + ])+ + '```\n'+'\n'+'Choices:\n'+ + ' • A social media post that is both (a) VERY interesting and (b) in reasonably good taste\n'+ + ' • Anything else\n'+ + '\n'+ + 'Decide based on which choice is the most correct for the given data. Respond only with the exact string value for the choice provided.' + ); + sails.log(await ƒ.improvePrompt(prompt1)); + + sails.log(await ƒ.improvePrompt(prompt1),2); + + sails.log(await ƒ.improvePrompt(prompt1),5); + + } + + +}; + diff --git a/website/scripts/test-ai-weights.js b/website/scripts/test-ai-weights.js index 68a062ebc9..4077ec6280 100644 --- a/website/scripts/test-ai-weights.js +++ b/website/scripts/test-ai-weights.js @@ -27,11 +27,6 @@ module.exports = { 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 weighedPosts = await ƒ.simultaneouslyForEach(posts, async (post)=>{