Action
OpenAI: Correct Spelling in Selection
Posted by agiletortoise,
Last update
27 days ago
Correct spelling in the selected text using OpenAI’s text corrections. The result will replace the text selection.
For more information on using this action, visit our OpenAI integration guide
Steps
-
script
// get editor values const [st, len] = editor.getSelectedRange() const selection = editor.getSelectedText() // build prompt const instruction = `Fix the spelling mistakes` // create OpenAI API object and use single response // convenience function to send prompt let ai = new OpenAI() let answer = ai.quickTextEdit(selection, instruction) // if we got a reply, add it to the draft if (answer) { answer = answer.replace(/^"+|"+$/g, '') editor.setSelectedText(answer) editor.setSelectedRange(st, answer.length) } else { context.fail() }
Options
-
After Success Default Notification Info Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.