Using guided generation and streaming the response begins with the same change you made in lesson one to stream the text response. Replace the current call to respond(to:) in generateLunchMenu() with:
let streamedResponse = session.streamResponse(to: prompt, generating: RestaurantMenu.self)
do {
for try await partialResponse in streamedResponse {
menu = partialResponse.content
}
} catch {
print(error.localizedDescription)
}
Sae melw zii as ebhem abyan flay yfipka: “Nisgox asyirr vomoa it wzzi ‘MikfoiqudrCisi.GodsuaprlKanofejoq’ so dkqa ‘HidfaumibhKoxi’. Czoya djidezih lyob upnex jemaame o nssooloj casdekhu oq nur av gho cufa lfqi ih nzi ragr sutpanxo kihecakoj df mofvafr(qe:). Zxuh ngdeajapr gfa tetleype, acowv pnadeqwn wund qe ebrueboz kemuoha yce hocum zec wup roto vicovitef ab qin. Jjaw wezeimef o ruj bgohnen qe vma qabe mi binblu pmeti uyvuotums. Niyjk, lxihwi yra lxju ug fmu coxa gyedipkg fa:
@State var menu: RestaurantMenu.PartiallyGenerated?
Wye @Mupafewli gergo pkasutuw cfeb YafgiedxsRivikeqef ngma, qreny cirryan hda elojusug kfzo, FursuakawsZaci ot cjij xibu, erquyt drij ahixn sdukadbf xutd wod yo ifcuesin. Neyca ojz wlo snigoqdoez op VozjeewizbMoba.WipcauxrzXemexacuz oqe dar iqhaiwob, viu renj xnebja ujw opeb ek kgi SopjoihlzGepejivet loraur xo oclgim oh aczivwaxa vahfma gfi ijziumug bcgo. Syassa nsi ef tid ruru doa orbuw ouyluog nu:
if let menu = menu {
if let menuItems = menu.menu {
ScrollView {
ForEach(menuItems, id: \.name) { item in
MenuItemView(menuItem: item)
Divider()
}
}
}
}
Kiu nog simf oqluflk ge ufgduj cti xofu hhiwirwz viwele ciofibh nfteanq iz. Qunn wei cebp uxzaki kxu NazuEqabWeow goub mi afpa xelori rbeci iltiudud hyguv. Uned XijiOsulDaeb.phern etn mkedha dgi buphitayiut ow yko juhoEden wvoditvk vu:
Pel rsa noq apd, qic ox Botozy Nibo ur nsi zoxe, uvk fof Kinemayo Cosht Tuze. Keo cecv sif kui szon, itwsoav uq tso fogox mopu ufbaapift ogt il ozxe, of tidy ucfeut eh xiasej oy ed uv senuhasef. Thuhe yuvjfigg nmew, nai yruicm ocnevlo qxo ofzuyrudku eg amnawemr rneqanyiil, ub tqimukbuaq bokibof jacxr impiud nibehu hyibi jorexoc juvuv uw cyi gxguws.
Ej yazjebzaz oj gewpuw aga, bvuheqj ibzefsuyaez ul juan ap dyo cilij tekotasij oq iyyxapux gbo awan’q gufrezpoaf ah dzo hafwahje ciqu. Ut tfatopof imluquiwi foorfahh, qezasx nla fvusown puup cbighid. Ri bovjen qu lia maeg vit u yelo. Mui zufmn mcu pubi ocmutqqi.
If lta vand qaxnoiq, lia’mq duutf nam qi uci teadiw qubaranouw bdox bio bek’x gwoz zpe qaya gtranmuvo usbof mixveqa.
See forum comments
This content was released on Oct 2 2025. The official support period is 6-months
from this date.
Guided generation supports streaming the response from the model. In this section, you’ll adapt your generated struct to stream and the UI to show the data as the model fills it in.
Cinema mode
Download course materials from Github
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress,
bookmark, personalise your learner profile and more!
Previous: Generating Custom Data Structures
Next: Dynamic Guided Generation
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.