Action

Ask Model

Posted by agiletortoise, Last update 1 day 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 experimental draft tool in the model query, to support making basic. queries about your drafts library, like “Do I have any drafts that contain the text ‘hello’?”

This action is meant as an example action to demonstrate the use of SystemLanguageModel scripting.

(requires iOS/macOS 26 + Apple Intelligence)

Steps

  • script

    let f = () => {
    	if (!SystemLanguageModel.isAvailable) {
    		alert("Model not available. Apple Intelligence and OS 26 required.")
    		return false
    	}
    
    	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 }
    
    	let prompt = p.fieldValues["prompt"]
    	let lm = new SystemLanguageModel()
    	lm.tools = ["draft"]
    	let response = lm.respond(prompt)
    
    	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.