Exploring the new Foundation Models framework introduced at WWDC25
Using the @Generable macro for Guided Generation to create a Superhero. The language model session is defined in the Observable class SuperheroGenerator, in which an instance is created in the Button("Ask Question") under a Task. The Task is assigned to a State variable, and this allows the streamed response to be cancelled, similar to how one interrupts the chatbot from a Stop button.
A sample PNG file showing the output, and the swift file with the code is included in this Repository.