Action
Suggest Tags
Posted by agiletortoise,
Last update
1 day ago
Asks the local, on-device AI to review the content of the current draft and suggest useful organizational tags, then prompts the user to select from those suggestions and assign them to the draft.
This action is meant as an example action to demonstrate the use of SystemLanguageModel
scripting. (docs)
(requires iOS/macOS 26 + Apple Intelligence)
Steps
-
script
// CREATE A PROMPT TO SEND TO MODEL const prompt = `Generate tag suggestions to use classifying the text below: ${draft.content}` // CREATE MODEL OBJECT let m = SystemLanguageModel.create() // CREATE SCHEMA TO GET BACK STRUCTURED DATA let schema = SystemLanguageModelSchema.create("Tag Suggestions", "A set of tag suggestions to classify a text.") schema.addStringArray("tags", "A list of tags to assign the text") // QUERY THE MODEL let response = m.respond(prompt, schema) // IF TAGS RETURNED, PROMPT TO SELECT AND ASSIGN if (response) { let suggestions = response["tags"] if (suggestions) { suggestions = suggestions.map(t => t.toLowerCase()) } if (!suggestions || suggestions.length == 0) { alert("No tag suggestions available") } else { let p = new Prompt() p.title = "Assign Tags" p.symbolName = "tag" p.addSelect("tags", "Tags", suggestions, [], true) p.addButton("Assign") if (p.show()) { let newTags = p.fieldValues["tags"] for (let tag of newTags) { draft.addTag(tag) } draft.update() } } } else { alert(m.lastError) 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.