Action
Rewrite Gemini
Posted by slyfox,
Last update
3 days ago
- Unlisted
Google Gemini - Rewrite using natural language and phrasing. Do not use contraction.
Steps
-
script
// get your input selected text, and store range for later const selection = editor.getSelectedText() const [st, len] = editor.getSelectedRange() // setup model name to use // FIX: Explicitly specify the model path as requested. This format is needed // for Drafts to send the request correctly and avoid the 404 error. const GeminiModel = "models/gemini-flash-latest" // Prompts let f = () => { let instruction = `Revise the following text so it is concise, clear, and informative, suitable for inclusion in a psychological report. Tone and Style: • Semi-formal and professional • Follow Canadian English spelling and conventions Requirements: • Preserve the abbreviation “MVA” exactly as written • Eliminate redundancy and use precise language • Prioritise readability and clarity for a professional audience Output: Provide the revised text only. Do not include explanations or commentary. Input:` // build prompt with instruction and selection let chatPrompt = `${instruction} "${selection}"` // Instantiate the AI object let ai = new GoogleAI() // FIX: Use quickPrompt() and pass the model name as the second argument // to ensure "gemini-3-pro-preview" is used. let answer = ai.quickPrompt(chatPrompt, GeminiModel) // if we got no reply, cancel if (!answer || answer.length == 0) { // Log a failure message if no answer is received console.log("Gemini returned an empty or invalid response.") return false } editor.setSelectedText(answer) editor.setSelectedRange(st, answer.length) return true } if (!f()) { // Only call context.fail() if the function returns false 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.