Action
Ask Model
Posted by agiletortoise,
Last update
9 days ago
Prompts for, well, a prompt to submit to the on-device Foundation Model, and displays its respond. Useful and a test/debugging tool for trying out prompts.
This also includes the draft tools in the model query, to support making basic. queries about your drafts library, like “Do I have any drafts that contain the text ‘hello’?” or “Create a draft with the text Hello World”
This action is meant as an example action to demonstrate the use of SystemLanguageModel
scripting. (docs)
(requires iOS/macOS 26 + Apple Intelligence)
Steps
-
script
let f = () => { // EXIT EARLY IF NOT SUPPORTED if (!SystemLanguageModel.isAvailable) { alert("Model not available. Apple Intelligence and OS 26 required.") return false } // PROMPT USER FOR, WELL, PROMPT let p = new Prompt() p.title = "Ask Model" p.message = "Type a prompt below, and get a response from the on-device model" p.addTextView("prompt", "Prompt") p.addButton("Submit") if(!p.show()) { return false } // GET PROMPT AND SUBMIT TO MODEL let prompt = p.fieldValues["prompt"] let lm = new SystemLanguageModel() lm.enableAllTools() let response = lm.respond(prompt) // DISPLAY RESPONSE OR ERROR if (!response) { alert(lm.lastError) return false } else { alert(`${response}`) } return true } if (!f()) { 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.