Action

Ask Model (Dictation)

Posted by agiletortoise, Last update 9 days ago

Prompts for dictation, and submits the dictated text as a prompt 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
    	}
    	
    	// dictate text
    	let text = editor.dictate()
    	if (!text || text.length == 0) {
    		return false
    	}
    
    	let model = new SystemLanguageModel()
    	model.enableAllTools()
    	let response = model.respond(text)
    
    	// DISPLAY RESPONSE OR ERROR
    	if (!response) {
    		alert(lm.lastError)
    		return false
    	}
    	else {
    		alert(`${response}`)
    	}
    	return true
    }
    
    if (!f()) {
    	context.cancel()
    }

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.