Action
Random Numbers
Posted by agiletortoise,
Last update
1 day ago
Asks the local, on-device model to generate an array of random integer numbers. Not terribly useful in an of itself, but provided as an example of ways to retreive structured data from the model.
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 a Number Group with 10 random integer numbers. Numbers should be positive, and no greater than 100` // CREATE MODEL OBJECT let m = SystemLanguageModel.create() // CREATE SCHEMA TO GET BACK STRUCTURED DATA let schema = SystemLanguageModelSchema.create("Number Group", "A group of numbers.") schema.addIntArray("numbers", "A list of numbers") // QUERY THE MODEL let response = m.respond(prompt, schema) // IF TAGS RETURNED, PROMPT TO SELECT AND ASSIGN if (response) { alert(JSON.stringify(response.numbers)) } 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.