<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0"><channel><title><![CDATA[NatashaTheRobot]]></title><description><![CDATA[Exploring AI-powered app development in Swift—practical insights, hands-on projects, and the latest in AI integration for iOS developers.]]></description><link>https://www.natashatherobot.com</link><image><url>https://substackcdn.com/image/fetch/$s_!E40x!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff20a345c-8476-4875-9dcd-4468de9bed9f_1000x1000.jpeg</url><title>NatashaTheRobot</title><link>https://www.natashatherobot.com</link></image><generator>Substack</generator><lastBuildDate>Sun, 03 May 2026 00:29:24 GMT</lastBuildDate><atom:link href="https://www.natashatherobot.com/feed" rel="self" type="application/rss+xml"/><copyright><![CDATA[NatashaTheRobot, Inc]]></copyright><language><![CDATA[en]]></language><webMaster><![CDATA[natashatherobot@substack.com]]></webMaster><itunes:owner><itunes:email><![CDATA[natashatherobot@substack.com]]></itunes:email><itunes:name><![CDATA[NatashaTheRobot]]></itunes:name></itunes:owner><itunes:author><![CDATA[NatashaTheRobot]]></itunes:author><googleplay:owner><![CDATA[natashatherobot@substack.com]]></googleplay:owner><googleplay:email><![CDATA[natashatherobot@substack.com]]></googleplay:email><googleplay:author><![CDATA[NatashaTheRobot]]></googleplay:author><itunes:block><![CDATA[Yes]]></itunes:block><item><title><![CDATA[Gemini Batch Mode API Made Easy: Mac App for Smarter Bulk Request Handling]]></title><description><![CDATA[I build an open-source Mac app for managing the new Gemini Batch Mode API!]]></description><link>https://www.natashatherobot.com/p/gemini-batch-mode-api-mac-app</link><guid isPermaLink="false">https://www.natashatherobot.com/p/gemini-batch-mode-api-mac-app</guid><dc:creator><![CDATA[NatashaTheRobot]]></dc:creator><pubDate>Wed, 20 Aug 2025 14:00:44 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/29e4b19c-82ad-47d3-8e51-3d8119597f82_1536x950.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>One of the biggest advantages of coding much faster with AI tools is that we can now quickly build apps that are super specific to our workflows - both personal, professional, and in organizations. And after running 100s of <a href="https://ai.google.dev/gemini-api/docs/batch-mode">Gemini API Batch jobs</a> as I continue working on my <a href="https://apps.apple.com/us/app/sanskrit-lexicon/id6746787546">Sanskrit-English Dictionary app</a>, I just had to code a tool to manage it all, and I did!</p><h2>The Backstory</h2><p>While the mainstream use-case for LLMs is using it as chatbots, there are a lot of opportunities to use it behind-the-scenes. In my case of building a Sanskrit-English Dictionary app, my database is extremely static and doesn&#8217;t change. That means that I can process many dictionary definitions using LLMs on the backend, and simply show the result to all users in a UI-friendly way in my app, without them even being aware that AI was used for processing. </p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.natashatherobot.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">This Substack is reader-supported. To receive new posts and support my work, consider becoming a free or paid subscriber.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>I&#8217;ve already worked a lot with the Gemini 2.5 Pro API, before Batch Mode was released, and it took me ~ 30 days to process all my database definitions in the past one-by-one. So when Batch Mode came out, I couldn&#8217;t be more excited! Now my processing time went down to only 2 days and my cost went down 50%!</p><h2>The Problems</h2><p>I initially ran my batch jobs via Python scripts, but quickly ran into an organizational nightmare. There were several things to keep track of: </p><ol><li><p>I had to divide up all my data into 100s of files to stay within the Batch Mode limits </p></li><li><p>Some of my files had to run using Gemini 2.5 Flash, and some had to be run using Gemini 2.5 Pro. When running a batch job, you have to run it using only 1 model, you cannot combine requests that need to run via different models. </p></li><li><p>I had to have a way to keep track of which files are running, which are done, which should be queued up next, etc. </p></li><li><p>I didn&#8217;t know how much everything was costing - yes, this is my fault, but I ended up spending A LOT more than I estimated. Since the batch jobs run so fast and the Gemini usage billing data updates very slowly, I ended up with a very surprising bill. Yes, again, my fault for not being slow in testing out the costs and not calculating them more carefully, but I honestly didn&#8217;t think it would go past my budget. </p></li><li><p>There is a tight timeframe for some of the tasks - once you upload your batch request file, it expires within 48 hours. The batch job itself expires after 48 hours after it starts. And of course, the batch job results file also expires after 48 hours. So you cannot just take your eye off-the-ball and return a week later to download your files. You have to actively poll for the result to make sure you download it before everything expires and you lose all your money on that batch job, having to re-run it again. </p></li></ol><p>I did manage all of this in Python, but it was a bit of a mess. I really wished Gemini had a better interface to manage these batch requests, similar to what OpenAI has, but unfortunately, it&#8217;s just not there. So I decided to build it myself! </p><h2>The Gemini Batch Mac App</h2><p>So for the past week, I took the time to build the interface that I wished the Google Gemini team had&#8230; as a Mac Tahoe app. Here is the result! </p><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;0c4fbde1-3d69-49e3-9909-7d96961a606c&quot;,&quot;duration&quot;:null}"></div><p>Simply upload your JSONL Batch request files, click Run, and the whole process is managed for you! You can keep track of exactly what is happening in the right-hand pane by selecting the file at any time. And the results file is saved in the app sandbox directory - safe from the 48 hour expiration. You can come back to the app whenever you have time, and download all completed JSONL results file, which you can then process further!</p><p>Oh - and I forgot to mention one thing! The tokens are calculated at the end of each batch job, so you can get an estimated price per file run. So it&#8217;s very easy to test by running 1 file, waiting around 5 - 15 minutes for the batch job to complete, and check the costs before running more files. Wish I had this when I started running my Gemini batch jobs! </p><h2>The App is Open Source</h2><p>The app is now open source and available on the <a href="https://github.com/trySwiftAI/GeminiBatch">try! Swift AI Github</a> for anybody to use! Note that the app is made for macOS 26 only - as I wanted to play around with LiquidGlass, but it should be easy to clone and port back if you need. </p><p>To learn how to read / write JSONL files in Swift, read my blog post: <a href="https://www.natashatherobot.com/p/read-write-jsonl-files-swift">How to Read / Write JSONL Files in Swift</a>. I also build a <a href="https://jsonlbeautifier.com/">JSONL Beautifier</a> to make it easy to inspect the JSONL results as I couldn&#8217;t find one when I searched. </p><p>Happy Batch Processing &#128640;&#128640;&#128640;</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.natashatherobot.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">This Substack is reader-supported. To receive new posts and support my work, consider becoming a free or paid subscriber.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[How to Read / Write JSONL Files in Swift]]></title><description><![CDATA[Learn how to work with JSONL files in Swift - especially useful for working with LLM Batch Requests.]]></description><link>https://www.natashatherobot.com/p/read-write-jsonl-files-swift</link><guid isPermaLink="false">https://www.natashatherobot.com/p/read-write-jsonl-files-swift</guid><dc:creator><![CDATA[NatashaTheRobot]]></dc:creator><pubDate>Wed, 20 Aug 2025 05:07:45 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/21be6d66-5424-400a-89c6-567f36ef0e1f_1024x1024.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>If you&#8217;re working with LLM APIs, you might have noticed a new common file format gaining popularity: JSONL. This is especially used for making batch requests. So what is JSONL and how do you work with it in Swift?  </p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.natashatherobot.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">This Substack is reader-supported. To receive new posts and support my work, consider becoming a free or paid subscriber.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p><strong>JSONL</strong>, short for <strong>JSON</strong> <strong>L</strong>ines (also known as newline-delimited JSON), is a text-based format where each line is a standalone, valid JSON object&#65532;. Unlike traditional JSON (which often holds an entire array or nested structure), JSONL is structured so that each entry lives on its own line, separated by newline characters ( \n ).</p><p>A sample JSONL file will look like this: </p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!sEp4!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8502dbf6-5fc9-46ca-9e8b-63c0bf2cae74_858x132.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!sEp4!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8502dbf6-5fc9-46ca-9e8b-63c0bf2cae74_858x132.png 424w, https://substackcdn.com/image/fetch/$s_!sEp4!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8502dbf6-5fc9-46ca-9e8b-63c0bf2cae74_858x132.png 848w, https://substackcdn.com/image/fetch/$s_!sEp4!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8502dbf6-5fc9-46ca-9e8b-63c0bf2cae74_858x132.png 1272w, https://substackcdn.com/image/fetch/$s_!sEp4!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8502dbf6-5fc9-46ca-9e8b-63c0bf2cae74_858x132.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!sEp4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8502dbf6-5fc9-46ca-9e8b-63c0bf2cae74_858x132.png" width="858" height="132" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8502dbf6-5fc9-46ca-9e8b-63c0bf2cae74_858x132.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:132,&quot;width&quot;:858,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:50518,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/171430449?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8502dbf6-5fc9-46ca-9e8b-63c0bf2cae74_858x132.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!sEp4!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8502dbf6-5fc9-46ca-9e8b-63c0bf2cae74_858x132.png 424w, https://substackcdn.com/image/fetch/$s_!sEp4!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8502dbf6-5fc9-46ca-9e8b-63c0bf2cae74_858x132.png 848w, https://substackcdn.com/image/fetch/$s_!sEp4!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8502dbf6-5fc9-46ca-9e8b-63c0bf2cae74_858x132.png 1272w, https://substackcdn.com/image/fetch/$s_!sEp4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8502dbf6-5fc9-46ca-9e8b-63c0bf2cae74_858x132.png 1456w" sizes="100vw" fetchpriority="high"></picture><div></div></div></a></figure></div><p>Again, note that there is no comma to separate the JSON structures. New structures / objects are simply on a new line ( \n ). Note also that each JSON value has an id to identify / map it. </p><h2>Writing a JSONL File</h2><p>Let&#8217;s say we want to create a Gemini API Batch request to generate Haiku poems for a list of topics. To do this, we would need to create a <code>haiku_batch_requests.jsonl</code> file to upload to the files API and then reference for creating the batch request.</p><p>Before writing to the file, we first need to define the system instructions and the haiku subjects. The system instructions will be reused in every JSON structure, but the subjects of the haiku will change.  </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!wTJ7!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf28fff8-ed7b-49c4-9635-f8cc491d16bf_1828x714.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!wTJ7!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf28fff8-ed7b-49c4-9635-f8cc491d16bf_1828x714.png 424w, https://substackcdn.com/image/fetch/$s_!wTJ7!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf28fff8-ed7b-49c4-9635-f8cc491d16bf_1828x714.png 848w, https://substackcdn.com/image/fetch/$s_!wTJ7!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf28fff8-ed7b-49c4-9635-f8cc491d16bf_1828x714.png 1272w, https://substackcdn.com/image/fetch/$s_!wTJ7!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf28fff8-ed7b-49c4-9635-f8cc491d16bf_1828x714.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!wTJ7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf28fff8-ed7b-49c4-9635-f8cc491d16bf_1828x714.png" width="1456" height="569" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/af28fff8-ed7b-49c4-9635-f8cc491d16bf_1828x714.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:569,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:185125,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/171430449?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf28fff8-ed7b-49c4-9635-f8cc491d16bf_1828x714.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!wTJ7!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf28fff8-ed7b-49c4-9635-f8cc491d16bf_1828x714.png 424w, https://substackcdn.com/image/fetch/$s_!wTJ7!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf28fff8-ed7b-49c4-9635-f8cc491d16bf_1828x714.png 848w, https://substackcdn.com/image/fetch/$s_!wTJ7!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf28fff8-ed7b-49c4-9635-f8cc491d16bf_1828x714.png 1272w, https://substackcdn.com/image/fetch/$s_!wTJ7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf28fff8-ed7b-49c4-9635-f8cc491d16bf_1828x714.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Note that since we need to be able to map the subject of the haiku to the generated haiku, we need to include the id or key for each subject: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!AqnD!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc08b126-189f-4f16-b692-f95815975d70_1280x704.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!AqnD!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc08b126-189f-4f16-b692-f95815975d70_1280x704.png 424w, https://substackcdn.com/image/fetch/$s_!AqnD!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc08b126-189f-4f16-b692-f95815975d70_1280x704.png 848w, https://substackcdn.com/image/fetch/$s_!AqnD!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc08b126-189f-4f16-b692-f95815975d70_1280x704.png 1272w, https://substackcdn.com/image/fetch/$s_!AqnD!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc08b126-189f-4f16-b692-f95815975d70_1280x704.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!AqnD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc08b126-189f-4f16-b692-f95815975d70_1280x704.png" width="1280" height="704" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/cc08b126-189f-4f16-b692-f95815975d70_1280x704.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:704,&quot;width&quot;:1280,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:300534,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/171430449?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc08b126-189f-4f16-b692-f95815975d70_1280x704.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!AqnD!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc08b126-189f-4f16-b692-f95815975d70_1280x704.png 424w, https://substackcdn.com/image/fetch/$s_!AqnD!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc08b126-189f-4f16-b692-f95815975d70_1280x704.png 848w, https://substackcdn.com/image/fetch/$s_!AqnD!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc08b126-189f-4f16-b692-f95815975d70_1280x704.png 1272w, https://substackcdn.com/image/fetch/$s_!AqnD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc08b126-189f-4f16-b692-f95815975d70_1280x704.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Note that for simplicity I&#8217;m using simple integers as keys, but in reality this would be a key that matches to your database, such as an UUID.</p><p>Next, you need to create an Encodable object that you can encode to JSON. In the case of the Gemini Batch API, I will be using the existing <a href="https://github.com/lzell/AIProxySwift">AIProxy</a> library since it already has an encodable request object: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!S3VK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde49a74c-8514-4ed3-9a69-94c632d93b80_1126x336.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!S3VK!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde49a74c-8514-4ed3-9a69-94c632d93b80_1126x336.png 424w, https://substackcdn.com/image/fetch/$s_!S3VK!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde49a74c-8514-4ed3-9a69-94c632d93b80_1126x336.png 848w, https://substackcdn.com/image/fetch/$s_!S3VK!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde49a74c-8514-4ed3-9a69-94c632d93b80_1126x336.png 1272w, https://substackcdn.com/image/fetch/$s_!S3VK!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde49a74c-8514-4ed3-9a69-94c632d93b80_1126x336.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!S3VK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde49a74c-8514-4ed3-9a69-94c632d93b80_1126x336.png" width="1126" height="336" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/de49a74c-8514-4ed3-9a69-94c632d93b80_1126x336.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:336,&quot;width&quot;:1126,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:89727,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/171430449?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde49a74c-8514-4ed3-9a69-94c632d93b80_1126x336.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!S3VK!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde49a74c-8514-4ed3-9a69-94c632d93b80_1126x336.png 424w, https://substackcdn.com/image/fetch/$s_!S3VK!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde49a74c-8514-4ed3-9a69-94c632d93b80_1126x336.png 848w, https://substackcdn.com/image/fetch/$s_!S3VK!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde49a74c-8514-4ed3-9a69-94c632d93b80_1126x336.png 1272w, https://substackcdn.com/image/fetch/$s_!S3VK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde49a74c-8514-4ed3-9a69-94c632d93b80_1126x336.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Again, to generate the JSONL file, it can be ANY encodable object that you need. </p><p>Finally, I will simply go through each of my haiku subjects and generate a JSON string from it, which I&#8217;ll store in an array of json lines. Then I will simply combine them with a &#8220;\n&#8221; character like this: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!4IEX!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47e7fb3c-bb87-4b28-a512-77b05cc35249_1758x1306.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!4IEX!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47e7fb3c-bb87-4b28-a512-77b05cc35249_1758x1306.png 424w, https://substackcdn.com/image/fetch/$s_!4IEX!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47e7fb3c-bb87-4b28-a512-77b05cc35249_1758x1306.png 848w, https://substackcdn.com/image/fetch/$s_!4IEX!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47e7fb3c-bb87-4b28-a512-77b05cc35249_1758x1306.png 1272w, https://substackcdn.com/image/fetch/$s_!4IEX!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47e7fb3c-bb87-4b28-a512-77b05cc35249_1758x1306.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!4IEX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47e7fb3c-bb87-4b28-a512-77b05cc35249_1758x1306.png" width="1456" height="1082" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/47e7fb3c-bb87-4b28-a512-77b05cc35249_1758x1306.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1082,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:439901,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/171430449?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47e7fb3c-bb87-4b28-a512-77b05cc35249_1758x1306.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!4IEX!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47e7fb3c-bb87-4b28-a512-77b05cc35249_1758x1306.png 424w, https://substackcdn.com/image/fetch/$s_!4IEX!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47e7fb3c-bb87-4b28-a512-77b05cc35249_1758x1306.png 848w, https://substackcdn.com/image/fetch/$s_!4IEX!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47e7fb3c-bb87-4b28-a512-77b05cc35249_1758x1306.png 1272w, https://substackcdn.com/image/fetch/$s_!4IEX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47e7fb3c-bb87-4b28-a512-77b05cc35249_1758x1306.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>That&#8217;s it! The hard part is over. The final part is simply to write the newly generated json lines string to file: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!85RQ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff61446bd-bdbf-41ee-b1cb-985fdf19ee95_1800x716.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!85RQ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff61446bd-bdbf-41ee-b1cb-985fdf19ee95_1800x716.png 424w, https://substackcdn.com/image/fetch/$s_!85RQ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff61446bd-bdbf-41ee-b1cb-985fdf19ee95_1800x716.png 848w, https://substackcdn.com/image/fetch/$s_!85RQ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff61446bd-bdbf-41ee-b1cb-985fdf19ee95_1800x716.png 1272w, https://substackcdn.com/image/fetch/$s_!85RQ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff61446bd-bdbf-41ee-b1cb-985fdf19ee95_1800x716.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!85RQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff61446bd-bdbf-41ee-b1cb-985fdf19ee95_1800x716.png" width="1456" height="579" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f61446bd-bdbf-41ee-b1cb-985fdf19ee95_1800x716.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:579,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:346036,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/171430449?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff61446bd-bdbf-41ee-b1cb-985fdf19ee95_1800x716.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!85RQ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff61446bd-bdbf-41ee-b1cb-985fdf19ee95_1800x716.png 424w, https://substackcdn.com/image/fetch/$s_!85RQ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff61446bd-bdbf-41ee-b1cb-985fdf19ee95_1800x716.png 848w, https://substackcdn.com/image/fetch/$s_!85RQ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff61446bd-bdbf-41ee-b1cb-985fdf19ee95_1800x716.png 1272w, https://substackcdn.com/image/fetch/$s_!85RQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff61446bd-bdbf-41ee-b1cb-985fdf19ee95_1800x716.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Here I&#8217;m storing the final JSONL in the user&#8217;s Downloads folder, but you can store it in any path and access it as needed. </p><h2>Reading the JSONL file</h2><p>Reading from a JSONL file follows the same process but in reverse, in the following steps: </p><ol><li><p>Separate the response by the new lines character ( \n ) </p></li><li><p>Iterate line-by-line and decode each line into a Decodable object</p></li><li><p>Return back an array of decodable objects</p></li></ol><p>The code is simple: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!3uic!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4d8f295-0c9e-4266-a94b-13cb4cf474fd_1336x982.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!3uic!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4d8f295-0c9e-4266-a94b-13cb4cf474fd_1336x982.png 424w, https://substackcdn.com/image/fetch/$s_!3uic!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4d8f295-0c9e-4266-a94b-13cb4cf474fd_1336x982.png 848w, https://substackcdn.com/image/fetch/$s_!3uic!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4d8f295-0c9e-4266-a94b-13cb4cf474fd_1336x982.png 1272w, https://substackcdn.com/image/fetch/$s_!3uic!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4d8f295-0c9e-4266-a94b-13cb4cf474fd_1336x982.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!3uic!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4d8f295-0c9e-4266-a94b-13cb4cf474fd_1336x982.png" width="1336" height="982" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a4d8f295-0c9e-4266-a94b-13cb4cf474fd_1336x982.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:982,&quot;width&quot;:1336,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:304015,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/171430449?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4d8f295-0c9e-4266-a94b-13cb4cf474fd_1336x982.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!3uic!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4d8f295-0c9e-4266-a94b-13cb4cf474fd_1336x982.png 424w, https://substackcdn.com/image/fetch/$s_!3uic!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4d8f295-0c9e-4266-a94b-13cb4cf474fd_1336x982.png 848w, https://substackcdn.com/image/fetch/$s_!3uic!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4d8f295-0c9e-4266-a94b-13cb4cf474fd_1336x982.png 1272w, https://substackcdn.com/image/fetch/$s_!3uic!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4d8f295-0c9e-4266-a94b-13cb4cf474fd_1336x982.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>That&#8217;s it! </p><h2>Conclusion</h2><p>While the JSONL format may seem a bit intimidating at first - just from being new and something many of us haven&#8217;t worked with, it&#8217;s actually just as simple to work with as with any JSON object. Just go line-by-line! </p><p><strong>BONUS</strong>: I wanted to beautify my JSONL file, but couldn&#8217;t find a JSONL Beautifier online, so I made one! </p><p><a href="https://jsonlbeautifier.com/">https://jsonlbeautifier.com/</a></p><p>Happy building! </p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.natashatherobot.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">This Substack is reader-supported. To receive new posts and support my work, consider becoming a free or paid subscriber.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p></p>]]></content:encoded></item><item><title><![CDATA[Batch Processing with Gemini API: A Swift Developer's Guide (Recording Only)]]></title><description><![CDATA[Learn how to leverage Gemini's Batch Mode in Swift!]]></description><link>https://www.natashatherobot.com/p/batch-processing-with-gemini-api-swift</link><guid isPermaLink="false">https://www.natashatherobot.com/p/batch-processing-with-gemini-api-swift</guid><dc:creator><![CDATA[NatashaTheRobot]]></dc:creator><pubDate>Wed, 20 Aug 2025 01:42:28 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/d892e908-cc5f-4e20-b5bc-2f3057f74ac3_200x200.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><em>Please note that the workshop has already taken place. You can purchase access to the session recording, which also includes exclusive access to the GitHub repositories referenced during the event. Upon purchase, the recording will be delivered to your email within 24 hours.</em></p><p>Learn how to leverage Google's Gemini Batch API to add powerful background AI processing to your Swift applications. Perfect for developers using Firebase or Supabase who need to process large datasets asynchronously over hours or days without blocking user interactions. We'll walk through the complete lifecycle of creating batch requests, monitoring their progress, and handling results - all using Swift! You'll receive a fully functional Swift monitoring app at the end of the workshop to track your batch requests in real-time and integrate batch AI processing into your existing applications.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://buy.stripe.com/9B67sM0modVU5Oi6RKawo0n&quot;,&quot;text&quot;:&quot;Buy Now ($50)&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://buy.stripe.com/9B67sM0modVU5Oi6RKawo0n"><span>Buy Now ($50)</span></a></p><p></p>]]></content:encoded></item><item><title><![CDATA[Build Personal Reactive UIs with the FoundationModels framework (Recording Only)]]></title><description><![CDATA[Learn how to build fun reactive UIs using the FoundationModels framework.]]></description><link>https://www.natashatherobot.com/p/reactive-uis-foundation-models-framework</link><guid isPermaLink="false">https://www.natashatherobot.com/p/reactive-uis-foundation-models-framework</guid><dc:creator><![CDATA[NatashaTheRobot]]></dc:creator><pubDate>Wed, 20 Aug 2025 01:38:43 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/b1523a66-3102-4501-87eb-2ba09e3e8d4a_200x200.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><em>Please note that the workshop has already taken place. You can purchase access to the session recording, which also includes exclusive access to the GitHub repositories referenced during the event. Upon purchase, the recording will be delivered to your email within 24 hours.</em></p><p>&#8203;Discover how to use the FoundationModels framework to create truly reactive applications where users can configure app settings using natural language commands. Watch as we build a demo app that dynamically transforms its UI based on typed user preferences - from changing themes and layouts to adjusting functionality, all through conversational interaction. All code will be provided at the end of the workshop, so you can run it at your own pace whenever you are ready to upgrade to macOS Tahoe.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://buy.stripe.com/fZu28sglmdVUb8C6RKawo0m&quot;,&quot;text&quot;:&quot;Buy Now ($50)&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://buy.stripe.com/fZu28sglmdVUb8C6RKawo0m"><span>Buy Now ($50)</span></a></p><p></p>]]></content:encoded></item><item><title><![CDATA[How to Work with SwiftData in the Background in Swift 6]]></title><description><![CDATA[Especially when working with LLM APIs, there are many use-cases where we want to save the returned data from the API into existing SwiftData models. Here is how you do this in Swift 6!]]></description><link>https://www.natashatherobot.com/p/swiftdata-background-swift-6</link><guid isPermaLink="false">https://www.natashatherobot.com/p/swiftdata-background-swift-6</guid><dc:creator><![CDATA[NatashaTheRobot]]></dc:creator><pubDate>Thu, 14 Aug 2025 10:40:18 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!biFa!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ba02e40-cd16-4dc2-a32d-d153e095ed98_1062x602.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I may be late to the party, but I&#8217;m only now starting to work with Swift 6 (after being super super scared to even try!), and it&#8217;s actually pretty cool once you get the hang of it. More importantly, it&#8217;s making me think through and architect my apps differently - in a good way. </p><p>In my latest app, I have a SwiftData model where some of the variables are processed by an LLM API in the background and the SwiftData model has to be updated with the results from the API. I&#8217;ll give the example of a Journal app with a simple model: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!biFa!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ba02e40-cd16-4dc2-a32d-d153e095ed98_1062x602.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!biFa!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ba02e40-cd16-4dc2-a32d-d153e095ed98_1062x602.png 424w, https://substackcdn.com/image/fetch/$s_!biFa!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ba02e40-cd16-4dc2-a32d-d153e095ed98_1062x602.png 848w, https://substackcdn.com/image/fetch/$s_!biFa!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ba02e40-cd16-4dc2-a32d-d153e095ed98_1062x602.png 1272w, https://substackcdn.com/image/fetch/$s_!biFa!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ba02e40-cd16-4dc2-a32d-d153e095ed98_1062x602.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!biFa!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ba02e40-cd16-4dc2-a32d-d153e095ed98_1062x602.png" width="1062" height="602" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0ba02e40-cd16-4dc2-a32d-d153e095ed98_1062x602.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:602,&quot;width&quot;:1062,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:121415,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/170958851?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ba02e40-cd16-4dc2-a32d-d153e095ed98_1062x602.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!biFa!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ba02e40-cd16-4dc2-a32d-d153e095ed98_1062x602.png 424w, https://substackcdn.com/image/fetch/$s_!biFa!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ba02e40-cd16-4dc2-a32d-d153e095ed98_1062x602.png 848w, https://substackcdn.com/image/fetch/$s_!biFa!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ba02e40-cd16-4dc2-a32d-d153e095ed98_1062x602.png 1272w, https://substackcdn.com/image/fetch/$s_!biFa!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0ba02e40-cd16-4dc2-a32d-d153e095ed98_1062x602.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>The app will use an LLM API to analyze the journal entry&#8217;s mood. So the mood will start off by being nil and then being filled in once we get the LLM API response. The mood variable is not the most critical part of this app, so it can be done fully on the background while the user can browse or add other journal entries. </p><p>So let&#8217;s try to attempt to write a <code>nonisolated</code> class (to be executed in the background) to extract the mood from a journal entry: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!omDj!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff81c2278-f9e1-4cad-8a03-18980b04f38f_1930x1068.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!omDj!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff81c2278-f9e1-4cad-8a03-18980b04f38f_1930x1068.png 424w, https://substackcdn.com/image/fetch/$s_!omDj!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff81c2278-f9e1-4cad-8a03-18980b04f38f_1930x1068.png 848w, https://substackcdn.com/image/fetch/$s_!omDj!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff81c2278-f9e1-4cad-8a03-18980b04f38f_1930x1068.png 1272w, https://substackcdn.com/image/fetch/$s_!omDj!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff81c2278-f9e1-4cad-8a03-18980b04f38f_1930x1068.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!omDj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff81c2278-f9e1-4cad-8a03-18980b04f38f_1930x1068.png" width="1456" height="806" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f81c2278-f9e1-4cad-8a03-18980b04f38f_1930x1068.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:806,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:347487,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/170958851?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff81c2278-f9e1-4cad-8a03-18980b04f38f_1930x1068.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!omDj!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff81c2278-f9e1-4cad-8a03-18980b04f38f_1930x1068.png 424w, https://substackcdn.com/image/fetch/$s_!omDj!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff81c2278-f9e1-4cad-8a03-18980b04f38f_1930x1068.png 848w, https://substackcdn.com/image/fetch/$s_!omDj!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff81c2278-f9e1-4cad-8a03-18980b04f38f_1930x1068.png 1272w, https://substackcdn.com/image/fetch/$s_!omDj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff81c2278-f9e1-4cad-8a03-18980b04f38f_1930x1068.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>It&#8217;s not a full on error, but it&#8217;s a warning, and my goal is to remove all the warnings to make sure my code is Swift 6 level SAFE!! So how do we fix it? </p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.natashatherobot.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">This Substack is reader-supported. To receive new posts and support my work, consider becoming a free or paid subscriber.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><h2>The Model Actor</h2><p>To make sure that our SwiftData models are accessed, updated, and saved in a thread-safe manner on the background thread, we can use a <code>ModelActor</code>. By default, the model actor will take in the model container and make the changes as needed. </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!yVbk!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6cf1476-7d8f-4ca3-8dfc-2b27842ad4bc_612x322.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!yVbk!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6cf1476-7d8f-4ca3-8dfc-2b27842ad4bc_612x322.png 424w, https://substackcdn.com/image/fetch/$s_!yVbk!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6cf1476-7d8f-4ca3-8dfc-2b27842ad4bc_612x322.png 848w, https://substackcdn.com/image/fetch/$s_!yVbk!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6cf1476-7d8f-4ca3-8dfc-2b27842ad4bc_612x322.png 1272w, https://substackcdn.com/image/fetch/$s_!yVbk!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6cf1476-7d8f-4ca3-8dfc-2b27842ad4bc_612x322.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!yVbk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6cf1476-7d8f-4ca3-8dfc-2b27842ad4bc_612x322.png" width="612" height="322" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f6cf1476-7d8f-4ca3-8dfc-2b27842ad4bc_612x322.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:322,&quot;width&quot;:612,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:42504,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/170958851?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6cf1476-7d8f-4ca3-8dfc-2b27842ad4bc_612x322.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!yVbk!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6cf1476-7d8f-4ca3-8dfc-2b27842ad4bc_612x322.png 424w, https://substackcdn.com/image/fetch/$s_!yVbk!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6cf1476-7d8f-4ca3-8dfc-2b27842ad4bc_612x322.png 848w, https://substackcdn.com/image/fetch/$s_!yVbk!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6cf1476-7d8f-4ca3-8dfc-2b27842ad4bc_612x322.png 1272w, https://substackcdn.com/image/fetch/$s_!yVbk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff6cf1476-7d8f-4ca3-8dfc-2b27842ad4bc_612x322.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>The model actor will be the only one that deals with the actual models, so in order to pass around the model information to our Mood Extractor API, for example, we need to create a proxy object for the <code>JournalEntry</code>: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!bhT0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54579461-ca2c-437c-b580-97d74195c1ad_906x476.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!bhT0!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54579461-ca2c-437c-b580-97d74195c1ad_906x476.png 424w, https://substackcdn.com/image/fetch/$s_!bhT0!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54579461-ca2c-437c-b580-97d74195c1ad_906x476.png 848w, https://substackcdn.com/image/fetch/$s_!bhT0!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54579461-ca2c-437c-b580-97d74195c1ad_906x476.png 1272w, https://substackcdn.com/image/fetch/$s_!bhT0!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54579461-ca2c-437c-b580-97d74195c1ad_906x476.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!bhT0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54579461-ca2c-437c-b580-97d74195c1ad_906x476.png" width="906" height="476" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/54579461-ca2c-437c-b580-97d74195c1ad_906x476.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:476,&quot;width&quot;:906,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:83674,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/170958851?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54579461-ca2c-437c-b580-97d74195c1ad_906x476.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!bhT0!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54579461-ca2c-437c-b580-97d74195c1ad_906x476.png 424w, https://substackcdn.com/image/fetch/$s_!bhT0!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54579461-ca2c-437c-b580-97d74195c1ad_906x476.png 848w, https://substackcdn.com/image/fetch/$s_!bhT0!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54579461-ca2c-437c-b580-97d74195c1ad_906x476.png 1272w, https://substackcdn.com/image/fetch/$s_!bhT0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F54579461-ca2c-437c-b580-97d74195c1ad_906x476.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Now whenever the MoodExtractor needs to access the <code>JournalEntry</code>, it can send in the JournalEntry&#8217;s <code>PersistentIdentifier</code> and get back the proxy <code>JournalEntryInfo</code> object with the required information for making the API call in a safe way. We can write the <code>getJournalEntryInfo</code> as follows: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!FGiR!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4334322-c706-4a26-9402-cb96a945ef1e_1914x992.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!FGiR!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4334322-c706-4a26-9402-cb96a945ef1e_1914x992.png 424w, https://substackcdn.com/image/fetch/$s_!FGiR!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4334322-c706-4a26-9402-cb96a945ef1e_1914x992.png 848w, https://substackcdn.com/image/fetch/$s_!FGiR!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4334322-c706-4a26-9402-cb96a945ef1e_1914x992.png 1272w, https://substackcdn.com/image/fetch/$s_!FGiR!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4334322-c706-4a26-9402-cb96a945ef1e_1914x992.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!FGiR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4334322-c706-4a26-9402-cb96a945ef1e_1914x992.png" width="1456" height="755" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a4334322-c706-4a26-9402-cb96a945ef1e_1914x992.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:755,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:262222,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/170958851?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4334322-c706-4a26-9402-cb96a945ef1e_1914x992.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!FGiR!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4334322-c706-4a26-9402-cb96a945ef1e_1914x992.png 424w, https://substackcdn.com/image/fetch/$s_!FGiR!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4334322-c706-4a26-9402-cb96a945ef1e_1914x992.png 848w, https://substackcdn.com/image/fetch/$s_!FGiR!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4334322-c706-4a26-9402-cb96a945ef1e_1914x992.png 1272w, https://substackcdn.com/image/fetch/$s_!FGiR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4334322-c706-4a26-9402-cb96a945ef1e_1914x992.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Finally, when the API returns back the mood of the journal entry, we can add a way to update the identified <code>JournalEntry</code> with the mood: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!q8p5!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec6ccf83-d879-4cf7-84a6-b2f37792fabc_1904x836.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!q8p5!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec6ccf83-d879-4cf7-84a6-b2f37792fabc_1904x836.png 424w, https://substackcdn.com/image/fetch/$s_!q8p5!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec6ccf83-d879-4cf7-84a6-b2f37792fabc_1904x836.png 848w, https://substackcdn.com/image/fetch/$s_!q8p5!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec6ccf83-d879-4cf7-84a6-b2f37792fabc_1904x836.png 1272w, https://substackcdn.com/image/fetch/$s_!q8p5!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec6ccf83-d879-4cf7-84a6-b2f37792fabc_1904x836.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!q8p5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec6ccf83-d879-4cf7-84a6-b2f37792fabc_1904x836.png" width="1456" height="639" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ec6ccf83-d879-4cf7-84a6-b2f37792fabc_1904x836.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:639,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:242130,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/170958851?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec6ccf83-d879-4cf7-84a6-b2f37792fabc_1904x836.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!q8p5!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec6ccf83-d879-4cf7-84a6-b2f37792fabc_1904x836.png 424w, https://substackcdn.com/image/fetch/$s_!q8p5!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec6ccf83-d879-4cf7-84a6-b2f37792fabc_1904x836.png 848w, https://substackcdn.com/image/fetch/$s_!q8p5!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec6ccf83-d879-4cf7-84a6-b2f37792fabc_1904x836.png 1272w, https://substackcdn.com/image/fetch/$s_!q8p5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec6ccf83-d879-4cf7-84a6-b2f37792fabc_1904x836.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>That&#8217;s it! Just with a few lines of code, the <code>JournalEntryActor</code> will safely retrieve, update, and save SwiftData models in a thread-safe way IN THE BACKGROUND!</p><h2>The Mood Extractor</h2><p>The <code>MoodExtractor</code> will be triggered to run in the background to extract the mood of the journal entry when the user clicks on the Save button after finishing editing their journal entry. So we can get the model container at the initialization (coming from SwiftUI), and use it to initialized the <code>JournalEntryActor</code>:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!tMi3!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9975b6af-1cc4-42a6-b81f-06beb41a4eae_1858x568.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!tMi3!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9975b6af-1cc4-42a6-b81f-06beb41a4eae_1858x568.png 424w, https://substackcdn.com/image/fetch/$s_!tMi3!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9975b6af-1cc4-42a6-b81f-06beb41a4eae_1858x568.png 848w, https://substackcdn.com/image/fetch/$s_!tMi3!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9975b6af-1cc4-42a6-b81f-06beb41a4eae_1858x568.png 1272w, https://substackcdn.com/image/fetch/$s_!tMi3!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9975b6af-1cc4-42a6-b81f-06beb41a4eae_1858x568.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!tMi3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9975b6af-1cc4-42a6-b81f-06beb41a4eae_1858x568.png" width="1456" height="445" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9975b6af-1cc4-42a6-b81f-06beb41a4eae_1858x568.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:445,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:164383,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/170958851?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9975b6af-1cc4-42a6-b81f-06beb41a4eae_1858x568.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!tMi3!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9975b6af-1cc4-42a6-b81f-06beb41a4eae_1858x568.png 424w, https://substackcdn.com/image/fetch/$s_!tMi3!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9975b6af-1cc4-42a6-b81f-06beb41a4eae_1858x568.png 848w, https://substackcdn.com/image/fetch/$s_!tMi3!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9975b6af-1cc4-42a6-b81f-06beb41a4eae_1858x568.png 1272w, https://substackcdn.com/image/fetch/$s_!tMi3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9975b6af-1cc4-42a6-b81f-06beb41a4eae_1858x568.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Now we can easily use the <code>journalEntryActor</code> to update our <code>extractMood</code> function to be completely thread-safe!</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!NdT0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbab2778e-b8e7-4ae5-b0ab-6d765fd30358_2254x804.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!NdT0!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbab2778e-b8e7-4ae5-b0ab-6d765fd30358_2254x804.png 424w, https://substackcdn.com/image/fetch/$s_!NdT0!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbab2778e-b8e7-4ae5-b0ab-6d765fd30358_2254x804.png 848w, https://substackcdn.com/image/fetch/$s_!NdT0!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbab2778e-b8e7-4ae5-b0ab-6d765fd30358_2254x804.png 1272w, https://substackcdn.com/image/fetch/$s_!NdT0!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbab2778e-b8e7-4ae5-b0ab-6d765fd30358_2254x804.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!NdT0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbab2778e-b8e7-4ae5-b0ab-6d765fd30358_2254x804.png" width="1456" height="519" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bab2778e-b8e7-4ae5-b0ab-6d765fd30358_2254x804.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:519,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:411919,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/170958851?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbab2778e-b8e7-4ae5-b0ab-6d765fd30358_2254x804.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!NdT0!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbab2778e-b8e7-4ae5-b0ab-6d765fd30358_2254x804.png 424w, https://substackcdn.com/image/fetch/$s_!NdT0!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbab2778e-b8e7-4ae5-b0ab-6d765fd30358_2254x804.png 848w, https://substackcdn.com/image/fetch/$s_!NdT0!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbab2778e-b8e7-4ae5-b0ab-6d765fd30358_2254x804.png 1272w, https://substackcdn.com/image/fetch/$s_!NdT0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbab2778e-b8e7-4ae5-b0ab-6d765fd30358_2254x804.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h2>Using the MoodExtractor in SwiftUI</h2><p>When the user clicks on &#8220;Save&#8221; after editing the entry, the <code>extractMood</code> function can be called in a detached (background task): </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!mr-e!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a59b612-6dc9-4084-abbf-33ee12fc6e06_1594x1106.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!mr-e!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a59b612-6dc9-4084-abbf-33ee12fc6e06_1594x1106.png 424w, https://substackcdn.com/image/fetch/$s_!mr-e!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a59b612-6dc9-4084-abbf-33ee12fc6e06_1594x1106.png 848w, https://substackcdn.com/image/fetch/$s_!mr-e!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a59b612-6dc9-4084-abbf-33ee12fc6e06_1594x1106.png 1272w, https://substackcdn.com/image/fetch/$s_!mr-e!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a59b612-6dc9-4084-abbf-33ee12fc6e06_1594x1106.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!mr-e!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a59b612-6dc9-4084-abbf-33ee12fc6e06_1594x1106.png" width="1456" height="1010" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9a59b612-6dc9-4084-abbf-33ee12fc6e06_1594x1106.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1010,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:368937,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/170958851?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a59b612-6dc9-4084-abbf-33ee12fc6e06_1594x1106.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!mr-e!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a59b612-6dc9-4084-abbf-33ee12fc6e06_1594x1106.png 424w, https://substackcdn.com/image/fetch/$s_!mr-e!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a59b612-6dc9-4084-abbf-33ee12fc6e06_1594x1106.png 848w, https://substackcdn.com/image/fetch/$s_!mr-e!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a59b612-6dc9-4084-abbf-33ee12fc6e06_1594x1106.png 1272w, https://substackcdn.com/image/fetch/$s_!mr-e!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9a59b612-6dc9-4084-abbf-33ee12fc6e06_1594x1106.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>To make sure the result is updated in real-time on the UI, make sure to use the SwiftData Query macro, in our case to list out the journal entries: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!FaRI!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a6f728a-161c-48db-a884-cd4fd053a97a_1446x794.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!FaRI!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a6f728a-161c-48db-a884-cd4fd053a97a_1446x794.png 424w, https://substackcdn.com/image/fetch/$s_!FaRI!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a6f728a-161c-48db-a884-cd4fd053a97a_1446x794.png 848w, https://substackcdn.com/image/fetch/$s_!FaRI!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a6f728a-161c-48db-a884-cd4fd053a97a_1446x794.png 1272w, https://substackcdn.com/image/fetch/$s_!FaRI!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a6f728a-161c-48db-a884-cd4fd053a97a_1446x794.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!FaRI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a6f728a-161c-48db-a884-cd4fd053a97a_1446x794.png" width="1446" height="794" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0a6f728a-161c-48db-a884-cd4fd053a97a_1446x794.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:794,&quot;width&quot;:1446,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:242125,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/170958851?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a6f728a-161c-48db-a884-cd4fd053a97a_1446x794.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!FaRI!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a6f728a-161c-48db-a884-cd4fd053a97a_1446x794.png 424w, https://substackcdn.com/image/fetch/$s_!FaRI!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a6f728a-161c-48db-a884-cd4fd053a97a_1446x794.png 848w, https://substackcdn.com/image/fetch/$s_!FaRI!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a6f728a-161c-48db-a884-cd4fd053a97a_1446x794.png 1272w, https://substackcdn.com/image/fetch/$s_!FaRI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a6f728a-161c-48db-a884-cd4fd053a97a_1446x794.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>The journal entries will automatically update with the mood as soon as they are saved in the background by the <code>JournalEntryActor</code>! </p><p>That&#8217;s it! It&#8217;s a bit of overhead in the architecture to go between the Model / ModelActor / Background API / SwiftUI, but this makes sure your code is SAFE and reactive! Oh - and all of this can be done in Swift 5 as well (you can architect your code in this same way without the Swift 6 warnings to force you!). </p><p>Have thoughts? Let me know in the comments!</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.natashatherobot.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">This Substack is reader-supported. To receive new posts and support my work, consider becoming a free or paid subscriber.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p></p>]]></content:encoded></item><item><title><![CDATA[How to Recreate the Dynamic Toolbar from Apple's Messages App in iOS 26 ]]></title><description><![CDATA[Your toolbar no longer has to be static... Add menus, change the top and bottom toolbar buttons on demand!]]></description><link>https://www.natashatherobot.com/p/dynamic-toolbar-apple-messages-ios26</link><guid isPermaLink="false">https://www.natashatherobot.com/p/dynamic-toolbar-apple-messages-ios26</guid><dc:creator><![CDATA[NatashaTheRobot]]></dc:creator><pubDate>Sat, 09 Aug 2025 06:34:21 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!oDY2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43b8f984-9e58-4d49-80cd-d0b6f03fde27_370x438.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>If you&#8217;re using the iOS 26 Beta on your iPhone, you might have noticed that the toolbar (both top and bottom) can become super dynamic. The best way to learn about the new UI is to check out Apple&#8217;s own apps and try to recreate them. So in this blog post, this is exactly what I try to do for the Messages app. Here is the fun result:</p><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;5acb6587-d3ad-4767-98fd-625b37041c34&quot;,&quot;duration&quot;:null}"></div><p>Let&#8217;s build it!</p>
      <p>
          <a href="https://www.natashatherobot.com/p/dynamic-toolbar-apple-messages-ios26">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[How to make Buttons more Glass-y in iOS 26]]></title><description><![CDATA[Use this one weird trick to make your glass buttons look super cool... in dark mode &#128526;]]></description><link>https://www.natashatherobot.com/p/buttons-glass-ios26</link><guid isPermaLink="false">https://www.natashatherobot.com/p/buttons-glass-ios26</guid><dc:creator><![CDATA[NatashaTheRobot]]></dc:creator><pubDate>Sat, 09 Aug 2025 01:44:43 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/b08bb680-ca41-434d-b523-960b0990ea55_252x224.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>One of the things that have disappointed me a bit was how the glass-style buttons didn&#8217;t look too glassy if you have a simple black / white background that is not scrolling. For example, let&#8217;s take this simple glass button with an orange tint: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Zmxy!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07ffb822-9f66-4b70-87a7-1826029d1b15_754x566.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Zmxy!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07ffb822-9f66-4b70-87a7-1826029d1b15_754x566.png 424w, https://substackcdn.com/image/fetch/$s_!Zmxy!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07ffb822-9f66-4b70-87a7-1826029d1b15_754x566.png 848w, https://substackcdn.com/image/fetch/$s_!Zmxy!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07ffb822-9f66-4b70-87a7-1826029d1b15_754x566.png 1272w, https://substackcdn.com/image/fetch/$s_!Zmxy!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07ffb822-9f66-4b70-87a7-1826029d1b15_754x566.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Zmxy!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07ffb822-9f66-4b70-87a7-1826029d1b15_754x566.png" width="754" height="566" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/07ffb822-9f66-4b70-87a7-1826029d1b15_754x566.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:566,&quot;width&quot;:754,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:128213,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/170423005?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07ffb822-9f66-4b70-87a7-1826029d1b15_754x566.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Zmxy!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07ffb822-9f66-4b70-87a7-1826029d1b15_754x566.png 424w, https://substackcdn.com/image/fetch/$s_!Zmxy!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07ffb822-9f66-4b70-87a7-1826029d1b15_754x566.png 848w, https://substackcdn.com/image/fetch/$s_!Zmxy!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07ffb822-9f66-4b70-87a7-1826029d1b15_754x566.png 1272w, https://substackcdn.com/image/fetch/$s_!Zmxy!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07ffb822-9f66-4b70-87a7-1826029d1b15_754x566.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p> It just looks like any other orange button: </p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!7c8f!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76a2e7a5-aa75-4063-9922-2e5eb106c434_232x182.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!7c8f!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76a2e7a5-aa75-4063-9922-2e5eb106c434_232x182.png 424w, https://substackcdn.com/image/fetch/$s_!7c8f!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76a2e7a5-aa75-4063-9922-2e5eb106c434_232x182.png 848w, https://substackcdn.com/image/fetch/$s_!7c8f!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76a2e7a5-aa75-4063-9922-2e5eb106c434_232x182.png 1272w, https://substackcdn.com/image/fetch/$s_!7c8f!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76a2e7a5-aa75-4063-9922-2e5eb106c434_232x182.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!7c8f!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76a2e7a5-aa75-4063-9922-2e5eb106c434_232x182.png" width="232" height="182" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/76a2e7a5-aa75-4063-9922-2e5eb106c434_232x182.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:182,&quot;width&quot;:232,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:12152,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/170423005?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76a2e7a5-aa75-4063-9922-2e5eb106c434_232x182.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!7c8f!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76a2e7a5-aa75-4063-9922-2e5eb106c434_232x182.png 424w, https://substackcdn.com/image/fetch/$s_!7c8f!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76a2e7a5-aa75-4063-9922-2e5eb106c434_232x182.png 848w, https://substackcdn.com/image/fetch/$s_!7c8f!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76a2e7a5-aa75-4063-9922-2e5eb106c434_232x182.png 1272w, https://substackcdn.com/image/fetch/$s_!7c8f!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76a2e7a5-aa75-4063-9922-2e5eb106c434_232x182.png 1456w" sizes="100vw"></picture><div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ps4T!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff9dfefe-6337-4dd4-9729-0da8bfc6a920_208x166.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ps4T!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff9dfefe-6337-4dd4-9729-0da8bfc6a920_208x166.png 424w, https://substackcdn.com/image/fetch/$s_!ps4T!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff9dfefe-6337-4dd4-9729-0da8bfc6a920_208x166.png 848w, https://substackcdn.com/image/fetch/$s_!ps4T!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff9dfefe-6337-4dd4-9729-0da8bfc6a920_208x166.png 1272w, https://substackcdn.com/image/fetch/$s_!ps4T!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff9dfefe-6337-4dd4-9729-0da8bfc6a920_208x166.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ps4T!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff9dfefe-6337-4dd4-9729-0da8bfc6a920_208x166.png" width="208" height="166" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ff9dfefe-6337-4dd4-9729-0da8bfc6a920_208x166.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:166,&quot;width&quot;:208,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:15948,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/170423005?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff9dfefe-6337-4dd4-9729-0da8bfc6a920_208x166.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ps4T!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff9dfefe-6337-4dd4-9729-0da8bfc6a920_208x166.png 424w, https://substackcdn.com/image/fetch/$s_!ps4T!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff9dfefe-6337-4dd4-9729-0da8bfc6a920_208x166.png 848w, https://substackcdn.com/image/fetch/$s_!ps4T!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff9dfefe-6337-4dd4-9729-0da8bfc6a920_208x166.png 1272w, https://substackcdn.com/image/fetch/$s_!ps4T!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff9dfefe-6337-4dd4-9729-0da8bfc6a920_208x166.png 1456w" sizes="100vw"></picture><div></div></div></a></figure></div><p>Only when I click on it, I can see some glass effect&#8230;</p><p>I just assumed this would be fixed over time, or maybe I was not getting something&#8230; and when I tried one simple trick, it did actually work! But only in dark mode&#8230; </p><p>The key is to put an opacity on the button tint: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!z9oe!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd203d931-c3c4-4af6-8688-6a6281aec5b4_1184x614.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!z9oe!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd203d931-c3c4-4af6-8688-6a6281aec5b4_1184x614.png 424w, https://substackcdn.com/image/fetch/$s_!z9oe!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd203d931-c3c4-4af6-8688-6a6281aec5b4_1184x614.png 848w, https://substackcdn.com/image/fetch/$s_!z9oe!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd203d931-c3c4-4af6-8688-6a6281aec5b4_1184x614.png 1272w, https://substackcdn.com/image/fetch/$s_!z9oe!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd203d931-c3c4-4af6-8688-6a6281aec5b4_1184x614.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!z9oe!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd203d931-c3c4-4af6-8688-6a6281aec5b4_1184x614.png" width="1184" height="614" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d203d931-c3c4-4af6-8688-6a6281aec5b4_1184x614.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:614,&quot;width&quot;:1184,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:162000,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/170423005?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd203d931-c3c4-4af6-8688-6a6281aec5b4_1184x614.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!z9oe!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd203d931-c3c4-4af6-8688-6a6281aec5b4_1184x614.png 424w, https://substackcdn.com/image/fetch/$s_!z9oe!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd203d931-c3c4-4af6-8688-6a6281aec5b4_1184x614.png 848w, https://substackcdn.com/image/fetch/$s_!z9oe!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd203d931-c3c4-4af6-8688-6a6281aec5b4_1184x614.png 1272w, https://substackcdn.com/image/fetch/$s_!z9oe!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd203d931-c3c4-4af6-8688-6a6281aec5b4_1184x614.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>This works really well in dark mode:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!dpg3!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe12bec3b-6c61-4709-82da-a84c23d1ec6f_216x184.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!dpg3!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe12bec3b-6c61-4709-82da-a84c23d1ec6f_216x184.png 424w, https://substackcdn.com/image/fetch/$s_!dpg3!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe12bec3b-6c61-4709-82da-a84c23d1ec6f_216x184.png 848w, https://substackcdn.com/image/fetch/$s_!dpg3!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe12bec3b-6c61-4709-82da-a84c23d1ec6f_216x184.png 1272w, https://substackcdn.com/image/fetch/$s_!dpg3!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe12bec3b-6c61-4709-82da-a84c23d1ec6f_216x184.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!dpg3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe12bec3b-6c61-4709-82da-a84c23d1ec6f_216x184.png" width="216" height="184" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e12bec3b-6c61-4709-82da-a84c23d1ec6f_216x184.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:184,&quot;width&quot;:216,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:12321,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/170423005?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe12bec3b-6c61-4709-82da-a84c23d1ec6f_216x184.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!dpg3!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe12bec3b-6c61-4709-82da-a84c23d1ec6f_216x184.png 424w, https://substackcdn.com/image/fetch/$s_!dpg3!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe12bec3b-6c61-4709-82da-a84c23d1ec6f_216x184.png 848w, https://substackcdn.com/image/fetch/$s_!dpg3!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe12bec3b-6c61-4709-82da-a84c23d1ec6f_216x184.png 1272w, https://substackcdn.com/image/fetch/$s_!dpg3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe12bec3b-6c61-4709-82da-a84c23d1ec6f_216x184.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>But not as great in light mode (this is why I set the opacity to higher in light mode, it just washes out if it&#8217;s too high): </p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!kvCy!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12dee229-9b45-48b0-b521-6d0a88a934d0_176x156.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!kvCy!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12dee229-9b45-48b0-b521-6d0a88a934d0_176x156.png 424w, https://substackcdn.com/image/fetch/$s_!kvCy!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12dee229-9b45-48b0-b521-6d0a88a934d0_176x156.png 848w, https://substackcdn.com/image/fetch/$s_!kvCy!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12dee229-9b45-48b0-b521-6d0a88a934d0_176x156.png 1272w, https://substackcdn.com/image/fetch/$s_!kvCy!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12dee229-9b45-48b0-b521-6d0a88a934d0_176x156.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!kvCy!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12dee229-9b45-48b0-b521-6d0a88a934d0_176x156.png" width="176" height="156" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/12dee229-9b45-48b0-b521-6d0a88a934d0_176x156.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:156,&quot;width&quot;:176,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:14290,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/170423005?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12dee229-9b45-48b0-b521-6d0a88a934d0_176x156.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!kvCy!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12dee229-9b45-48b0-b521-6d0a88a934d0_176x156.png 424w, https://substackcdn.com/image/fetch/$s_!kvCy!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12dee229-9b45-48b0-b521-6d0a88a934d0_176x156.png 848w, https://substackcdn.com/image/fetch/$s_!kvCy!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12dee229-9b45-48b0-b521-6d0a88a934d0_176x156.png 1272w, https://substackcdn.com/image/fetch/$s_!kvCy!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F12dee229-9b45-48b0-b521-6d0a88a934d0_176x156.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Anyway, it does look too cool in dark mode! So this is something to play around with when creating glass effect views - make sure to add the opacity to the tint but test it out in dark and light modes! </p><p>Again, this might have been obvious to others, but I just assumed that <code>glassEffect</code> would automatically look like the orange button with the 0.5 opacity above and it just didn&#8217;t. So sharing it just in case others had the same misconception. </p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.natashatherobot.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">This Substack is reader-supported. To receive new posts and support my work, consider becoming a free or paid subscriber.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Using the FoundationModels Framework for Streaming from external LLM providers]]></title><description><![CDATA[In Xcode 26 Beta 4, we can use GeneratedContent with json to stream responses from external LLM providers, such as OpenAI, Anthropic, Gemini and more!]]></description><link>https://www.natashatherobot.com/p/foundationmodels-streaming-external-llm</link><guid isPermaLink="false">https://www.natashatherobot.com/p/foundationmodels-streaming-external-llm</guid><dc:creator><![CDATA[NatashaTheRobot]]></dc:creator><pubDate>Mon, 04 Aug 2025 03:15:32 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!jkYQ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8247ed45-4232-44ca-97e3-df47cb49feeb_1740x1362.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>It&#8217;s no argument that the FoundationModels framework design is absolutely brilliant. But given the actual model&#8217;s limitations (e.g. extremely limited supported languages, small context window, etc), it cannot be used for many use-cases and apps. And especially for more complex use-cases, most apps that want to integrate LLMs will continue to rely on external LLM providers such as OpenAI, Anthropic, Gemini, etc. </p><p>So I was extremely excited to see <a href="https://x.com/_julianschiavo/status/1947713632676278741">this X post from @_julianschiavo</a> announcing that we can now use the same FoundationModels API design to work with external LLM providers! </p><p>In this post, I&#8217;ll walk you through how to do this to build an AI-powered Financial Analyst app using the Perplexity API for searching through company-specific financial data. </p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.natashatherobot.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">This Substack is reader-supported. To receive new posts and support my work, consider becoming a free or paid subscriber.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><h2>The AI-powered Financial Analyst App</h2><p>The Financial Analyst app is simple - the user can simply choose from a list of companies they want financial reports on, include the time range for that financial information, and ask any custom questions if they&#8217;d like. </p><p>The Perplexity API is then used to get back a structured response, which is streamed as new tokens come in and the UI is built with the latest streamed generation: </p><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;d753b7a2-1f20-419a-aea9-2a8f22332864&quot;,&quot;duration&quot;:null}"></div><p>So how do we build this? </p><h2>Streaming the Perplexity API Response</h2><p>Streaming an API response line-by-line has been available in iOS APIs through <code>AsyncThrowingStream</code> for some time, so this part is as simple as this: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!jkYQ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8247ed45-4232-44ca-97e3-df47cb49feeb_1740x1362.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!jkYQ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8247ed45-4232-44ca-97e3-df47cb49feeb_1740x1362.png 424w, https://substackcdn.com/image/fetch/$s_!jkYQ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8247ed45-4232-44ca-97e3-df47cb49feeb_1740x1362.png 848w, https://substackcdn.com/image/fetch/$s_!jkYQ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8247ed45-4232-44ca-97e3-df47cb49feeb_1740x1362.png 1272w, https://substackcdn.com/image/fetch/$s_!jkYQ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8247ed45-4232-44ca-97e3-df47cb49feeb_1740x1362.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!jkYQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8247ed45-4232-44ca-97e3-df47cb49feeb_1740x1362.png" width="1456" height="1140" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8247ed45-4232-44ca-97e3-df47cb49feeb_1740x1362.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1140,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:426020,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/169986201?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8247ed45-4232-44ca-97e3-df47cb49feeb_1740x1362.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!jkYQ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8247ed45-4232-44ca-97e3-df47cb49feeb_1740x1362.png 424w, https://substackcdn.com/image/fetch/$s_!jkYQ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8247ed45-4232-44ca-97e3-df47cb49feeb_1740x1362.png 848w, https://substackcdn.com/image/fetch/$s_!jkYQ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8247ed45-4232-44ca-97e3-df47cb49feeb_1740x1362.png 1272w, https://substackcdn.com/image/fetch/$s_!jkYQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8247ed45-4232-44ca-97e3-df47cb49feeb_1740x1362.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Notice that the stream will return back the json string from the response. </p><p>I won&#8217;t go deeper into the prompt and other specific variables that are used to make the streaming request as this is just the basics of building an API call, but you can <a href="https://github.com/trySwiftAI/FinancialAnalyst/blob/main/FinancialAnalyst/API/PerplexityClient.swift">view the full PerplexityClient code here</a>. </p><p>I&#8217;ll just point out the json schema that is passed to the Perplexity API as this is what we expect to get returned as a structured json response from the model: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!m_T5!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48e0e380-0d58-43ca-9658-6dcd5b2031df_1912x850.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!m_T5!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48e0e380-0d58-43ca-9658-6dcd5b2031df_1912x850.png 424w, https://substackcdn.com/image/fetch/$s_!m_T5!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48e0e380-0d58-43ca-9658-6dcd5b2031df_1912x850.png 848w, https://substackcdn.com/image/fetch/$s_!m_T5!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48e0e380-0d58-43ca-9658-6dcd5b2031df_1912x850.png 1272w, https://substackcdn.com/image/fetch/$s_!m_T5!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48e0e380-0d58-43ca-9658-6dcd5b2031df_1912x850.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!m_T5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48e0e380-0d58-43ca-9658-6dcd5b2031df_1912x850.png" width="1456" height="647" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/48e0e380-0d58-43ca-9658-6dcd5b2031df_1912x850.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:647,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:325726,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/169986201?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48e0e380-0d58-43ca-9658-6dcd5b2031df_1912x850.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!m_T5!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48e0e380-0d58-43ca-9658-6dcd5b2031df_1912x850.png 424w, https://substackcdn.com/image/fetch/$s_!m_T5!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48e0e380-0d58-43ca-9658-6dcd5b2031df_1912x850.png 848w, https://substackcdn.com/image/fetch/$s_!m_T5!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48e0e380-0d58-43ca-9658-6dcd5b2031df_1912x850.png 1272w, https://substackcdn.com/image/fetch/$s_!m_T5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48e0e380-0d58-43ca-9658-6dcd5b2031df_1912x850.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h2>Using Generable Types for Decoding</h2><p>Normally we would be creating <code>Codable</code> objects to decode the API response, but now we can simply use the <code>Generable</code> type from the FoundationModels framework instead!</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!eH4I!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c9fc9dd-d723-476c-a40a-6f7da423b99f_1000x466.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!eH4I!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c9fc9dd-d723-476c-a40a-6f7da423b99f_1000x466.png 424w, https://substackcdn.com/image/fetch/$s_!eH4I!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c9fc9dd-d723-476c-a40a-6f7da423b99f_1000x466.png 848w, https://substackcdn.com/image/fetch/$s_!eH4I!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c9fc9dd-d723-476c-a40a-6f7da423b99f_1000x466.png 1272w, https://substackcdn.com/image/fetch/$s_!eH4I!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c9fc9dd-d723-476c-a40a-6f7da423b99f_1000x466.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!eH4I!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c9fc9dd-d723-476c-a40a-6f7da423b99f_1000x466.png" width="1000" height="466" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6c9fc9dd-d723-476c-a40a-6f7da423b99f_1000x466.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:466,&quot;width&quot;:1000,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:123456,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/169986201?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c9fc9dd-d723-476c-a40a-6f7da423b99f_1000x466.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!eH4I!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c9fc9dd-d723-476c-a40a-6f7da423b99f_1000x466.png 424w, https://substackcdn.com/image/fetch/$s_!eH4I!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c9fc9dd-d723-476c-a40a-6f7da423b99f_1000x466.png 848w, https://substackcdn.com/image/fetch/$s_!eH4I!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c9fc9dd-d723-476c-a40a-6f7da423b99f_1000x466.png 1272w, https://substackcdn.com/image/fetch/$s_!eH4I!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c9fc9dd-d723-476c-a40a-6f7da423b99f_1000x466.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!5X1n!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9c1517b-9ea8-41b0-be16-249a9a160468_628x1186.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!5X1n!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9c1517b-9ea8-41b0-be16-249a9a160468_628x1186.png 424w, https://substackcdn.com/image/fetch/$s_!5X1n!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9c1517b-9ea8-41b0-be16-249a9a160468_628x1186.png 848w, https://substackcdn.com/image/fetch/$s_!5X1n!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9c1517b-9ea8-41b0-be16-249a9a160468_628x1186.png 1272w, https://substackcdn.com/image/fetch/$s_!5X1n!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9c1517b-9ea8-41b0-be16-249a9a160468_628x1186.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!5X1n!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9c1517b-9ea8-41b0-be16-249a9a160468_628x1186.png" width="628" height="1186" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b9c1517b-9ea8-41b0-be16-249a9a160468_628x1186.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1186,&quot;width&quot;:628,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:223089,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/169986201?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9c1517b-9ea8-41b0-be16-249a9a160468_628x1186.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!5X1n!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9c1517b-9ea8-41b0-be16-249a9a160468_628x1186.png 424w, https://substackcdn.com/image/fetch/$s_!5X1n!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9c1517b-9ea8-41b0-be16-249a9a160468_628x1186.png 848w, https://substackcdn.com/image/fetch/$s_!5X1n!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9c1517b-9ea8-41b0-be16-249a9a160468_628x1186.png 1272w, https://substackcdn.com/image/fetch/$s_!5X1n!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb9c1517b-9ea8-41b0-be16-249a9a160468_628x1186.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>The <code>Generable</code> type is now <code>Codable</code> by default, so it just works! But one issue is that as of now (Xcode 26 Beta 4), you cannot add <code>CodingKeys</code>. This means that if the api returns snake case (e.g. search_results), you cannot add a CodingKey to use <code>searchResults</code> as a variable. You have to name each variable EXACTLY how they are in the API response. </p><h2>Generating a Generable Object from JSON</h2><p>When the Perplexity API returns back the response, the structured output we requested with our json schema, which corresponds to the Generable <code>Analysis</code> object above will be returned simply as a json string in the assistant message content.</p><p>However, here is the problem&#8230; the json response will be generated one token at a time: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!yAFI!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd0fb27d-8e55-4074-806f-427e374512af_2216x1394.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!yAFI!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd0fb27d-8e55-4074-806f-427e374512af_2216x1394.png 424w, https://substackcdn.com/image/fetch/$s_!yAFI!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd0fb27d-8e55-4074-806f-427e374512af_2216x1394.png 848w, https://substackcdn.com/image/fetch/$s_!yAFI!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd0fb27d-8e55-4074-806f-427e374512af_2216x1394.png 1272w, https://substackcdn.com/image/fetch/$s_!yAFI!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd0fb27d-8e55-4074-806f-427e374512af_2216x1394.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!yAFI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd0fb27d-8e55-4074-806f-427e374512af_2216x1394.png" width="1456" height="916" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bd0fb27d-8e55-4074-806f-427e374512af_2216x1394.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:916,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:489988,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/169986201?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd0fb27d-8e55-4074-806f-427e374512af_2216x1394.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!yAFI!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd0fb27d-8e55-4074-806f-427e374512af_2216x1394.png 424w, https://substackcdn.com/image/fetch/$s_!yAFI!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd0fb27d-8e55-4074-806f-427e374512af_2216x1394.png 848w, https://substackcdn.com/image/fetch/$s_!yAFI!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd0fb27d-8e55-4074-806f-427e374512af_2216x1394.png 1272w, https://substackcdn.com/image/fetch/$s_!yAFI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd0fb27d-8e55-4074-806f-427e374512af_2216x1394.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>So how can we decode it? This is the magical part! </p><p>First, create a <code>GeneratedContent</code> object from any partial json string!</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!xqlG!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb7080887-3b05-472b-b093-c222c85435db_1470x130.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!xqlG!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb7080887-3b05-472b-b093-c222c85435db_1470x130.png 424w, https://substackcdn.com/image/fetch/$s_!xqlG!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb7080887-3b05-472b-b093-c222c85435db_1470x130.png 848w, https://substackcdn.com/image/fetch/$s_!xqlG!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb7080887-3b05-472b-b093-c222c85435db_1470x130.png 1272w, https://substackcdn.com/image/fetch/$s_!xqlG!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb7080887-3b05-472b-b093-c222c85435db_1470x130.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!xqlG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb7080887-3b05-472b-b093-c222c85435db_1470x130.png" width="1456" height="129" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b7080887-3b05-472b-b093-c222c85435db_1470x130.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:129,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:45540,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/169986201?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb7080887-3b05-472b-b093-c222c85435db_1470x130.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!xqlG!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb7080887-3b05-472b-b093-c222c85435db_1470x130.png 424w, https://substackcdn.com/image/fetch/$s_!xqlG!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb7080887-3b05-472b-b093-c222c85435db_1470x130.png 848w, https://substackcdn.com/image/fetch/$s_!xqlG!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb7080887-3b05-472b-b093-c222c85435db_1470x130.png 1272w, https://substackcdn.com/image/fetch/$s_!xqlG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb7080887-3b05-472b-b093-c222c85435db_1470x130.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Then pass that generated object into the Generable object that the json represents: </p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!JQEC!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc5f7cc74-8877-4c98-915f-e33ae44a4d0c_732x94.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!JQEC!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc5f7cc74-8877-4c98-915f-e33ae44a4d0c_732x94.png 424w, https://substackcdn.com/image/fetch/$s_!JQEC!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc5f7cc74-8877-4c98-915f-e33ae44a4d0c_732x94.png 848w, https://substackcdn.com/image/fetch/$s_!JQEC!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc5f7cc74-8877-4c98-915f-e33ae44a4d0c_732x94.png 1272w, https://substackcdn.com/image/fetch/$s_!JQEC!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc5f7cc74-8877-4c98-915f-e33ae44a4d0c_732x94.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!JQEC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc5f7cc74-8877-4c98-915f-e33ae44a4d0c_732x94.png" width="732" height="94" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c5f7cc74-8877-4c98-915f-e33ae44a4d0c_732x94.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:94,&quot;width&quot;:732,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:26085,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/169986201?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc5f7cc74-8877-4c98-915f-e33ae44a4d0c_732x94.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!JQEC!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc5f7cc74-8877-4c98-915f-e33ae44a4d0c_732x94.png 424w, https://substackcdn.com/image/fetch/$s_!JQEC!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc5f7cc74-8877-4c98-915f-e33ae44a4d0c_732x94.png 848w, https://substackcdn.com/image/fetch/$s_!JQEC!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc5f7cc74-8877-4c98-915f-e33ae44a4d0c_732x94.png 1272w, https://substackcdn.com/image/fetch/$s_!JQEC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc5f7cc74-8877-4c98-915f-e33ae44a4d0c_732x94.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>This will start generating the Analysis as soon as any of the information from the partial json string comes in and can be parsed!</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!MDWO!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14697950-3dc5-4ab4-895b-c2e4281a2c05_2506x172.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!MDWO!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14697950-3dc5-4ab4-895b-c2e4281a2c05_2506x172.png 424w, https://substackcdn.com/image/fetch/$s_!MDWO!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14697950-3dc5-4ab4-895b-c2e4281a2c05_2506x172.png 848w, https://substackcdn.com/image/fetch/$s_!MDWO!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14697950-3dc5-4ab4-895b-c2e4281a2c05_2506x172.png 1272w, https://substackcdn.com/image/fetch/$s_!MDWO!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14697950-3dc5-4ab4-895b-c2e4281a2c05_2506x172.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!MDWO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14697950-3dc5-4ab4-895b-c2e4281a2c05_2506x172.png" width="1456" height="100" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/14697950-3dc5-4ab4-895b-c2e4281a2c05_2506x172.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:100,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:48008,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/169986201?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14697950-3dc5-4ab4-895b-c2e4281a2c05_2506x172.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!MDWO!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14697950-3dc5-4ab4-895b-c2e4281a2c05_2506x172.png 424w, https://substackcdn.com/image/fetch/$s_!MDWO!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14697950-3dc5-4ab4-895b-c2e4281a2c05_2506x172.png 848w, https://substackcdn.com/image/fetch/$s_!MDWO!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14697950-3dc5-4ab4-895b-c2e4281a2c05_2506x172.png 1272w, https://substackcdn.com/image/fetch/$s_!MDWO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F14697950-3dc5-4ab4-895b-c2e4281a2c05_2506x172.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>For example, here the company name came in, so now the company is available!</p><p>The final result to get an analysis object from the API response is as follows: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ciIC!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63d9d8e8-f4e5-4e59-bc12-c6f9bcb57869_1804x944.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ciIC!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63d9d8e8-f4e5-4e59-bc12-c6f9bcb57869_1804x944.png 424w, https://substackcdn.com/image/fetch/$s_!ciIC!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63d9d8e8-f4e5-4e59-bc12-c6f9bcb57869_1804x944.png 848w, https://substackcdn.com/image/fetch/$s_!ciIC!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63d9d8e8-f4e5-4e59-bc12-c6f9bcb57869_1804x944.png 1272w, https://substackcdn.com/image/fetch/$s_!ciIC!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63d9d8e8-f4e5-4e59-bc12-c6f9bcb57869_1804x944.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ciIC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63d9d8e8-f4e5-4e59-bc12-c6f9bcb57869_1804x944.png" width="1456" height="762" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/63d9d8e8-f4e5-4e59-bc12-c6f9bcb57869_1804x944.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:762,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:290418,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/169986201?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63d9d8e8-f4e5-4e59-bc12-c6f9bcb57869_1804x944.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ciIC!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63d9d8e8-f4e5-4e59-bc12-c6f9bcb57869_1804x944.png 424w, https://substackcdn.com/image/fetch/$s_!ciIC!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63d9d8e8-f4e5-4e59-bc12-c6f9bcb57869_1804x944.png 848w, https://substackcdn.com/image/fetch/$s_!ciIC!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63d9d8e8-f4e5-4e59-bc12-c6f9bcb57869_1804x944.png 1272w, https://substackcdn.com/image/fetch/$s_!ciIC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F63d9d8e8-f4e5-4e59-bc12-c6f9bcb57869_1804x944.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>In the same way, to generate the <code>GeneratedFinancialAnalysis</code> object, we will pass in the json response from the Perplexity response stream every time it comes in: </p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Voqp!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffda23bf8-d6c1-4e1f-85d4-ff91b471526e_1858x148.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Voqp!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffda23bf8-d6c1-4e1f-85d4-ff91b471526e_1858x148.png 424w, https://substackcdn.com/image/fetch/$s_!Voqp!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffda23bf8-d6c1-4e1f-85d4-ff91b471526e_1858x148.png 848w, https://substackcdn.com/image/fetch/$s_!Voqp!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffda23bf8-d6c1-4e1f-85d4-ff91b471526e_1858x148.png 1272w, https://substackcdn.com/image/fetch/$s_!Voqp!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffda23bf8-d6c1-4e1f-85d4-ff91b471526e_1858x148.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Voqp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffda23bf8-d6c1-4e1f-85d4-ff91b471526e_1858x148.png" width="1456" height="116" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fda23bf8-d6c1-4e1f-85d4-ff91b471526e_1858x148.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:116,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:90047,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/169986201?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffda23bf8-d6c1-4e1f-85d4-ff91b471526e_1858x148.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Voqp!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffda23bf8-d6c1-4e1f-85d4-ff91b471526e_1858x148.png 424w, https://substackcdn.com/image/fetch/$s_!Voqp!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffda23bf8-d6c1-4e1f-85d4-ff91b471526e_1858x148.png 848w, https://substackcdn.com/image/fetch/$s_!Voqp!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffda23bf8-d6c1-4e1f-85d4-ff91b471526e_1858x148.png 1272w, https://substackcdn.com/image/fetch/$s_!Voqp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffda23bf8-d6c1-4e1f-85d4-ff91b471526e_1858x148.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>This will generate the current version of the Analysis object from the partial json string!</p><h2>Updating the UI</h2><p>Live-updating the UI as the stream comes in with more and more information each time is as simple as just updating the <code>generatedAnalysis</code> State variable every time the new response with additional data comes in through the stream: </p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!zSzS!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F650f3336-e0b3-4b0f-8716-4fe9d81017e9_1510x114.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!zSzS!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F650f3336-e0b3-4b0f-8716-4fe9d81017e9_1510x114.png 424w, https://substackcdn.com/image/fetch/$s_!zSzS!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F650f3336-e0b3-4b0f-8716-4fe9d81017e9_1510x114.png 848w, https://substackcdn.com/image/fetch/$s_!zSzS!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F650f3336-e0b3-4b0f-8716-4fe9d81017e9_1510x114.png 1272w, https://substackcdn.com/image/fetch/$s_!zSzS!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F650f3336-e0b3-4b0f-8716-4fe9d81017e9_1510x114.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!zSzS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F650f3336-e0b3-4b0f-8716-4fe9d81017e9_1510x114.png" width="1456" height="110" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/650f3336-e0b3-4b0f-8716-4fe9d81017e9_1510x114.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:110,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:50229,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/169986201?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F650f3336-e0b3-4b0f-8716-4fe9d81017e9_1510x114.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!zSzS!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F650f3336-e0b3-4b0f-8716-4fe9d81017e9_1510x114.png 424w, https://substackcdn.com/image/fetch/$s_!zSzS!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F650f3336-e0b3-4b0f-8716-4fe9d81017e9_1510x114.png 848w, https://substackcdn.com/image/fetch/$s_!zSzS!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F650f3336-e0b3-4b0f-8716-4fe9d81017e9_1510x114.png 1272w, https://substackcdn.com/image/fetch/$s_!zSzS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F650f3336-e0b3-4b0f-8716-4fe9d81017e9_1510x114.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Simply <code>performAnalysis</code> when the view loads:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!HxS4!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0683bf33-c4c4-4849-b176-c1140de5a261_530x156.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!HxS4!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0683bf33-c4c4-4849-b176-c1140de5a261_530x156.png 424w, https://substackcdn.com/image/fetch/$s_!HxS4!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0683bf33-c4c4-4849-b176-c1140de5a261_530x156.png 848w, https://substackcdn.com/image/fetch/$s_!HxS4!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0683bf33-c4c4-4849-b176-c1140de5a261_530x156.png 1272w, https://substackcdn.com/image/fetch/$s_!HxS4!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0683bf33-c4c4-4849-b176-c1140de5a261_530x156.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!HxS4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0683bf33-c4c4-4849-b176-c1140de5a261_530x156.png" width="530" height="156" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0683bf33-c4c4-4849-b176-c1140de5a261_530x156.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:156,&quot;width&quot;:530,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:23297,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/169986201?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0683bf33-c4c4-4849-b176-c1140de5a261_530x156.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!HxS4!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0683bf33-c4c4-4849-b176-c1140de5a261_530x156.png 424w, https://substackcdn.com/image/fetch/$s_!HxS4!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0683bf33-c4c4-4849-b176-c1140de5a261_530x156.png 848w, https://substackcdn.com/image/fetch/$s_!HxS4!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0683bf33-c4c4-4849-b176-c1140de5a261_530x156.png 1272w, https://substackcdn.com/image/fetch/$s_!HxS4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0683bf33-c4c4-4849-b176-c1140de5a261_530x156.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>And keep replacing the <code>generatedAnalysis</code> variable with the latest version. Here is the full <code>performAnalysis</code> function: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!cmro!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd05d85f6-cfc6-4ddf-9e21-cc4ef35ff6ce_1550x1380.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!cmro!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd05d85f6-cfc6-4ddf-9e21-cc4ef35ff6ce_1550x1380.png 424w, https://substackcdn.com/image/fetch/$s_!cmro!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd05d85f6-cfc6-4ddf-9e21-cc4ef35ff6ce_1550x1380.png 848w, https://substackcdn.com/image/fetch/$s_!cmro!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd05d85f6-cfc6-4ddf-9e21-cc4ef35ff6ce_1550x1380.png 1272w, https://substackcdn.com/image/fetch/$s_!cmro!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd05d85f6-cfc6-4ddf-9e21-cc4ef35ff6ce_1550x1380.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!cmro!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd05d85f6-cfc6-4ddf-9e21-cc4ef35ff6ce_1550x1380.png" width="1456" height="1296" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d05d85f6-cfc6-4ddf-9e21-cc4ef35ff6ce_1550x1380.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1296,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:360758,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/169986201?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd05d85f6-cfc6-4ddf-9e21-cc4ef35ff6ce_1550x1380.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!cmro!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd05d85f6-cfc6-4ddf-9e21-cc4ef35ff6ce_1550x1380.png 424w, https://substackcdn.com/image/fetch/$s_!cmro!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd05d85f6-cfc6-4ddf-9e21-cc4ef35ff6ce_1550x1380.png 848w, https://substackcdn.com/image/fetch/$s_!cmro!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd05d85f6-cfc6-4ddf-9e21-cc4ef35ff6ce_1550x1380.png 1272w, https://substackcdn.com/image/fetch/$s_!cmro!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd05d85f6-cfc6-4ddf-9e21-cc4ef35ff6ce_1550x1380.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>You can <a href="https://github.com/trySwiftAI/FinancialAnalyst/blob/main/FinancialAnalyst/Views/AnalysisView/AnalysisView.swift">view the full AnalysisView code here</a>. </p><h2>Conclusion</h2><p>That&#8217;s it! It only takes a few steps to use the Generable macro from the FoundationModels framework to create an impressive streaming experience with external LLM providers. </p><p>Simply: </p><ul><li><p>Stream the LLM Provider API response as a json string</p></li><li><p>Use Generable types for decoding the json</p></li><li><p>Update the UI to the latest streamed generable object</p></li></ul><p>The FoundationModels team once again does an impressive job with allowing us to use the same developer experience for external models! </p><p>Now, back to building &#129299;</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.natashatherobot.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">This Substack is reader-supported. To receive new posts and support my work, consider becoming a free or paid subscriber.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>P.S. - The full code for the Financial Analyst app is <a href="https://github.com/trySwiftAI/FinancialAnalyst/tree/main">available on Github here</a>.</p><p></p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!PMmG!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7377b05-1dc1-4b95-a26b-9254f1b50f13_728x90.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!PMmG!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7377b05-1dc1-4b95-a26b-9254f1b50f13_728x90.png 424w, https://substackcdn.com/image/fetch/$s_!PMmG!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7377b05-1dc1-4b95-a26b-9254f1b50f13_728x90.png 848w, https://substackcdn.com/image/fetch/$s_!PMmG!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7377b05-1dc1-4b95-a26b-9254f1b50f13_728x90.png 1272w, https://substackcdn.com/image/fetch/$s_!PMmG!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7377b05-1dc1-4b95-a26b-9254f1b50f13_728x90.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!PMmG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7377b05-1dc1-4b95-a26b-9254f1b50f13_728x90.png" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e7377b05-1dc1-4b95-a26b-9254f1b50f13_728x90.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:null,&quot;width&quot;:null,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:25785,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/169986201?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7377b05-1dc1-4b95-a26b-9254f1b50f13_728x90.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!PMmG!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7377b05-1dc1-4b95-a26b-9254f1b50f13_728x90.png 424w, https://substackcdn.com/image/fetch/$s_!PMmG!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7377b05-1dc1-4b95-a26b-9254f1b50f13_728x90.png 848w, https://substackcdn.com/image/fetch/$s_!PMmG!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7377b05-1dc1-4b95-a26b-9254f1b50f13_728x90.png 1272w, https://substackcdn.com/image/fetch/$s_!PMmG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe7377b05-1dc1-4b95-a26b-9254f1b50f13_728x90.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div>]]></content:encoded></item><item><title><![CDATA[Let's build the Apple Music iOS 26 Tab Bar in Liquid Glass]]></title><description><![CDATA[The Apple Music app in iOS26 goes all-in in showing what the new Tab Bar can do with the new Liquid Glass design.]]></description><link>https://www.natashatherobot.com/p/apple-music-ios-26-tab-bar-liquid-glass</link><guid isPermaLink="false">https://www.natashatherobot.com/p/apple-music-ios-26-tab-bar-liquid-glass</guid><dc:creator><![CDATA[NatashaTheRobot]]></dc:creator><pubDate>Mon, 28 Jul 2025 13:56:15 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!3gj6!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50457ce6-d8bc-44c4-865b-0ea37228e631_1206x396.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>The Apple Music app in iOS26 goes all-in in showing what the new Tab Bar can do with the new Liquid Glass design. It has many super cool behaviors. </p><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;6834904d-d638-4fd5-8639-89128de3ce1e&quot;,&quot;duration&quot;:null}"></div><p>So how can we build it?!! Let&#8217;s get started!</p>
      <p>
          <a href="https://www.natashatherobot.com/p/apple-music-ios-26-tab-bar-liquid-glass">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[The FoundationModels framework is broken in Beta 4]]></title><description><![CDATA[This may not be a good two weeks to test with the FoundationModels framework...]]></description><link>https://www.natashatherobot.com/p/the-foundationmodels-framework-is</link><guid isPermaLink="false">https://www.natashatherobot.com/p/the-foundationmodels-framework-is</guid><dc:creator><![CDATA[NatashaTheRobot]]></dc:creator><pubDate>Sun, 27 Jul 2025 03:00:06 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!9ODO!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F947fc914-a270-40bd-a723-ec71eb309350_1640x1150.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>While I&#8217;ve been loving experimenting and thinking about use-cases for the new <code>FoundationModels</code> framework, I was a bit taken back by it after Beta 4 came out. Suddenly it stopped following instructions as well, it wouldn&#8217;t &#8220;remember&#8221; what I said in the previous message and would ask me again for the same information, the guardrails would be over triggered by anything, and most importantly, it essentially stopped calling my Tools. Instead, it would reply back with a message saying something like: </p><blockquote><p>I will now call this tool</p><p>[TOOL CALL + PARAMETERS]</p><p>Ok, I called the tool and this is the result!</p></blockquote><p>In other words, it hallucinated calling my tools with the right parameters without ever calling the tools&#8230; And when it sometimes did trigger a tool call, I would get a <code>LangaugeModelSession.GenerationError.decodingFailure</code> error. </p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.natashatherobot.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">This Substack is reader-supported. To receive new posts and support my work, consider becoming a free or paid subscriber.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>I asked about this on X, and a few people told me to look in the <a href="https://developer.apple.com/documentation/ios-ipados-release-notes/ios-ipados-26-release-notes">iOS release notes</a>. Ok, my fault for not looking before, but I just kept thinking that I was doing something wrong. Here is what the release notes say in the Foundation Models framework section: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!9ODO!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F947fc914-a270-40bd-a723-ec71eb309350_1640x1150.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!9ODO!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F947fc914-a270-40bd-a723-ec71eb309350_1640x1150.png 424w, https://substackcdn.com/image/fetch/$s_!9ODO!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F947fc914-a270-40bd-a723-ec71eb309350_1640x1150.png 848w, https://substackcdn.com/image/fetch/$s_!9ODO!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F947fc914-a270-40bd-a723-ec71eb309350_1640x1150.png 1272w, https://substackcdn.com/image/fetch/$s_!9ODO!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F947fc914-a270-40bd-a723-ec71eb309350_1640x1150.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!9ODO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F947fc914-a270-40bd-a723-ec71eb309350_1640x1150.png" width="1456" height="1021" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/947fc914-a270-40bd-a723-ec71eb309350_1640x1150.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1021,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:335436,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/169346815?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F947fc914-a270-40bd-a723-ec71eb309350_1640x1150.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!9ODO!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F947fc914-a270-40bd-a723-ec71eb309350_1640x1150.png 424w, https://substackcdn.com/image/fetch/$s_!9ODO!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F947fc914-a270-40bd-a723-ec71eb309350_1640x1150.png 848w, https://substackcdn.com/image/fetch/$s_!9ODO!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F947fc914-a270-40bd-a723-ec71eb309350_1640x1150.png 1272w, https://substackcdn.com/image/fetch/$s_!9ODO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F947fc914-a270-40bd-a723-ec71eb309350_1640x1150.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Wow - &#8220;Tool calling might not function properly if primitive types such as <code>Int</code>, <code>String</code>, or <code>Bool</code> are used as the argument&#8221;?!!!! </p><p>The workaround that seems to work, is by setting the <code>includeSchemaInPrompt</code> to <code>false</code> when asking the model to respond to a message (which also requires that the generating type is set) as follows:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ZbSg!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fafb8b1c6-922d-4095-9784-6048a5b0b8b5_1258x268.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ZbSg!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fafb8b1c6-922d-4095-9784-6048a5b0b8b5_1258x268.png 424w, https://substackcdn.com/image/fetch/$s_!ZbSg!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fafb8b1c6-922d-4095-9784-6048a5b0b8b5_1258x268.png 848w, https://substackcdn.com/image/fetch/$s_!ZbSg!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fafb8b1c6-922d-4095-9784-6048a5b0b8b5_1258x268.png 1272w, https://substackcdn.com/image/fetch/$s_!ZbSg!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fafb8b1c6-922d-4095-9784-6048a5b0b8b5_1258x268.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ZbSg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fafb8b1c6-922d-4095-9784-6048a5b0b8b5_1258x268.png" width="1258" height="268" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/afb8b1c6-922d-4095-9784-6048a5b0b8b5_1258x268.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:268,&quot;width&quot;:1258,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:90795,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/169346815?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fafb8b1c6-922d-4095-9784-6048a5b0b8b5_1258x268.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ZbSg!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fafb8b1c6-922d-4095-9784-6048a5b0b8b5_1258x268.png 424w, https://substackcdn.com/image/fetch/$s_!ZbSg!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fafb8b1c6-922d-4095-9784-6048a5b0b8b5_1258x268.png 848w, https://substackcdn.com/image/fetch/$s_!ZbSg!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fafb8b1c6-922d-4095-9784-6048a5b0b8b5_1258x268.png 1272w, https://substackcdn.com/image/fetch/$s_!ZbSg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fafb8b1c6-922d-4095-9784-6048a5b0b8b5_1258x268.png 1456w" sizes="100vw"></picture><div></div></div></a></figure></div><p>If using this, make sure to include a sample response in the model instructions so it knows which schema you expect. </p><p>But the biggest issue here is that the team felt pressured to ship this for Beta 4. I know it&#8217;s a Beta, but we won&#8217;t get to the next Beta for maybe another 2 weeks, and the fact that the team is willing to ship this broken version of the FoundationModels framework even when the previous version was working fine without giving developers option to set the model to the previous version just really breaks the trust with the FoundationModels framework. Imagine you have an app in production, and the team knowingly ships these type of breaking changes?!! </p><p>When the FoundationModels framework just came out it had that &#8220;wow, it just works&#8221; feel. Yes, the on-device model has extreme limitations, but it was good at tool calling and what it advertised. And the framework design itself is incredible. But now that feeling is gone and is instead replaced by &#8220;wow, hope it works&#8221; with uncertainty about the future. </p><p>I like to keep more positive, but I think it&#8217;s also important to point out these type of risks of incorporating the FoundationModels framework into your app super early on. And for anyone who&#8217;s been struggling like me with Beta 4 thinking it&#8217;s your fault, it&#8217;s not your fault! </p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.natashatherobot.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">This Substack is reader-supported. To receive new posts and support my work, consider becoming a free or paid subscriber.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Natural Language Search with Apple's FoundationsModels framework Part 2: Using Tools]]></title><description><![CDATA[Learn how to use Apple's FoundationModels framework to parse user input into powerful filters for real-estate listings.]]></description><link>https://www.natashatherobot.com/p/natural-language-search-foundationmodels-framework-tools</link><guid isPermaLink="false">https://www.natashatherobot.com/p/natural-language-search-foundationmodels-framework-tools</guid><dc:creator><![CDATA[NatashaTheRobot]]></dc:creator><pubDate>Tue, 08 Jul 2025 05:20:55 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!H7vC!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6214c24c-e07f-468c-96c2-dece9496a304_1972x610.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Previously, I wrote <a href="https://www.natashatherobot.com/p/natural-language-search-foundationmodels-framework">Natural Language Search with Apple's FoundationsModels framework?!</a>, which explores Apple&#8217;s FoundationModels ability to find the correct answer when given a mix of natural language options. For example, if the model is given 5 real-estate listings, can it figure out which of the 5 matches the user&#8217;s query (e.g. pet-friendly)? TLDR - not surprisingly, this DID NOT work well and truly showed the limitations of this model. </p><p>Today, I&#8217;m going to explore one alternative that does work well for this use-case. The key is to stop thinking of the FoundationModel as &#8220;intelligent&#8221; and think of it more as a natural language parser. Then build sophisticated tools that can take in parameters parsed by the model. </p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.natashatherobot.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">This Substack is reader-supported. To receive new posts and support my work, consider becoming a free or paid subscriber.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>So let&#8217;s get started!</p><h2>Having a Comprehensive DataSet</h2><p>The most difficult part of the this example is making sure you have a comprehensive dataset that can anticipate most of what the user is looking for. In the case of real-estate, these datasets already exist, but they can further be enhanced by running Python scripts in combination with much bigger and better models such as Google Gemini Pro to further take out extra non-standard parameters. </p><p>I wrote a few blog posts about pre-processing your data here:  </p><ul><li><p><a href="https://www.natashatherobot.com/p/preprocessing-using-llms">The Case for Preprocessing: Using LLMs Before Your Users Do</a></p></li><li><p><a href="https://www.natashatherobot.com/p/openai-batch-api">How to Work with OpenAI's Batch API (not in Swift!)</a></p></li><li><p><a href="https://www.natashatherobot.com/p/building-a-sanskrit-dictionary-app-ai">Building a Sanskrit Dictionary App: An AI-Powered Retrospective</a></p></li></ul><p>Let&#8217;s assume I have a comprehensive real-estate backend, which will translate to the following <code>HouseListing</code> object in Swift: </p><pre><code>import Foundation
import FoundationModels

@Generable
struct HouseListing {
    
    // MARK: - Basic Property Details
    let id: String
    let title: String
    let description: String
    
    let address: String
    let priceInUSD: Double
    let squareFootage: Int
    let lotSizeInAcres: Double
    let yearBuilt: Int
    
    // MARK: - Bedrooms &amp; Bathrooms
    let numberOfBedrooms: Int
    let numberOfBathrooms: Double
    let hasMasterSuite: Bool
    let hasGuestBedroom: Bool
    
    // MARK: - Parking &amp; Garage
    let hasGarage: Bool
    let numberOfGarageSpaces: Int
    let hasDriveway: Bool
    let hasCarport: Bool
    let streetParking: Bool
    
    // MARK: - Outdoor Features
    let hasPool: Bool
    let hasHotTub: Bool
    let hasBackyard: Bool
    let hasFrontYard: Bool
    let hasGarden: Bool
    let hasDeck: Bool
    let hasPatio: Bool
    let hasBalcony: Bool
    let hasFirepit: Bool
    let hasOutdoorKitchen: Bool
    
    // MARK: - Indoor Features
    let hasFireplace: Bool
    let hasBasement: Bool
    let hasAttic: Bool
    let hasWalkInCloset: Bool
    let hasLaundryRoom: Bool
    let hasHomeOffice: Bool
    let hasLibrary: Bool
    let hasWinecellar: Bool
    let hasPantry: Bool
    let hasGameRoom: Bool
    let hasHomeGym: Bool
    let hasHomeTheater: Bool
    
    // MARK: - Kitchen Features
    let hasUpdatedKitchen: Bool
    let hasKitchenIsland: Bool
    let hasGraniteCountertops: Bool
    let hasStainlessAppliances: Bool
    let hasGasStove: Bool
    let hasDoubleOven: Bool
    let hasWalkInPantry: Bool
    
    // MARK: - Flooring &amp; Interior
    let hasHardwoodFloors: Bool
    let hasCarpeting: Bool
    let hasTileFlooring: Bool
    let hasMarbleFlooring: Bool
    let hasVaultedCeilings: Bool
    let hasOpenFloorPlan: Bool
    let hasCrownMolding: Bool
    
    // MARK: - Utilities &amp; Systems
    let hasCentralAC: Bool
    let hasCentralHeating: Bool
    let hasWasherDryer: Bool
    let hasSecuritySystem: Bool
    let hasSmartHome: Bool
    let hasSolarPanels: Bool
    let hasBackupGenerator: Bool
    
    // MARK: - Accessibility
    let isWheelchairAccessible: Bool
    let hasSingleStoryLiving: Bool
    let hasElevator: Bool
    let hasWideDoorways: Bool
    let hasAccessibleBathroom: Bool
    
    // MARK: - Pet-Friendly Features
    let isPetFriendly: Bool
    let hasDogRun: Bool
    let hasFencedYard: Bool
    let allowsCats: Bool
    let allowsDogs: Bool
    let allowsLargePets: Bool
    let hasBuiltInPetFeatures: Bool
    
    // MARK: - Neighborhood &amp; Location
    let nearPublicTransit: Bool
    let nearSchools: Bool
    let nearShopping: Bool
    let nearRestaurants: Bool
    let nearHospitals: Bool
    let nearHikingTrails: Bool
    let nearBeach: Bool
    let nearPark: Bool
    let nearGolfCourse: Bool
    let nearAirport: Bool
    let isInGatedCommunity: Bool
    let hasHOA: Bool
    let hoaFee: Double?
    
    // MARK: - School Districts
    let schoolDistrict: String
    let elementarySchoolRating: Int? // 1-10
    let middleSchoolRating: Int? // 1-10
    let highSchoolRating: Int? // 1-10
    let nearPrivateSchools: Bool
    
    // MARK: - Safety &amp; Security
    let hasNeighborhoodWatch: Bool
    let hasSecurityGates: Bool
    let hasMotionLights: Bool
    let hasRingDoorbell: Bool
    
    // MARK: - Investment &amp; Financial
    let hasRentalPotential: Bool
    let propertyTaxRate: Double
    let appreciationRate: Double
    let isFixerUpper: Bool
    let isNewConstruction: Bool
    let hasWarranty: Bool
    
    // MARK: - Seasonal &amp; Climate
    let hasGoodInsulation: Bool
    let hasStormShelter: Bool
    let hasGoodDrainage: Bool
    
    // MARK: - Community Features
    let hasCommunityPool: Bool
    let hasClubhouse: Bool
    let hasTennisCourtAccess: Bool
    let hasGymAccess: Bool
    let hasPlaygroundNearby: Bool
    let hasWalkingTrails: Bool
    
    // MARK: - Technology &amp; Modern Features
    let hasFiberInternet: Bool
    let hasSmartThermostat: Bool
    let hasElectricCarCharger: Bool
    let hasSmartLighting: Bool
    let hasVoiceControl: Bool
    
    // MARK: - Environmental
    let hasEcoFriendlyFeatures: Bool
    let hasEnergyEfficientAppliances: Bool
    let hasLEDLighting: Bool
    let hasRainwaterCollection: Bool
    let hasCompostArea: Bool
    
    // MARK: - Maintenance &amp; Condition
    let hasRecentRenovations: Bool
    let needsRepairs: Bool
    let hasMaintenanceContract: Bool
}</code></pre><p>How can we work with this using the FoundationModels framework? </p><h2>The Goal</h2><p>Our <code>HouseListing</code> has soooo much detail that it will quickly overwhelm the user to see all of them at ones. Instead, we can build a chat-based interface where the user can simply search for houses based on the criteria that matter to them specifically.</p><p>This means that we need to translate what the user is searching for in a house in natural language to match the variables in the <code>HouseListing</code> object, that we can use as a filter for houses matching the user&#8217;s query.</p><p>For example, when the user searches for &#8220;<strong>pet friendly houses near hiking trails</strong>&#8221;, we want to filter our <code>HouseListing</code> to only return houses where the <code>isPetFriendly</code> and <code>nearHikingTrails</code> variables are set to <code>true</code>. </p><h2>Creating a Housing Search Tool</h2><p>To create a <code>Tool</code> using the FoundationModels framework 3 things are required: </p><ol><li><p>Name - A unique name for the tool</p></li><li><p>Description - A natural language description of when and how to use the tool</p></li><li><p>The Call function - A language model will call this method when it wants to leverage this tool.</p></li></ol><p>Let&#8217;s get started with the name and description, the easy parts: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!H7vC!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6214c24c-e07f-468c-96c2-dece9496a304_1972x610.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!H7vC!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6214c24c-e07f-468c-96c2-dece9496a304_1972x610.png 424w, https://substackcdn.com/image/fetch/$s_!H7vC!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6214c24c-e07f-468c-96c2-dece9496a304_1972x610.png 848w, https://substackcdn.com/image/fetch/$s_!H7vC!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6214c24c-e07f-468c-96c2-dece9496a304_1972x610.png 1272w, https://substackcdn.com/image/fetch/$s_!H7vC!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6214c24c-e07f-468c-96c2-dece9496a304_1972x610.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!H7vC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6214c24c-e07f-468c-96c2-dece9496a304_1972x610.png" width="1456" height="450" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6214c24c-e07f-468c-96c2-dece9496a304_1972x610.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:450,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:189302,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167704972?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6214c24c-e07f-468c-96c2-dece9496a304_1972x610.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!H7vC!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6214c24c-e07f-468c-96c2-dece9496a304_1972x610.png 424w, https://substackcdn.com/image/fetch/$s_!H7vC!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6214c24c-e07f-468c-96c2-dece9496a304_1972x610.png 848w, https://substackcdn.com/image/fetch/$s_!H7vC!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6214c24c-e07f-468c-96c2-dece9496a304_1972x610.png 1272w, https://substackcdn.com/image/fetch/$s_!H7vC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6214c24c-e07f-468c-96c2-dece9496a304_1972x610.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Now onto the hard part - the call function&#8230; </p><p>First, we will define the input arguments from the model when calling this function. So when the user types in &#8220;a pet friendly house near hiking trails&#8221;, we would want the model to pass in <code>isPetFriendly = true</code> and <code>nearHikingTrails = true</code> as arguments<code>. </code></p><p>To do this, we first want to specify all the possible filter options as an enum that the model will choose from, which will allow us to filter <code>HouseListings</code>: </p><pre><code>    @Generable
    enum FilterType: String, CaseIterable {
        // Price &amp; Size
        case minPrice = "minPrice"
        case maxPrice = "maxPrice"
        case minSquareFootage = "minSquareFootage"
        case maxSquareFootage = "maxSquareFootage"
        case minLotSize = "minLotSize"
        case maxLotSize = "maxLotSize"
        case minYearBuilt = "minYearBuilt"
        case maxYearBuilt = "maxYearBuilt"
        
        // Bedrooms &amp; Bathrooms
        case numberOfBedrooms = "bedrooms"
        case minBedrooms = "minBedrooms"
        case maxBedrooms = "maxBedrooms"
        case minBathrooms = "minBathrooms"
        case maxBathrooms = "maxBathrooms"
        case hasMasterSuite = "hasMasterSuite"
        case hasGuestBedroom = "hasGuestBedroom"
        
        // Features (Boolean)
        case hasPool = "hasPool"
        case hasGarage = "hasGarage"
        case hasFireplace = "hasFireplace"
        case hasGarden = "hasGarden"
        case hasHomeOffice = "hasHomeOffice"
        case hasSmartHome = "hasSmartHome"
        case hasSolarPanels = "hasSolarPanels"
        case isPetFriendly = "isPetFriendly"
        case hasFencedYard = "hasFencedYard"
        case isWheelchairAccessible = "isWheelchairAccessible"
        case hasSingleStoryLiving = "hasSingleStoryLiving"
        case nearSchools = "nearSchools"
        case nearPublicTransit = "nearPublicTransit"
        case nearHikingTrails = "nearHikingTrails"
        case nearBeach = "nearBeach"
        case nearGolfCourse = "nearGolfCourse"
        case isInGatedCommunity = "isInGatedCommunity"
        case hasRentalPotential = "hasRentalPotential"
        case isFixerUpper = "isFixerUpper"
        case isNewConstruction = "isNewConstruction"
        case hasUpdatedKitchen = "hasUpdatedKitchen"
        case hasKitchenIsland = "hasKitchenIsland"
        case hasHardwoodFloors = "hasHardwoodFloors"
        case hasOpenFloorPlan = "hasOpenFloorPlan"
        case hasCentralAC = "hasCentralAC"
        case hasSecuritySystem = "hasSecuritySystem"
        case hasBackyard = "hasBackyard"
        case hasBalcony = "hasBalcony"
        case hasElevator = "hasElevator"
        case allowsDogs = "allowsDogs"
        case allowsCats = "allowsCats"
        case hasHOA = "hasHOA"
        case hasEcoFriendlyFeatures = "hasEcoFriendlyFeatures"
        
        var description: String {
            switch self {
            case .minPrice: return "Minimum price in USD"
            case .maxPrice: return "Maximum price in USD"
            case .minSquareFootage: return "Minimum square footage"
            case .maxSquareFootage: return "Maximum square footage"
            case .minLotSize: return "Minimum lot size in acres"
            case .maxLotSize: return "Maximum lot size in acres"
            case .minYearBuilt: return "Minimum year built"
            case .maxYearBuilt: return "Maximum year built"
            case .numberOfBedrooms: return "Exact number of bedrooms"
            case .minBedrooms: return "Minimum bedrooms"
            case .maxBedrooms: return "Maximum bedrooms"
            case .minBathrooms: return "Minimum bathrooms"
            case .maxBathrooms: return "Maximum bathrooms"
            case .hasMasterSuite: return "Has master suite"
            case .hasGuestBedroom: return "Has guest bedroom"
            case .hasPool: return "Has swimming pool"
            case .hasGarage: return "Has garage"
            case .hasFireplace: return "Has fireplace"
            case .hasGarden: return "Has garden"
            case .hasHomeOffice: return "Has home office"
            case .hasSmartHome: return "Has smart home features"
            case .hasSolarPanels: return "Has solar panels"
            case .isPetFriendly: return "Pet friendly"
            case .hasFencedYard: return "Has fenced yard"
            case .isWheelchairAccessible: return "Wheelchair accessible"
            case .hasSingleStoryLiving: return "Single story living"
            case .nearSchools: return "Near schools"
            case .nearPublicTransit: return "Near public transit"
            case .nearHikingTrails: return "Near hiking trails"
            case .nearBeach: return "Near beach"
            case .nearGolfCourse: return "Near golf course"
            case .isInGatedCommunity: return "In gated community"
            case .hasRentalPotential: return "Has rental potential"
            case .isFixerUpper: return "Fixer-upper property"
            case .isNewConstruction: return "New construction"
            case .hasUpdatedKitchen: return "Has updated kitchen"
            case .hasKitchenIsland: return "Has kitchen island"
            case .hasHardwoodFloors: return "Has hardwood floors"
            case .hasOpenFloorPlan: return "Has open floor plan"
            case .hasCentralAC: return "Has central air conditioning"
            case .hasSecuritySystem: return "Has security system"
            case .hasBackyard: return "Has backyard"
            case .hasBalcony: return "Has balcony"
            case .hasElevator: return "Has elevator"
            case .allowsDogs: return "Allows dogs"
            case .allowsCats: return "Allows cats"
            case .hasHOA: return "Has HOA"
            case .hasEcoFriendlyFeatures: return "Has eco-friendly features"
            }
        }
    }</code></pre><p>When the model passes in the <code>FilterType</code>, we would also want a value for this type (e.g. true / false), and a description of the filter - this is more for the model to &#8220;think&#8221; through using this filter: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!1KAU!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cb292b3-a6cd-4963-aa3f-9aba629182d4_1878x608.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!1KAU!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cb292b3-a6cd-4963-aa3f-9aba629182d4_1878x608.png 424w, https://substackcdn.com/image/fetch/$s_!1KAU!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cb292b3-a6cd-4963-aa3f-9aba629182d4_1878x608.png 848w, https://substackcdn.com/image/fetch/$s_!1KAU!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cb292b3-a6cd-4963-aa3f-9aba629182d4_1878x608.png 1272w, https://substackcdn.com/image/fetch/$s_!1KAU!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cb292b3-a6cd-4963-aa3f-9aba629182d4_1878x608.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!1KAU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cb292b3-a6cd-4963-aa3f-9aba629182d4_1878x608.png" width="1456" height="471" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3cb292b3-a6cd-4963-aa3f-9aba629182d4_1878x608.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:471,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:248849,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167704972?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cb292b3-a6cd-4963-aa3f-9aba629182d4_1878x608.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!1KAU!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cb292b3-a6cd-4963-aa3f-9aba629182d4_1878x608.png 424w, https://substackcdn.com/image/fetch/$s_!1KAU!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cb292b3-a6cd-4963-aa3f-9aba629182d4_1878x608.png 848w, https://substackcdn.com/image/fetch/$s_!1KAU!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cb292b3-a6cd-4963-aa3f-9aba629182d4_1878x608.png 1272w, https://substackcdn.com/image/fetch/$s_!1KAU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cb292b3-a6cd-4963-aa3f-9aba629182d4_1878x608.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Finally, our <code>Arguments</code> parameter for the call function will include an array of <code>FilterSpecifications</code> and a way for the model to reset all filters (for example if the user says &#8220;Forget that, I want to start fresh. Let&#8217;s look for houses with pools only&#8221;. </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!EReE!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F814c8c05-8153-46d2-9501-f2760e7b0c00_1792x620.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!EReE!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F814c8c05-8153-46d2-9501-f2760e7b0c00_1792x620.png 424w, https://substackcdn.com/image/fetch/$s_!EReE!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F814c8c05-8153-46d2-9501-f2760e7b0c00_1792x620.png 848w, https://substackcdn.com/image/fetch/$s_!EReE!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F814c8c05-8153-46d2-9501-f2760e7b0c00_1792x620.png 1272w, https://substackcdn.com/image/fetch/$s_!EReE!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F814c8c05-8153-46d2-9501-f2760e7b0c00_1792x620.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!EReE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F814c8c05-8153-46d2-9501-f2760e7b0c00_1792x620.png" width="1456" height="504" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/814c8c05-8153-46d2-9501-f2760e7b0c00_1792x620.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:504,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:231630,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167704972?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F814c8c05-8153-46d2-9501-f2760e7b0c00_1792x620.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!EReE!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F814c8c05-8153-46d2-9501-f2760e7b0c00_1792x620.png 424w, https://substackcdn.com/image/fetch/$s_!EReE!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F814c8c05-8153-46d2-9501-f2760e7b0c00_1792x620.png 848w, https://substackcdn.com/image/fetch/$s_!EReE!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F814c8c05-8153-46d2-9501-f2760e7b0c00_1792x620.png 1272w, https://substackcdn.com/image/fetch/$s_!EReE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F814c8c05-8153-46d2-9501-f2760e7b0c00_1792x620.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Note that the arguments input for the call function can be any <code>Generable</code> object defined in your Tool. </p><h2>State Management with Tools</h2><p>One of very interesting implementation details of the genius FoundationModels framework is that the <code>LanguageModelSession</code> will take in an instance of a tool that it will use throughout it&#8217;s lifecycle. That means Tools can keep state! </p><p>As the user continues their conversation with the language model, more filters will be added. For example, in the first message the user may say they want a house with a pool. When the model responds with filtered houses that have pools, the user may then try to narrow it down to houses that are also pet friendly, etc. </p><p>Ideally, the model should be able to take in the full context of the entire conversation and understand that the user wants a house with a pool that is also pet friendly and include these two filters (<code>hasPool = true</code>, and <code>isPetFriendly=true)</code> when calling the tool. But unfortunately the Foundation Model is just not that sophisticated and can be hit or miss. For example, if you say you want a house with a pool, it will only pass in the <code>hasPool=true</code> filter, &#8220;forgetting&#8221; / not taking into consideration the earlier <code>isPetFriendly=true </code>filter. And this will get worse and worse the longer the conversation and especially with more filters. </p><p>So keeping state is up to you as the developer! In our case, we can instruct the model to only include the new filters from the user input, that will aggregate and keep track of ourselves.</p><p>In our example of a <code>DynamicHousingSearchTool</code>, we want the tool to keep track of two things: </p><ul><li><p>The current active filters </p></li><li><p>The current results matching the active filters</p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!U8kd!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8f7d855-ec55-4d0f-afd7-0a2c3c7a5a66_1278x238.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!U8kd!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8f7d855-ec55-4d0f-afd7-0a2c3c7a5a66_1278x238.png 424w, https://substackcdn.com/image/fetch/$s_!U8kd!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8f7d855-ec55-4d0f-afd7-0a2c3c7a5a66_1278x238.png 848w, https://substackcdn.com/image/fetch/$s_!U8kd!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8f7d855-ec55-4d0f-afd7-0a2c3c7a5a66_1278x238.png 1272w, https://substackcdn.com/image/fetch/$s_!U8kd!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8f7d855-ec55-4d0f-afd7-0a2c3c7a5a66_1278x238.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!U8kd!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8f7d855-ec55-4d0f-afd7-0a2c3c7a5a66_1278x238.png" width="1278" height="238" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a8f7d855-ec55-4d0f-afd7-0a2c3c7a5a66_1278x238.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:238,&quot;width&quot;:1278,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:93485,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167704972?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8f7d855-ec55-4d0f-afd7-0a2c3c7a5a66_1278x238.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!U8kd!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8f7d855-ec55-4d0f-afd7-0a2c3c7a5a66_1278x238.png 424w, https://substackcdn.com/image/fetch/$s_!U8kd!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8f7d855-ec55-4d0f-afd7-0a2c3c7a5a66_1278x238.png 848w, https://substackcdn.com/image/fetch/$s_!U8kd!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8f7d855-ec55-4d0f-afd7-0a2c3c7a5a66_1278x238.png 1272w, https://substackcdn.com/image/fetch/$s_!U8kd!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8f7d855-ec55-4d0f-afd7-0a2c3c7a5a66_1278x238.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>The second reason for keeping state is the model&#8217;s small context window. By having the tool keep the state, you can easily start a new <code>LanguageModelSession</code> using the same instance and continue the house search without the user knowing they&#8217;re in a new chat session as follows:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!__KZ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F88916392-ee3a-4d29-bb8d-2c5024e3f41b_1966x1074.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!__KZ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F88916392-ee3a-4d29-bb8d-2c5024e3f41b_1966x1074.png 424w, https://substackcdn.com/image/fetch/$s_!__KZ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F88916392-ee3a-4d29-bb8d-2c5024e3f41b_1966x1074.png 848w, https://substackcdn.com/image/fetch/$s_!__KZ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F88916392-ee3a-4d29-bb8d-2c5024e3f41b_1966x1074.png 1272w, https://substackcdn.com/image/fetch/$s_!__KZ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F88916392-ee3a-4d29-bb8d-2c5024e3f41b_1966x1074.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!__KZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F88916392-ee3a-4d29-bb8d-2c5024e3f41b_1966x1074.png" width="1456" height="795" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/88916392-ee3a-4d29-bb8d-2c5024e3f41b_1966x1074.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:795,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:448684,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167704972?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F88916392-ee3a-4d29-bb8d-2c5024e3f41b_1966x1074.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!__KZ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F88916392-ee3a-4d29-bb8d-2c5024e3f41b_1966x1074.png 424w, https://substackcdn.com/image/fetch/$s_!__KZ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F88916392-ee3a-4d29-bb8d-2c5024e3f41b_1966x1074.png 848w, https://substackcdn.com/image/fetch/$s_!__KZ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F88916392-ee3a-4d29-bb8d-2c5024e3f41b_1966x1074.png 1272w, https://substackcdn.com/image/fetch/$s_!__KZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F88916392-ee3a-4d29-bb8d-2c5024e3f41b_1966x1074.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h2>Applying the Filter</h2><p>When the model passes in an array of <code>FilterSpecification</code>s as arguments, we can iterate through the filters and apply them by using the <code>FilterType</code> enum: </p><pre><code>private func applyFilter(
        filterType: FilterType,
        value: String,
        to houses: [HouseListing]
    ) -&gt; [HouseListing] {
        
        switch filterType {
        // Numeric filters
        case .minPrice:
            guard let minPrice = Double(value) else { return houses }
            return houses.filter { $0.priceInUSD &gt;= minPrice }
            
        case .maxPrice:
            guard let maxPrice = Double(value) else { return houses }
            return houses.filter { $0.priceInUSD &lt;= maxPrice }
            
        case .minSquareFootage:
            guard let minSqFt = Int(value) else { return houses }
            return houses.filter { $0.squareFootage &gt;= minSqFt }
            
        case .maxSquareFootage:
            guard let maxSqFt = Int(value) else { return houses }
            return houses.filter { $0.squareFootage &lt;= maxSqFt }
            
        case .numberOfBedrooms:
            guard let bedrooms = Int(value) else { return houses }
            return houses.filter { $0.numberOfBedrooms == bedrooms }
            
        case .minBedrooms:
            guard let minBedrooms = Int(value) else { return houses }
            return houses.filter { $0.numberOfBedrooms &gt;= minBedrooms }
            
        case .maxBedrooms:
            guard let maxBedrooms = Int(value) else { return houses }
            return houses.filter { $0.numberOfBedrooms &lt;= maxBedrooms }
            
        case .minBathrooms:
            guard let minBathrooms = Double(value) else { return houses }
            return houses.filter { $0.numberOfBathrooms &gt;= minBathrooms }
            
        case .maxBathrooms:
            guard let maxBathrooms = Double(value) else { return houses }
            return houses.filter { $0.numberOfBathrooms &lt;= maxBathrooms }
            
        case .minLotSize:
            guard let minLot = Double(value) else { return houses }
            return houses.filter { $0.lotSizeInAcres &gt;= minLot }
            
        case .maxLotSize:
            guard let maxLot = Double(value) else { return houses }
            return houses.filter { $0.lotSizeInAcres &lt;= maxLot }
            
        case .minYearBuilt:
            guard let minYear = Int(value) else { return houses }
            return houses.filter { $0.yearBuilt &gt;= minYear }
            
        case .maxYearBuilt:
            guard let maxYear = Int(value) else { return houses }
            return houses.filter { $0.yearBuilt &lt;= maxYear }
            
        // Boolean filters
        case .hasPool:
            let boolValue = value.lowercased() == "true"
            return houses.filter { $0.hasPool == boolValue }
            
        case .hasGarage:
            let boolValue = value.lowercased() == "true"
            return houses.filter { $0.hasGarage == boolValue }
            
        case .hasFireplace:
            let boolValue = value.lowercased() == "true"
            return houses.filter { $0.hasFireplace == boolValue }
            
        case .hasGarden:
            let boolValue = value.lowercased() == "true"
            return houses.filter { $0.hasGarden == boolValue }
            
        case .hasHomeOffice:
            let boolValue = value.lowercased() == "true"
            return houses.filter { $0.hasHomeOffice == boolValue }
            
        case .hasSmartHome:
            let boolValue = value.lowercased() == "true"
            return houses.filter { $0.hasSmartHome == boolValue }
            
        case .hasSolarPanels:
            let boolValue = value.lowercased() == "true"
            return houses.filter { $0.hasSolarPanels == boolValue }
            
        case .isPetFriendly:
            let boolValue = value.lowercased() == "true"
            return houses.filter { $0.isPetFriendly == boolValue }
            
        case .hasFencedYard:
            let boolValue = value.lowercased() == "true"
            return houses.filter { $0.hasFencedYard == boolValue }
            
        case .isWheelchairAccessible:
            let boolValue = value.lowercased() == "true"
            return houses.filter { $0.isWheelchairAccessible == boolValue }
            
        case .hasSingleStoryLiving:
            let boolValue = value.lowercased() == "true"
            return houses.filter { $0.hasSingleStoryLiving == boolValue }
            
        case .nearSchools:
            let boolValue = value.lowercased() == "true"
            return houses.filter { $0.nearSchools == boolValue }
            
        case .nearPublicTransit:
            let boolValue = value.lowercased() == "true"
            return houses.filter { $0.nearPublicTransit == boolValue }
            
        case .nearHikingTrails:
            let boolValue = value.lowercased() == "true"
            return houses.filter { $0.nearHikingTrails == boolValue }
            
        case .nearBeach:
            let boolValue = value.lowercased() == "true"
            return houses.filter { $0.nearBeach == boolValue }
            
        case .nearGolfCourse:
            let boolValue = value.lowercased() == "true"
            return houses.filter { $0.nearGolfCourse == boolValue }
            
        case .isInGatedCommunity:
            let boolValue = value.lowercased() == "true"
            return houses.filter { $0.isInGatedCommunity == boolValue }
            
        case .hasRentalPotential:
            let boolValue = value.lowercased() == "true"
            return houses.filter { $0.hasRentalPotential == boolValue }
            
        case .isFixerUpper:
            let boolValue = value.lowercased() == "true"
            return houses.filter { $0.isFixerUpper == boolValue }
            
        case .isNewConstruction:
            let boolValue = value.lowercased() == "true"
            return houses.filter { $0.isNewConstruction == boolValue }
            
        case .hasUpdatedKitchen:
            let boolValue = value.lowercased() == "true"
            return houses.filter { $0.hasUpdatedKitchen == boolValue }
            
        case .hasKitchenIsland:
            let boolValue = value.lowercased() == "true"
            return houses.filter { $0.hasKitchenIsland == boolValue }
            
        case .hasHardwoodFloors:
            let boolValue = value.lowercased() == "true"
            return houses.filter { $0.hasHardwoodFloors == boolValue }
            
        case .hasOpenFloorPlan:
            let boolValue = value.lowercased() == "true"
            return houses.filter { $0.hasOpenFloorPlan == boolValue }
            
        case .hasCentralAC:
            let boolValue = value.lowercased() == "true"
            return houses.filter { $0.hasCentralAC == boolValue }
            
        case .hasSecuritySystem:
            let boolValue = value.lowercased() == "true"
            return houses.filter { $0.hasSecuritySystem == boolValue }
            
        case .hasBackyard:
            let boolValue = value.lowercased() == "true"
            return houses.filter { $0.hasBackyard == boolValue }
            
        case .hasBalcony:
            let boolValue = value.lowercased() == "true"
            return houses.filter { $0.hasBalcony == boolValue }
            
        case .hasElevator:
            let boolValue = value.lowercased() == "true"
            return houses.filter { $0.hasElevator == boolValue }
            
        case .allowsDogs:
            let boolValue = value.lowercased() == "true"
            return houses.filter { $0.allowsDogs == boolValue }
            
        case .allowsCats:
            let boolValue = value.lowercased() == "true"
            return houses.filter { $0.allowsCats == boolValue }
            
        case .hasHOA:
            let boolValue = value.lowercased() == "true"
            return houses.filter { $0.hasHOA == boolValue }
            
        case .hasEcoFriendlyFeatures:
            let boolValue = value.lowercased() == "true"
            return houses.filter { $0.hasEcoFriendlyFeatures == boolValue }
            
        case .hasMasterSuite:
            let boolValue = value.lowercased() == "true"
            return houses.filter { $0.hasMasterSuite == boolValue }
            
        case .hasGuestBedroom:
            let boolValue = value.lowercased() == "true"
            return houses.filter { $0.hasGuestBedroom == boolValue }
        }
    }</code></pre><h2>Implementing the Call Function</h2><p>The call functions will take in the Arguments that we defined earlier: </p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!rQce!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b1fa012-b5e3-4d1e-98e5-8e353dd9b94e_1798x432.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!rQce!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b1fa012-b5e3-4d1e-98e5-8e353dd9b94e_1798x432.png 424w, https://substackcdn.com/image/fetch/$s_!rQce!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b1fa012-b5e3-4d1e-98e5-8e353dd9b94e_1798x432.png 848w, https://substackcdn.com/image/fetch/$s_!rQce!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b1fa012-b5e3-4d1e-98e5-8e353dd9b94e_1798x432.png 1272w, https://substackcdn.com/image/fetch/$s_!rQce!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b1fa012-b5e3-4d1e-98e5-8e353dd9b94e_1798x432.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!rQce!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b1fa012-b5e3-4d1e-98e5-8e353dd9b94e_1798x432.png" width="1456" height="350" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2b1fa012-b5e3-4d1e-98e5-8e353dd9b94e_1798x432.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:350,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:179389,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167704972?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b1fa012-b5e3-4d1e-98e5-8e353dd9b94e_1798x432.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!rQce!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b1fa012-b5e3-4d1e-98e5-8e353dd9b94e_1798x432.png 424w, https://substackcdn.com/image/fetch/$s_!rQce!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b1fa012-b5e3-4d1e-98e5-8e353dd9b94e_1798x432.png 848w, https://substackcdn.com/image/fetch/$s_!rQce!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b1fa012-b5e3-4d1e-98e5-8e353dd9b94e_1798x432.png 1272w, https://substackcdn.com/image/fetch/$s_!rQce!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b1fa012-b5e3-4d1e-98e5-8e353dd9b94e_1798x432.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>And output a <code>ToolOutput</code> object, which can be initiated with either a <code>String</code> or a <code>GeneratedContent</code> type:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ugvW!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F17699390-0a40-4f04-b742-fdf0edd1b98f_1368x98.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ugvW!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F17699390-0a40-4f04-b742-fdf0edd1b98f_1368x98.png 424w, https://substackcdn.com/image/fetch/$s_!ugvW!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F17699390-0a40-4f04-b742-fdf0edd1b98f_1368x98.png 848w, https://substackcdn.com/image/fetch/$s_!ugvW!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F17699390-0a40-4f04-b742-fdf0edd1b98f_1368x98.png 1272w, https://substackcdn.com/image/fetch/$s_!ugvW!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F17699390-0a40-4f04-b742-fdf0edd1b98f_1368x98.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ugvW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F17699390-0a40-4f04-b742-fdf0edd1b98f_1368x98.png" width="1368" height="98" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/17699390-0a40-4f04-b742-fdf0edd1b98f_1368x98.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:98,&quot;width&quot;:1368,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:42957,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167704972?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F17699390-0a40-4f04-b742-fdf0edd1b98f_1368x98.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ugvW!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F17699390-0a40-4f04-b742-fdf0edd1b98f_1368x98.png 424w, https://substackcdn.com/image/fetch/$s_!ugvW!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F17699390-0a40-4f04-b742-fdf0edd1b98f_1368x98.png 848w, https://substackcdn.com/image/fetch/$s_!ugvW!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F17699390-0a40-4f04-b742-fdf0edd1b98f_1368x98.png 1272w, https://substackcdn.com/image/fetch/$s_!ugvW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F17699390-0a40-4f04-b742-fdf0edd1b98f_1368x98.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>First, if the model passes in true for resetFilters, we reset the state variables: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!yXxj!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9019ae30-7b97-45d0-929c-bd420d17a02f_830x250.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!yXxj!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9019ae30-7b97-45d0-929c-bd420d17a02f_830x250.png 424w, https://substackcdn.com/image/fetch/$s_!yXxj!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9019ae30-7b97-45d0-929c-bd420d17a02f_830x250.png 848w, https://substackcdn.com/image/fetch/$s_!yXxj!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9019ae30-7b97-45d0-929c-bd420d17a02f_830x250.png 1272w, https://substackcdn.com/image/fetch/$s_!yXxj!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9019ae30-7b97-45d0-929c-bd420d17a02f_830x250.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!yXxj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9019ae30-7b97-45d0-929c-bd420d17a02f_830x250.png" width="830" height="250" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9019ae30-7b97-45d0-929c-bd420d17a02f_830x250.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:250,&quot;width&quot;:830,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:58398,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167704972?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9019ae30-7b97-45d0-929c-bd420d17a02f_830x250.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!yXxj!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9019ae30-7b97-45d0-929c-bd420d17a02f_830x250.png 424w, https://substackcdn.com/image/fetch/$s_!yXxj!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9019ae30-7b97-45d0-929c-bd420d17a02f_830x250.png 848w, https://substackcdn.com/image/fetch/$s_!yXxj!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9019ae30-7b97-45d0-929c-bd420d17a02f_830x250.png 1272w, https://substackcdn.com/image/fetch/$s_!yXxj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9019ae30-7b97-45d0-929c-bd420d17a02f_830x250.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Next, we will iterate through each filter and add the new filters to the <code>activeFilters</code> array and filter the <code>currentResults</code>:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!JzaY!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d997648-5643-4493-a273-454d059b7927_1184x844.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!JzaY!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d997648-5643-4493-a273-454d059b7927_1184x844.png 424w, https://substackcdn.com/image/fetch/$s_!JzaY!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d997648-5643-4493-a273-454d059b7927_1184x844.png 848w, https://substackcdn.com/image/fetch/$s_!JzaY!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d997648-5643-4493-a273-454d059b7927_1184x844.png 1272w, https://substackcdn.com/image/fetch/$s_!JzaY!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d997648-5643-4493-a273-454d059b7927_1184x844.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!JzaY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d997648-5643-4493-a273-454d059b7927_1184x844.png" width="1184" height="844" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5d997648-5643-4493-a273-454d059b7927_1184x844.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:844,&quot;width&quot;:1184,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:263412,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167704972?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d997648-5643-4493-a273-454d059b7927_1184x844.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!JzaY!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d997648-5643-4493-a273-454d059b7927_1184x844.png 424w, https://substackcdn.com/image/fetch/$s_!JzaY!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d997648-5643-4493-a273-454d059b7927_1184x844.png 848w, https://substackcdn.com/image/fetch/$s_!JzaY!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d997648-5643-4493-a273-454d059b7927_1184x844.png 1272w, https://substackcdn.com/image/fetch/$s_!JzaY!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5d997648-5643-4493-a273-454d059b7927_1184x844.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>We want to give the new filtered house results back to the Foundation Model to display to the user, but the original <code>HouseListing</code> object is too big and overwhelming both for the model (in tokens) and the user. So we want to create a smaller version of the <code>HouseListing</code> that just includes the most important information. We do this by creating a new Generable <code>HouseResult</code> object: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!4W5Y!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc51175a4-9d33-4403-a4af-5e51f2088b5e_1194x672.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!4W5Y!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc51175a4-9d33-4403-a4af-5e51f2088b5e_1194x672.png 424w, https://substackcdn.com/image/fetch/$s_!4W5Y!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc51175a4-9d33-4403-a4af-5e51f2088b5e_1194x672.png 848w, https://substackcdn.com/image/fetch/$s_!4W5Y!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc51175a4-9d33-4403-a4af-5e51f2088b5e_1194x672.png 1272w, https://substackcdn.com/image/fetch/$s_!4W5Y!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc51175a4-9d33-4403-a4af-5e51f2088b5e_1194x672.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!4W5Y!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc51175a4-9d33-4403-a4af-5e51f2088b5e_1194x672.png" width="1194" height="672" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c51175a4-9d33-4403-a4af-5e51f2088b5e_1194x672.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:672,&quot;width&quot;:1194,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:237678,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167704972?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc51175a4-9d33-4403-a4af-5e51f2088b5e_1194x672.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!4W5Y!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc51175a4-9d33-4403-a4af-5e51f2088b5e_1194x672.png 424w, https://substackcdn.com/image/fetch/$s_!4W5Y!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc51175a4-9d33-4403-a4af-5e51f2088b5e_1194x672.png 848w, https://substackcdn.com/image/fetch/$s_!4W5Y!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc51175a4-9d33-4403-a4af-5e51f2088b5e_1194x672.png 1272w, https://substackcdn.com/image/fetch/$s_!4W5Y!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc51175a4-9d33-4403-a4af-5e51f2088b5e_1194x672.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>We also want to give a custom message about the results for the model: </p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!D7In!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc2ded60-6550-46e1-a43c-b54085ec90de_1610x344.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!D7In!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc2ded60-6550-46e1-a43c-b54085ec90de_1610x344.png 424w, https://substackcdn.com/image/fetch/$s_!D7In!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc2ded60-6550-46e1-a43c-b54085ec90de_1610x344.png 848w, https://substackcdn.com/image/fetch/$s_!D7In!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc2ded60-6550-46e1-a43c-b54085ec90de_1610x344.png 1272w, https://substackcdn.com/image/fetch/$s_!D7In!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc2ded60-6550-46e1-a43c-b54085ec90de_1610x344.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!D7In!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc2ded60-6550-46e1-a43c-b54085ec90de_1610x344.png" width="1456" height="311" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/dc2ded60-6550-46e1-a43c-b54085ec90de_1610x344.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:311,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:121647,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167704972?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc2ded60-6550-46e1-a43c-b54085ec90de_1610x344.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!D7In!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc2ded60-6550-46e1-a43c-b54085ec90de_1610x344.png 424w, https://substackcdn.com/image/fetch/$s_!D7In!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc2ded60-6550-46e1-a43c-b54085ec90de_1610x344.png 848w, https://substackcdn.com/image/fetch/$s_!D7In!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc2ded60-6550-46e1-a43c-b54085ec90de_1610x344.png 1272w, https://substackcdn.com/image/fetch/$s_!D7In!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc2ded60-6550-46e1-a43c-b54085ec90de_1610x344.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>We then include all the information in a <code>GeneratedContent</code> final output for the model: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Vxnc!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F705a9f1c-e74b-4c5c-a692-4fda1fc7a336_1508x534.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Vxnc!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F705a9f1c-e74b-4c5c-a692-4fda1fc7a336_1508x534.png 424w, https://substackcdn.com/image/fetch/$s_!Vxnc!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F705a9f1c-e74b-4c5c-a692-4fda1fc7a336_1508x534.png 848w, https://substackcdn.com/image/fetch/$s_!Vxnc!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F705a9f1c-e74b-4c5c-a692-4fda1fc7a336_1508x534.png 1272w, https://substackcdn.com/image/fetch/$s_!Vxnc!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F705a9f1c-e74b-4c5c-a692-4fda1fc7a336_1508x534.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Vxnc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F705a9f1c-e74b-4c5c-a692-4fda1fc7a336_1508x534.png" width="1456" height="516" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/705a9f1c-e74b-4c5c-a692-4fda1fc7a336_1508x534.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:516,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:178876,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167704972?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F705a9f1c-e74b-4c5c-a692-4fda1fc7a336_1508x534.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Vxnc!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F705a9f1c-e74b-4c5c-a692-4fda1fc7a336_1508x534.png 424w, https://substackcdn.com/image/fetch/$s_!Vxnc!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F705a9f1c-e74b-4c5c-a692-4fda1fc7a336_1508x534.png 848w, https://substackcdn.com/image/fetch/$s_!Vxnc!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F705a9f1c-e74b-4c5c-a692-4fda1fc7a336_1508x534.png 1272w, https://substackcdn.com/image/fetch/$s_!Vxnc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F705a9f1c-e74b-4c5c-a692-4fda1fc7a336_1508x534.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>That&#8217;s it! The model will not have the list of filtered houses to present to the user based on their natural language criteria. </p><h2>Advanced</h2><p>Since you&#8217;re controlling the end-to-end UI of this application, instead of passing the house results to the language model to display to the user, you can use the Tool call to trigger a UI update to directly DISPLAY the results to the user while sending the response to the model as a message simply saying you applied the requested filters. </p><p>Check out <a href="https://x.com/tanmays/status/1939537666934255662">this project</a> for inspiration! </p><h2>The Prompt</h2><p>Finally, it&#8217;s time to run the model! The model instructions in this case is a bit more complex to get it working just right: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!TFd8!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07d04b7f-eb8b-4dbc-b3e3-d76b387ced96_1974x1408.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!TFd8!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07d04b7f-eb8b-4dbc-b3e3-d76b387ced96_1974x1408.png 424w, https://substackcdn.com/image/fetch/$s_!TFd8!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07d04b7f-eb8b-4dbc-b3e3-d76b387ced96_1974x1408.png 848w, https://substackcdn.com/image/fetch/$s_!TFd8!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07d04b7f-eb8b-4dbc-b3e3-d76b387ced96_1974x1408.png 1272w, https://substackcdn.com/image/fetch/$s_!TFd8!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07d04b7f-eb8b-4dbc-b3e3-d76b387ced96_1974x1408.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!TFd8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07d04b7f-eb8b-4dbc-b3e3-d76b387ced96_1974x1408.png" width="1456" height="1039" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/07d04b7f-eb8b-4dbc-b3e3-d76b387ced96_1974x1408.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1039,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:391068,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167704972?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07d04b7f-eb8b-4dbc-b3e3-d76b387ced96_1974x1408.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!TFd8!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07d04b7f-eb8b-4dbc-b3e3-d76b387ced96_1974x1408.png 424w, https://substackcdn.com/image/fetch/$s_!TFd8!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07d04b7f-eb8b-4dbc-b3e3-d76b387ced96_1974x1408.png 848w, https://substackcdn.com/image/fetch/$s_!TFd8!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07d04b7f-eb8b-4dbc-b3e3-d76b387ced96_1974x1408.png 1272w, https://substackcdn.com/image/fetch/$s_!TFd8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07d04b7f-eb8b-4dbc-b3e3-d76b387ced96_1974x1408.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Giving examples to the model is super important. The examples included above are: </p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!IoV3!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F627e84e5-6c5f-457a-8cbd-72d8bc77a867_1946x348.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!IoV3!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F627e84e5-6c5f-457a-8cbd-72d8bc77a867_1946x348.png 424w, https://substackcdn.com/image/fetch/$s_!IoV3!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F627e84e5-6c5f-457a-8cbd-72d8bc77a867_1946x348.png 848w, https://substackcdn.com/image/fetch/$s_!IoV3!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F627e84e5-6c5f-457a-8cbd-72d8bc77a867_1946x348.png 1272w, https://substackcdn.com/image/fetch/$s_!IoV3!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F627e84e5-6c5f-457a-8cbd-72d8bc77a867_1946x348.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!IoV3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F627e84e5-6c5f-457a-8cbd-72d8bc77a867_1946x348.png" width="1456" height="260" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/627e84e5-6c5f-457a-8cbd-72d8bc77a867_1946x348.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:260,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:267959,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167704972?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F627e84e5-6c5f-457a-8cbd-72d8bc77a867_1946x348.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!IoV3!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F627e84e5-6c5f-457a-8cbd-72d8bc77a867_1946x348.png 424w, https://substackcdn.com/image/fetch/$s_!IoV3!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F627e84e5-6c5f-457a-8cbd-72d8bc77a867_1946x348.png 848w, https://substackcdn.com/image/fetch/$s_!IoV3!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F627e84e5-6c5f-457a-8cbd-72d8bc77a867_1946x348.png 1272w, https://substackcdn.com/image/fetch/$s_!IoV3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F627e84e5-6c5f-457a-8cbd-72d8bc77a867_1946x348.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Finally, we just pass the tool and the instructions to the model and it runs well!</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!exVj!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa08200a9-3057-4a59-9557-9c647a207ec7_1876x1120.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!exVj!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa08200a9-3057-4a59-9557-9c647a207ec7_1876x1120.png 424w, https://substackcdn.com/image/fetch/$s_!exVj!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa08200a9-3057-4a59-9557-9c647a207ec7_1876x1120.png 848w, https://substackcdn.com/image/fetch/$s_!exVj!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa08200a9-3057-4a59-9557-9c647a207ec7_1876x1120.png 1272w, https://substackcdn.com/image/fetch/$s_!exVj!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa08200a9-3057-4a59-9557-9c647a207ec7_1876x1120.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!exVj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa08200a9-3057-4a59-9557-9c647a207ec7_1876x1120.png" width="1456" height="869" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a08200a9-3057-4a59-9557-9c647a207ec7_1876x1120.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:869,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:450980,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167704972?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa08200a9-3057-4a59-9557-9c647a207ec7_1876x1120.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!exVj!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa08200a9-3057-4a59-9557-9c647a207ec7_1876x1120.png 424w, https://substackcdn.com/image/fetch/$s_!exVj!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa08200a9-3057-4a59-9557-9c647a207ec7_1876x1120.png 848w, https://substackcdn.com/image/fetch/$s_!exVj!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa08200a9-3057-4a59-9557-9c647a207ec7_1876x1120.png 1272w, https://substackcdn.com/image/fetch/$s_!exVj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa08200a9-3057-4a59-9557-9c647a207ec7_1876x1120.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h2>Conclusion</h2><p>The FoundationModels framework is best used for parsing natural language. When you use it only for that - just parsing user&#8217;s input into specific function arguments that you have full control over, you truly get to experience the power of the model. Set up your tools and code accordingly!</p>]]></content:encoded></item><item><title><![CDATA[LLMs Calling LLMs: Building AI Agents with Apple's Foundation Models and Tool Calling]]></title><description><![CDATA[Explore going from prompts to multi-agent architecture by leveraging Foundation Models tool calling capabilities and exposing LLMs themselves as tools]]></description><link>https://www.natashatherobot.com/p/ai-agents-apples-foundation-models-tool-calling</link><guid isPermaLink="false">https://www.natashatherobot.com/p/ai-agents-apples-foundation-models-tool-calling</guid><dc:creator><![CDATA[Tarek M. Ben Lechhab]]></dc:creator><pubDate>Mon, 07 Jul 2025 14:31:50 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!gxxP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb534cbfe-f071-45de-a36a-e126a51d644b_1024x1024.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>If you follow the ever-changing AI space, you might have noticed that there's a lot of discussion around agents. Between the hype and the more grounded academic world, it's a bit difficult to find a clear definition of what AI agents are.</p><p>One possible definition that is relatively accepted is that <strong>an agent is an LLM running tools in a loop and possibly working with other LLMs to achieve a goal</strong>.</p><p>Like many powerful ideas, it's very simple at its core. But you'll see that it can scale to advanced use cases.</p><div><hr></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.natashatherobot.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">This Substack is reader-supported. To receive new posts and support my work, consider becoming a free or paid subscriber.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p></p><p><em>This is a guest post by <a href="https://bilqisium.com">Tarek M. Ben Lechhab</a>, indie Apple developer, freelancer, and AI enthusiast, feel free to take a look at his publication.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://bilqisium.substack.com&quot;,&quot;text&quot;:&quot;Read other posts by Tarek&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://bilqisium.substack.com"><span>Read other posts by Tarek</span></a></p><div><hr></div><p>Apple's Foundation Models framework is an excellent candidate for experiments in this space.</p><p>Indeed it provides very solid tool calling capabilities, and the limited context window, (only 4096 tokens input and output combined), can greatly benefit from delegating tasks in order to multiply the total number of tokens available to do some work.</p><p>There are many ways agents are used today. We are going to focus on one approach: <strong>the plan and execute design pattern with a bit of orchestration</strong>.</p><p>Used wisely, those can greatly expand the capabilities of your AI-enabled app.</p><p>We will leverage tool calling in order to exhibit agentic behavior.</p><p>But first, let's take a look at tool calling in Foundation Models.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!gxxP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb534cbfe-f071-45de-a36a-e126a51d644b_1024x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!gxxP!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb534cbfe-f071-45de-a36a-e126a51d644b_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!gxxP!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb534cbfe-f071-45de-a36a-e126a51d644b_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!gxxP!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb534cbfe-f071-45de-a36a-e126a51d644b_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!gxxP!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb534cbfe-f071-45de-a36a-e126a51d644b_1024x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!gxxP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb534cbfe-f071-45de-a36a-e126a51d644b_1024x1024.png" width="1024" height="1024" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b534cbfe-f071-45de-a36a-e126a51d644b_1024x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1635008,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167707281?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb534cbfe-f071-45de-a36a-e126a51d644b_1024x1024.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!gxxP!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb534cbfe-f071-45de-a36a-e126a51d644b_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!gxxP!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb534cbfe-f071-45de-a36a-e126a51d644b_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!gxxP!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb534cbfe-f071-45de-a36a-e126a51d644b_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!gxxP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb534cbfe-f071-45de-a36a-e126a51d644b_1024x1024.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h2>Use the Tool, Luke</h2><p>I'm only half joking with this reference. Indeed, like the Force, the tool calling (or function calling) capability of LLMs is very powerful. In the LLM world,a tool is a piece of code provided beforehand that can be called by your LLM at its own discretion.</p><p>Instead of relying on a set of deterministic steps to achieve a result, you pass a tool to the LLM and let it decide if, when, and how it should call it.</p><p>The <a href="https://developer.apple.com/documentation/foundationmodels">Foundation Models</a> implementation is top notch in its own category, especially from an API design standpoint. I'm quite impressed with how much one can achieve with it, given the small size of the only currently available model.</p><p>In order for the LLM to use your tools, you first declare a tool conforming to the <a href="https://developer.apple.com/documentation/foundationmodels/tool">Tool protocol</a>.</p><p>This involves:</p><ul><li><p><strong>Naming</strong> the tool</p></li><li><p>Providing a <strong>description.</strong> This is like a mini-prompt for the LLM to understand what this tool does. Based of this mini-prompt, the LLM will determine if, when, and how it should use the tool.</p></li><li><p>Defining its <a href="https://developer.apple.com/documentation/foundationmodels/tool/arguments">arguments using @Generable</a>. Those are the parameters that the LLM must pass in order to invoke your tool. They will be dynamically generated by the LLM.</p></li><li><p>Implementing the <a href="https://developer.apple.com/documentation/foundationmodels/tool/call(arguments:)">call method</a> which is the action to execute when this tool is called. This method is `async`, so you can definitely do some background or network work, assuming you stay within the timeout limit of the LLM.</p></li><li><p>Returning the <strong>output</strong>, wrapped in a <a href="https://developer.apple.com/documentation/foundationmodels/tooloutput">ToolOutput</a>. By default it can take a string or generated content (which will be useful later)</p></li></ul><p>Here's a simple example for the traditional weather tool:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!FTwy!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb0f6a86e-1775-4d20-aa2d-e8b922151b45_1600x564.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!FTwy!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb0f6a86e-1775-4d20-aa2d-e8b922151b45_1600x564.png 424w, https://substackcdn.com/image/fetch/$s_!FTwy!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb0f6a86e-1775-4d20-aa2d-e8b922151b45_1600x564.png 848w, https://substackcdn.com/image/fetch/$s_!FTwy!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb0f6a86e-1775-4d20-aa2d-e8b922151b45_1600x564.png 1272w, https://substackcdn.com/image/fetch/$s_!FTwy!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb0f6a86e-1775-4d20-aa2d-e8b922151b45_1600x564.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!FTwy!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb0f6a86e-1775-4d20-aa2d-e8b922151b45_1600x564.png" width="1456" height="513" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b0f6a86e-1775-4d20-aa2d-e8b922151b45_1600x564.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:513,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!FTwy!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb0f6a86e-1775-4d20-aa2d-e8b922151b45_1600x564.png 424w, https://substackcdn.com/image/fetch/$s_!FTwy!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb0f6a86e-1775-4d20-aa2d-e8b922151b45_1600x564.png 848w, https://substackcdn.com/image/fetch/$s_!FTwy!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb0f6a86e-1775-4d20-aa2d-e8b922151b45_1600x564.png 1272w, https://substackcdn.com/image/fetch/$s_!FTwy!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb0f6a86e-1775-4d20-aa2d-e8b922151b45_1600x564.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Then, you just pass an instance of that tool to your <a href="https://developer.apple.com/documentation/foundationmodels/languagemodelsession">LanguageModelSession</a> during instantiation, and you're good to go!</p><p>It's up to the LLM to decide whether or not it should call the tool, when it should call it, and with which parameters.</p><p>For long-time programmers, this might sound scary, since there is a lot of non determinism here. but when it works well (and it usually works well), it's really powerful.</p><p>You are essentially programming your computer in natural language and delegating a good chunk of the decision making process.</p><p>In some sense, LLMs can be seen as a new emerging core capability of computers, and programming them with natural language as a new programming paradigm. This idea was developed by Andrej Karpathy in <a href="https://www.youtube.com/watch?v=LCEmiRjPEtQ">a talk that I can only strongly encourage you to watch</a>.</p><p>We are still at the phase of interacting through the command line with those LLMs, as it was done in the 60s with traditional computers.</p><p>I can't even begin to imagine how it will look in the future if it evolves from the CLI to other ways of interacting!</p><h2>Planning and Executing</h2><p>Now that we've seen the basics of a tool, let's turn it up a notch.</p><p>Like traditional programming, this new kind of programming has design patterns.</p><p>One of these design patterns is <a href="https://techcommunity.microsoft.com/blog/educatordeveloperblog/ai-agents-planning-and-orchestration-with-the-planning-design-pattern---part-7/4399204">planning and executing</a>.</p><p>One could think a way to achieve planning and executing would be to write an advanced prompt.</p><p>We could instruct for instance the LLM to first make an extensive plan and then execute this plan.</p><p>While that might work for some cases, this approach would be pretty limited:</p><ul><li><p>First because the context window is short, which means that the planning tokens will count toward the global 4096 input + output limit, not to mention the extensive prompt tokens.</p></li><li><p>Second, because a small 4-billion-parameter LLM like this one is probably not trained for planning and execution (the same goes for reasoning)</p></li></ul><p>A much better way (and the standard way) to do it is by adapting our architecture to have agents interacting with each other.</p><h2>I've put an LLM in your LLM</h2><p>Remember the definition of an agent that we went with earlier? An LLM working with tools and other LLMs.</p><p>This is exactly what we'll experiment with: What if we exposed other LLMs to our root LLM through the tool API? That way, an LLM has the capability of calling another LLM (which is seen as a tool) when necessary.</p><p>Each LLM is an instance of a LanguageModelSession, we thus have multiple windows of 4096 tokens to work with.</p><p>Let's take a look at the architecture of what we're building:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!AZG_!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80c5753c-90d2-4c4e-81bf-f1bd02a63d70_1600x1501.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!AZG_!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80c5753c-90d2-4c4e-81bf-f1bd02a63d70_1600x1501.png 424w, https://substackcdn.com/image/fetch/$s_!AZG_!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80c5753c-90d2-4c4e-81bf-f1bd02a63d70_1600x1501.png 848w, https://substackcdn.com/image/fetch/$s_!AZG_!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80c5753c-90d2-4c4e-81bf-f1bd02a63d70_1600x1501.png 1272w, https://substackcdn.com/image/fetch/$s_!AZG_!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80c5753c-90d2-4c4e-81bf-f1bd02a63d70_1600x1501.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!AZG_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80c5753c-90d2-4c4e-81bf-f1bd02a63d70_1600x1501.png" width="1456" height="1366" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/80c5753c-90d2-4c4e-81bf-f1bd02a63d70_1600x1501.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1366,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!AZG_!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80c5753c-90d2-4c4e-81bf-f1bd02a63d70_1600x1501.png 424w, https://substackcdn.com/image/fetch/$s_!AZG_!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80c5753c-90d2-4c4e-81bf-f1bd02a63d70_1600x1501.png 848w, https://substackcdn.com/image/fetch/$s_!AZG_!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80c5753c-90d2-4c4e-81bf-f1bd02a63d70_1600x1501.png 1272w, https://substackcdn.com/image/fetch/$s_!AZG_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80c5753c-90d2-4c4e-81bf-f1bd02a63d70_1600x1501.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Think of it like a restaurant:</p><ul><li><p>The Coordinator which is the head chef, decides which dish to make</p></li><li><p>The Planner writes the recipe</p></li><li><p>Workers are the line cooks</p></li><li><p>The Coordinator takes back the work from cooks and plates the final dish &#127869;&#65039;</p></li></ul><p>There is a lot of code involved as you can imagine. I can only strongly encourage you to follow along in <a href="https://github.com/bilqisium/AgenticFoundationModels">the sample project</a>.</p><p>Let's take a look at the main pieces.</p><h2>Breaking down the architecture</h2><h3>1. We instantiate a <a href="https://github.com/bilqisium/AgenticFoundationModels/blob/main/AgenticFoundationModels/Agents/Coordinators/CoordinatorAgent.swift">root Coordinator LLM</a></h3><p>Here are its <a href="https://developer.apple.com/documentation/foundationmodels/instructions">instructions (or system prompt)</a></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!lWt7!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a2d6b16-5dbc-4402-b1e9-e830e52fadad_1422x498.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!lWt7!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a2d6b16-5dbc-4402-b1e9-e830e52fadad_1422x498.png 424w, https://substackcdn.com/image/fetch/$s_!lWt7!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a2d6b16-5dbc-4402-b1e9-e830e52fadad_1422x498.png 848w, https://substackcdn.com/image/fetch/$s_!lWt7!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a2d6b16-5dbc-4402-b1e9-e830e52fadad_1422x498.png 1272w, https://substackcdn.com/image/fetch/$s_!lWt7!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a2d6b16-5dbc-4402-b1e9-e830e52fadad_1422x498.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!lWt7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a2d6b16-5dbc-4402-b1e9-e830e52fadad_1422x498.png" width="1422" height="498" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4a2d6b16-5dbc-4402-b1e9-e830e52fadad_1422x498.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:498,&quot;width&quot;:1422,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!lWt7!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a2d6b16-5dbc-4402-b1e9-e830e52fadad_1422x498.png 424w, https://substackcdn.com/image/fetch/$s_!lWt7!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a2d6b16-5dbc-4402-b1e9-e830e52fadad_1422x498.png 848w, https://substackcdn.com/image/fetch/$s_!lWt7!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a2d6b16-5dbc-4402-b1e9-e830e52fadad_1422x498.png 1272w, https://substackcdn.com/image/fetch/$s_!lWt7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a2d6b16-5dbc-4402-b1e9-e830e52fadad_1422x498.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><em>Remark: You&#8217;ll notice that I had to explain to the coordinator to keep the order right and how to do it. At some point, since the worker tasks were running in parallel, and the order in which they returned wasn't predictable, the final output was out of order. Classic concurrency bug fixed by a simple human sentence! We wish all bugs could be fixed like that!</em></p><p>And its prompt:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ufVm!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98bb263c-d548-4139-b80e-70996cca07c8_990x218.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ufVm!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98bb263c-d548-4139-b80e-70996cca07c8_990x218.png 424w, https://substackcdn.com/image/fetch/$s_!ufVm!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98bb263c-d548-4139-b80e-70996cca07c8_990x218.png 848w, https://substackcdn.com/image/fetch/$s_!ufVm!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98bb263c-d548-4139-b80e-70996cca07c8_990x218.png 1272w, https://substackcdn.com/image/fetch/$s_!ufVm!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98bb263c-d548-4139-b80e-70996cca07c8_990x218.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ufVm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98bb263c-d548-4139-b80e-70996cca07c8_990x218.png" width="990" height="218" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/98bb263c-d548-4139-b80e-70996cca07c8_990x218.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:218,&quot;width&quot;:990,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ufVm!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98bb263c-d548-4139-b80e-70996cca07c8_990x218.png 424w, https://substackcdn.com/image/fetch/$s_!ufVm!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98bb263c-d548-4139-b80e-70996cca07c8_990x218.png 848w, https://substackcdn.com/image/fetch/$s_!ufVm!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98bb263c-d548-4139-b80e-70996cca07c8_990x218.png 1272w, https://substackcdn.com/image/fetch/$s_!ufVm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98bb263c-d548-4139-b80e-70996cca07c8_990x218.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><h3>2. We give it a set of tools, namely the <a href="https://github.com/bilqisium/AgenticFoundationModels/blob/main/AgenticFoundationModels/Agents/Tools/Agentic/PlannerTool.swift">Planner</a> and the <a href="https://github.com/bilqisium/AgenticFoundationModels/blob/main/AgenticFoundationModels/Agents/Tools/Agentic/WorkerTool.swift">Worker</a> which are themselves instances of LLMs</h3><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!LbWa!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21698ade-ce19-421e-b756-bb6d9856f78a_1354x136.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!LbWa!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21698ade-ce19-421e-b756-bb6d9856f78a_1354x136.png 424w, https://substackcdn.com/image/fetch/$s_!LbWa!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21698ade-ce19-421e-b756-bb6d9856f78a_1354x136.png 848w, https://substackcdn.com/image/fetch/$s_!LbWa!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21698ade-ce19-421e-b756-bb6d9856f78a_1354x136.png 1272w, https://substackcdn.com/image/fetch/$s_!LbWa!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21698ade-ce19-421e-b756-bb6d9856f78a_1354x136.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!LbWa!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21698ade-ce19-421e-b756-bb6d9856f78a_1354x136.png" width="1354" height="136" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/21698ade-ce19-421e-b756-bb6d9856f78a_1354x136.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:136,&quot;width&quot;:1354,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!LbWa!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21698ade-ce19-421e-b756-bb6d9856f78a_1354x136.png 424w, https://substackcdn.com/image/fetch/$s_!LbWa!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21698ade-ce19-421e-b756-bb6d9856f78a_1354x136.png 848w, https://substackcdn.com/image/fetch/$s_!LbWa!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21698ade-ce19-421e-b756-bb6d9856f78a_1354x136.png 1272w, https://substackcdn.com/image/fetch/$s_!LbWa!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21698ade-ce19-421e-b756-bb6d9856f78a_1354x136.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><h3>3. The Coordinator passes the user's request to the Planner using the tool's Arguments (leveraging <a href="https://developer.apple.com/documentation/foundationmodels/generable">@Generable</a>).</h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!9I_D!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4210678b-55f5-4f44-b997-7047927c511e_1562x508.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!9I_D!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4210678b-55f5-4f44-b997-7047927c511e_1562x508.png 424w, https://substackcdn.com/image/fetch/$s_!9I_D!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4210678b-55f5-4f44-b997-7047927c511e_1562x508.png 848w, https://substackcdn.com/image/fetch/$s_!9I_D!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4210678b-55f5-4f44-b997-7047927c511e_1562x508.png 1272w, https://substackcdn.com/image/fetch/$s_!9I_D!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4210678b-55f5-4f44-b997-7047927c511e_1562x508.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!9I_D!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4210678b-55f5-4f44-b997-7047927c511e_1562x508.png" width="1456" height="474" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4210678b-55f5-4f44-b997-7047927c511e_1562x508.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:474,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!9I_D!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4210678b-55f5-4f44-b997-7047927c511e_1562x508.png 424w, https://substackcdn.com/image/fetch/$s_!9I_D!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4210678b-55f5-4f44-b997-7047927c511e_1562x508.png 848w, https://substackcdn.com/image/fetch/$s_!9I_D!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4210678b-55f5-4f44-b997-7047927c511e_1562x508.png 1272w, https://substackcdn.com/image/fetch/$s_!9I_D!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4210678b-55f5-4f44-b997-7047927c511e_1562x508.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h3>4. Then, in the call method, we instantiate a new session of the LLM to handle the planning request. The Planner decomposes the user request into subtasks, the Coordinator gets them.</h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!L1Lj!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0be840e1-79c8-4767-9edd-194a9b6bf993_1600x408.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!L1Lj!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0be840e1-79c8-4767-9edd-194a9b6bf993_1600x408.png 424w, https://substackcdn.com/image/fetch/$s_!L1Lj!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0be840e1-79c8-4767-9edd-194a9b6bf993_1600x408.png 848w, https://substackcdn.com/image/fetch/$s_!L1Lj!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0be840e1-79c8-4767-9edd-194a9b6bf993_1600x408.png 1272w, https://substackcdn.com/image/fetch/$s_!L1Lj!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0be840e1-79c8-4767-9edd-194a9b6bf993_1600x408.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!L1Lj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0be840e1-79c8-4767-9edd-194a9b6bf993_1600x408.png" width="1456" height="371" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0be840e1-79c8-4767-9edd-194a9b6bf993_1600x408.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:371,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!L1Lj!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0be840e1-79c8-4767-9edd-194a9b6bf993_1600x408.png 424w, https://substackcdn.com/image/fetch/$s_!L1Lj!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0be840e1-79c8-4767-9edd-194a9b6bf993_1600x408.png 848w, https://substackcdn.com/image/fetch/$s_!L1Lj!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0be840e1-79c8-4767-9edd-194a9b6bf993_1600x408.png 1272w, https://substackcdn.com/image/fetch/$s_!L1Lj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0be840e1-79c8-4767-9edd-194a9b6bf993_1600x408.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!YfYj!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ca6cc0e-9946-4218-8de4-97d2b8ca0bc0_1174x538.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!YfYj!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ca6cc0e-9946-4218-8de4-97d2b8ca0bc0_1174x538.png 424w, https://substackcdn.com/image/fetch/$s_!YfYj!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ca6cc0e-9946-4218-8de4-97d2b8ca0bc0_1174x538.png 848w, https://substackcdn.com/image/fetch/$s_!YfYj!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ca6cc0e-9946-4218-8de4-97d2b8ca0bc0_1174x538.png 1272w, https://substackcdn.com/image/fetch/$s_!YfYj!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ca6cc0e-9946-4218-8de4-97d2b8ca0bc0_1174x538.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!YfYj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ca6cc0e-9946-4218-8de4-97d2b8ca0bc0_1174x538.png" width="1174" height="538" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7ca6cc0e-9946-4218-8de4-97d2b8ca0bc0_1174x538.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:538,&quot;width&quot;:1174,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!YfYj!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ca6cc0e-9946-4218-8de4-97d2b8ca0bc0_1174x538.png 424w, https://substackcdn.com/image/fetch/$s_!YfYj!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ca6cc0e-9946-4218-8de4-97d2b8ca0bc0_1174x538.png 848w, https://substackcdn.com/image/fetch/$s_!YfYj!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ca6cc0e-9946-4218-8de4-97d2b8ca0bc0_1174x538.png 1272w, https://substackcdn.com/image/fetch/$s_!YfYj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ca6cc0e-9946-4218-8de4-97d2b8ca0bc0_1174x538.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!i1DW!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0cb9da2-baa4-4fab-bbc5-cd91019f43e0_1150x580.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!i1DW!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0cb9da2-baa4-4fab-bbc5-cd91019f43e0_1150x580.png 424w, https://substackcdn.com/image/fetch/$s_!i1DW!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0cb9da2-baa4-4fab-bbc5-cd91019f43e0_1150x580.png 848w, https://substackcdn.com/image/fetch/$s_!i1DW!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0cb9da2-baa4-4fab-bbc5-cd91019f43e0_1150x580.png 1272w, https://substackcdn.com/image/fetch/$s_!i1DW!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0cb9da2-baa4-4fab-bbc5-cd91019f43e0_1150x580.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!i1DW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0cb9da2-baa4-4fab-bbc5-cd91019f43e0_1150x580.png" width="1150" height="580" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c0cb9da2-baa4-4fab-bbc5-cd91019f43e0_1150x580.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:580,&quot;width&quot;:1150,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!i1DW!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0cb9da2-baa4-4fab-bbc5-cd91019f43e0_1150x580.png 424w, https://substackcdn.com/image/fetch/$s_!i1DW!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0cb9da2-baa4-4fab-bbc5-cd91019f43e0_1150x580.png 848w, https://substackcdn.com/image/fetch/$s_!i1DW!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0cb9da2-baa4-4fab-bbc5-cd91019f43e0_1150x580.png 1272w, https://substackcdn.com/image/fetch/$s_!i1DW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0cb9da2-baa4-4fab-bbc5-cd91019f43e0_1150x580.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h3>5. The Coordinator spawns one Worker per subtask, to execute it</h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!_2ZP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10c3bda5-6f4a-4761-9148-d4e93ed43f36_1600x467.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!_2ZP!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10c3bda5-6f4a-4761-9148-d4e93ed43f36_1600x467.png 424w, https://substackcdn.com/image/fetch/$s_!_2ZP!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10c3bda5-6f4a-4761-9148-d4e93ed43f36_1600x467.png 848w, https://substackcdn.com/image/fetch/$s_!_2ZP!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10c3bda5-6f4a-4761-9148-d4e93ed43f36_1600x467.png 1272w, https://substackcdn.com/image/fetch/$s_!_2ZP!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10c3bda5-6f4a-4761-9148-d4e93ed43f36_1600x467.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!_2ZP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10c3bda5-6f4a-4761-9148-d4e93ed43f36_1600x467.png" width="1456" height="425" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/10c3bda5-6f4a-4761-9148-d4e93ed43f36_1600x467.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:425,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!_2ZP!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10c3bda5-6f4a-4761-9148-d4e93ed43f36_1600x467.png 424w, https://substackcdn.com/image/fetch/$s_!_2ZP!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10c3bda5-6f4a-4761-9148-d4e93ed43f36_1600x467.png 848w, https://substackcdn.com/image/fetch/$s_!_2ZP!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10c3bda5-6f4a-4761-9148-d4e93ed43f36_1600x467.png 1272w, https://substackcdn.com/image/fetch/$s_!_2ZP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10c3bda5-6f4a-4761-9148-d4e93ed43f36_1600x467.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!qf0B!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71166beb-1d76-4f07-a758-fec7b339bcc0_1296x428.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!qf0B!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71166beb-1d76-4f07-a758-fec7b339bcc0_1296x428.png 424w, https://substackcdn.com/image/fetch/$s_!qf0B!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71166beb-1d76-4f07-a758-fec7b339bcc0_1296x428.png 848w, https://substackcdn.com/image/fetch/$s_!qf0B!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71166beb-1d76-4f07-a758-fec7b339bcc0_1296x428.png 1272w, https://substackcdn.com/image/fetch/$s_!qf0B!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71166beb-1d76-4f07-a758-fec7b339bcc0_1296x428.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!qf0B!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71166beb-1d76-4f07-a758-fec7b339bcc0_1296x428.png" width="1296" height="428" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/71166beb-1d76-4f07-a758-fec7b339bcc0_1296x428.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:428,&quot;width&quot;:1296,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!qf0B!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71166beb-1d76-4f07-a758-fec7b339bcc0_1296x428.png 424w, https://substackcdn.com/image/fetch/$s_!qf0B!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71166beb-1d76-4f07-a758-fec7b339bcc0_1296x428.png 848w, https://substackcdn.com/image/fetch/$s_!qf0B!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71166beb-1d76-4f07-a758-fec7b339bcc0_1296x428.png 1272w, https://substackcdn.com/image/fetch/$s_!qf0B!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71166beb-1d76-4f07-a758-fec7b339bcc0_1296x428.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!nDmX!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F15b10f79-f4ea-4e07-92e4-43b166ac8edc_848x346.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!nDmX!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F15b10f79-f4ea-4e07-92e4-43b166ac8edc_848x346.png 424w, https://substackcdn.com/image/fetch/$s_!nDmX!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F15b10f79-f4ea-4e07-92e4-43b166ac8edc_848x346.png 848w, https://substackcdn.com/image/fetch/$s_!nDmX!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F15b10f79-f4ea-4e07-92e4-43b166ac8edc_848x346.png 1272w, https://substackcdn.com/image/fetch/$s_!nDmX!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F15b10f79-f4ea-4e07-92e4-43b166ac8edc_848x346.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!nDmX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F15b10f79-f4ea-4e07-92e4-43b166ac8edc_848x346.png" width="848" height="346" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/15b10f79-f4ea-4e07-92e4-43b166ac8edc_848x346.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:346,&quot;width&quot;:848,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!nDmX!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F15b10f79-f4ea-4e07-92e4-43b166ac8edc_848x346.png 424w, https://substackcdn.com/image/fetch/$s_!nDmX!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F15b10f79-f4ea-4e07-92e4-43b166ac8edc_848x346.png 848w, https://substackcdn.com/image/fetch/$s_!nDmX!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F15b10f79-f4ea-4e07-92e4-43b166ac8edc_848x346.png 1272w, https://substackcdn.com/image/fetch/$s_!nDmX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F15b10f79-f4ea-4e07-92e4-43b166ac8edc_848x346.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h3>6. The Coordinator gathers all the Workers results, combines them and answers the user</h3><h2>Why This Matters</h2><p>Having such a decomposition unlocks capabilities that would be harder, or sometimes impossible to achieve with just one LLM and one prompt:</p><ul><li><p>Each tool (especially workers) can reason about its task, in its own 4096-token playground.</p></li><li><p>Tools can handle ambiguity and edge cases of their own subtasks.</p></li><li><p>Tools can provide explanations for their actions, even if it goes wrong.</p></li><li><p>Ultimately, it enables emergent behaviors, although I admit that with a model this small it's seldom the case.</p></li></ul><h2>Taking our agents for a test run</h2><p>Alright, it's time to take our shiny new toy for a spin.</p><p>Ever wanted to learn about quantum computing? Now is the chance.</p><p>Let's go with the very basic prompt: &#8220;What is quantum computing?&#8221;</p><h3>Normal Mode</h3><p>Here is one possible output from the normal mode:</p><pre><code><code>Quantum computing is a cutting-edge field of computer science that leverages the principles of quantum mechanics to process and solve complex problems more efficiently than classical computers. Unlike traditional computers, which use bits as the smallest unit of data represented as either 0 or 1, quantum computers use quantum bits, or qubits. Qubits can exist in multiple states simultaneously due to a phenomenon known as superposition, allowing quantum computers to process a vast amount of possibilities at once.

Another key concept in quantum computing is entanglement, where qubits become interconnected in such a way that the state of one qubit can depend on the state of another, regardless of the distance between them. This interconnectedness enables quantum computers to perform certain calculations much faster than classical computers.

Quantum computing has the potential to revolutionize fields such as cryptography, optimization, materials science, and complex system simulations by tackling problems that are currently intractable for classical computers. However, building practical quantum computers remains a significant challenge due to issues like qubit stability and error rates.</code></code></pre><h3>Agentic Mode</h3><p>Let's try it with the agentic architecture now:</p><p>The coordinator receives the following prompt:</p><pre><code>Process the following task using the available tools:

User Task: What is quantum computing? </code></pre><p>Then it passes this prompt to the worker (notice that it generated the maximum number of subtasks itself based on the range guide we provided):</p><pre><code>Please analyze and break down the following task into subtasks:
Task: What is quantum computing?
Maximum subtasks: 5

Requirements:
1. Create logical, actionable subtasks
2. Identify dependencies between subtasks
3. Ensure subtasks are specific and measurable
4. Consider the given context and constraints

Provide a comprehensive task plan with a clear strategy.</code></pre><p>Here is the planner's decomposition:</p><pre><code>Task Plan:
Original Task: What is quantum computing?

Strategy: To effectively breakdown the task of 'What is quantum computing?', I will systematically research foundational concepts and theories, trace the historical evolution of quantum computing, assess its potential applications, and compile these insights into a coherent summary. Each subtask builds upon the previous ones, ensuring a logical progression from theoretical understanding to practical implications.

Subtasks (5):
  1. [1] Research foundational concepts of quantum computing.
  2. [2] Identify key theories and principles underlying quantum computing.
  3. [3] Explore historical development and milestones in quantum computing.
  4. [4] Analyze applications and potential impacts of quantum computing.
  5. [5] Summarize findings and prepare a structured explanation of quantum computing.</code></pre><p>The coordinator assigns each of the five subtasks to a worker, spawned in parallel. (not shown here for conciseness)</p><p>Then it gathers the findings of each worker, and combines them into the final result sent to the user:</p><pre><code>Here's a structured breakdown of quantum computing based on the subtasks:

1. **Research Foundational Concepts of Quantum Computing:**
   - Quantum computing uses principles like superposition and entanglement.
   - Key components include qubits, quantum gates, and quantum algorithms.

2. **Identify Key Theories and Principles Underlying Quantum Computing:**
   - **Quantum Superposition**: Allows qubits to exist in multiple states simultaneously.
   - **Quantum Entanglement**: Links qubits for complex computations.
   - **Quantum Tunneling**: Enables particles to pass through potential barriers.
   - **Quantum Interference**: Enhances signal amplification and cancellation.
   - **Quantum Decoherence**: Addresses the loss of quantum states due to environmental interaction.

3. **Explore Historical Development and Milestones in Quantum Computing:**
   - Quantum computing began in the mid-20th century.
   - Key milestones include the development of quantum gates in the 1980s and the first quantum computers in the 1990s.
   - IBM's 2019 announcement of quantum advantage marked a significant breakthrough.

4. **Analyze Applications and Potential Impacts of Quantum Computing:**
   - Quantum computing could revolutionize cryptography by breaking current encryption standards.
   - In materials science, it could enhance drug discovery and material optimization.
   - AI benefits from increased parallelism, improving machine learning capabilities.

5. **Summarize Findings and Prepare a Structured Explanation of Quantum Computing:**
   - Quantum computing offers unparalleled computational power through superposition and entanglement.
   - It holds transformative potential across industries, promising breakthroughs in cryptography, materials science, and artificial intelligence.

This structured approach ensures a logical understanding of quantum computing from foundational concepts to its wide-reaching applications.</code></pre><p>We can see that the final output from the agentic version is much more terse and elaborated than what a single prompt can usually do.</p><p>This is because we expanded the working tokens by multiplying the context windows, dispatched in separate tasks, allowing parallel and specialized work.</p><p>By providing additional tools for specific tasks to the worker tools, I believe this can scale quite well and provide real value.</p><h2>Limitations</h2><h3>Hallucinations</h3><p>While this architecture is powerful in theory, you should still keep in mind that the only currently available model is very small. So it can quickly go off rails and hallucinate.</p><p>For instance, if you ask for real world information, such as the weather, the task decomposition will be just right, but since the workers don't find tools to actually get the location and the weather for that location, it just hallucinates that it does so, or tries to fill it with last know information from training.</p><p>In a production app, the results of such an architecture will only be as good as the tests you conducted to ensure that they fit your specific needs.</p><p>I encourage you to try it, the way tasks are decomposed and executed is instructive to understand the internals of the model.</p><h3>Specialized synthesizer or not?</h3><p>I want to mention that an initial version of this architecture had a synthesizer tool called after the workers in order to combine the work.</p><p>However, it was fragile and the coordinator seemed often confused and tried to re-interpret those results.</p><p>This is typically the kind of limitations that probably wouldn't appear in a bigger model since it would have enough power and tokens to deal with this kind of ambiguity.</p><p>So I removed it, the Coordinator knows &#8220;naturally&#8221; how to do the synthesizing job.</p><h2>Technical details</h2><p>There are a few technical details worth mentioning.</p><h3>Splitting instructions</h3><p>I have had much better results splitting my explanations to the LLM instance between the <a href="https://developer.apple.com/documentation/foundationmodels/instructions">instructions</a> and the actual <a href="https://developer.apple.com/documentation/foundationmodels/prompt">prompt</a>. Apple engineers say that the model is specifically trained to follow instructions over prompt. So one could expect to be able to say everything in the instructions and keep the prompt minimal, but at the time of this writing, it doesn't always work well.</p><h3>Mapping inputs and outputs</h3><p>One key element to make this architecture work is to ensure that when tools are supposed to be chained together, the output of the previous tool has to match the input of the next one.</p><p>For instance, the coordinator is supposed to call a worker with a subtask produced from the planner.</p><p>Here's how that translates:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!lH2S!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55a50086-b054-4761-b480-af8117e3e065_1600x694.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!lH2S!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55a50086-b054-4761-b480-af8117e3e065_1600x694.png 424w, https://substackcdn.com/image/fetch/$s_!lH2S!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55a50086-b054-4761-b480-af8117e3e065_1600x694.png 848w, https://substackcdn.com/image/fetch/$s_!lH2S!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55a50086-b054-4761-b480-af8117e3e065_1600x694.png 1272w, https://substackcdn.com/image/fetch/$s_!lH2S!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55a50086-b054-4761-b480-af8117e3e065_1600x694.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!lH2S!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55a50086-b054-4761-b480-af8117e3e065_1600x694.png" width="1456" height="632" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/55a50086-b054-4761-b480-af8117e3e065_1600x694.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:632,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!lH2S!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55a50086-b054-4761-b480-af8117e3e065_1600x694.png 424w, https://substackcdn.com/image/fetch/$s_!lH2S!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55a50086-b054-4761-b480-af8117e3e065_1600x694.png 848w, https://substackcdn.com/image/fetch/$s_!lH2S!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55a50086-b054-4761-b480-af8117e3e065_1600x694.png 1272w, https://substackcdn.com/image/fetch/$s_!lH2S!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55a50086-b054-4761-b480-af8117e3e065_1600x694.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!lQH5!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f23368c-573c-48e6-8c16-eef378840057_1534x470.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!lQH5!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f23368c-573c-48e6-8c16-eef378840057_1534x470.png 424w, https://substackcdn.com/image/fetch/$s_!lQH5!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f23368c-573c-48e6-8c16-eef378840057_1534x470.png 848w, https://substackcdn.com/image/fetch/$s_!lQH5!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f23368c-573c-48e6-8c16-eef378840057_1534x470.png 1272w, https://substackcdn.com/image/fetch/$s_!lQH5!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f23368c-573c-48e6-8c16-eef378840057_1534x470.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!lQH5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f23368c-573c-48e6-8c16-eef378840057_1534x470.png" width="1456" height="446" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9f23368c-573c-48e6-8c16-eef378840057_1534x470.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:446,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!lQH5!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f23368c-573c-48e6-8c16-eef378840057_1534x470.png 424w, https://substackcdn.com/image/fetch/$s_!lQH5!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f23368c-573c-48e6-8c16-eef378840057_1534x470.png 848w, https://substackcdn.com/image/fetch/$s_!lQH5!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f23368c-573c-48e6-8c16-eef378840057_1534x470.png 1272w, https://substackcdn.com/image/fetch/$s_!lQH5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f23368c-573c-48e6-8c16-eef378840057_1534x470.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>You can see that the planner outputs an array of subtasks, and the worker takes one subtask. Once again, the LLM figures out the mapping automatically. &#129327;</p><h3>Head-scratcher: avoid guided generation with tool calling!</h3><p>It took me a long while to figure this one out. I don't know if it's a bug, a limitation of the system, or just a quirk but there is a critical detail to ensure the model proceeds with tool calling.</p><p><strong>The root or coordinator model mustn't have any &#8220;generating&#8221; type when using tool calling</strong>, at least with this architecture. It means, you shouldn't call it with <code>session.respond(to: prompt, generating: FinalAnswer.self)</code> for instance.</p><p>During my tests, I absolutely had to remove any generating type from the <code>respond(to:)</code> call, which means that ultimately it's probably just like calling it with <code>session.respond(to: prompt, generating: String.self)</code>.</p><p>Otherwise, it would just be very inconsistent in calling the passed tools and often tried to fulfill the request itself, especially with multi-step tool calling.</p><p>I guess there's something that prevents an advanced use case such as this one from working with <a href="https://developer.apple.com/documentation/foundationmodels/generating-swift-data-structures-with-guided-generation">guided generation</a>.</p><p>I might be wrong, but my suspicion is that guided generation seems to be baked in the model, probably during training time, and that it conflicts with the model roaming free with tool use and generating a simple String. (once again, the size of the model is probably the culprit here)</p><h3>Prompt engineering</h3><p>Crafting a good system prompt (instructions) and user prompts goes a long way to make the model do exactly what we want it to.</p><p>Once again, this is the interface we have to program the LLM, so finding the right words and formulation is a discipline in and of itself.</p><p>I found best results with the usual prompt engineering best practices such as using a lot of imperative language.</p><p>However, counter intuitively, I found best results by not explicitly naming the tools in the instructions and prompt. For some reason, when doing so it wasn't making the connection between the actual tools and the string representing those tools in the prompt, and consequently it would lay down its plan to do it, if it had tools at its disposal with those names. &#128580;</p><h3>Session Management</h3><p>&#9888;&#65039;<strong>Warning</strong>: One also has to be careful not to call `respond(to:)` on a LanguageModelSession again before it has returned. Otherwise, it crashes, so be careful in your production apps!</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!5Cjc!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05da721c-06c9-4dd3-b5fa-bd34a55f36dc_1600x91.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!5Cjc!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05da721c-06c9-4dd3-b5fa-bd34a55f36dc_1600x91.png 424w, https://substackcdn.com/image/fetch/$s_!5Cjc!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05da721c-06c9-4dd3-b5fa-bd34a55f36dc_1600x91.png 848w, https://substackcdn.com/image/fetch/$s_!5Cjc!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05da721c-06c9-4dd3-b5fa-bd34a55f36dc_1600x91.png 1272w, https://substackcdn.com/image/fetch/$s_!5Cjc!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05da721c-06c9-4dd3-b5fa-bd34a55f36dc_1600x91.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!5Cjc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05da721c-06c9-4dd3-b5fa-bd34a55f36dc_1600x91.png" width="1456" height="83" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/05da721c-06c9-4dd3-b5fa-bd34a55f36dc_1600x91.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:83,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!5Cjc!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05da721c-06c9-4dd3-b5fa-bd34a55f36dc_1600x91.png 424w, https://substackcdn.com/image/fetch/$s_!5Cjc!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05da721c-06c9-4dd3-b5fa-bd34a55f36dc_1600x91.png 848w, https://substackcdn.com/image/fetch/$s_!5Cjc!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05da721c-06c9-4dd3-b5fa-bd34a55f36dc_1600x91.png 1272w, https://substackcdn.com/image/fetch/$s_!5Cjc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05da721c-06c9-4dd3-b5fa-bd34a55f36dc_1600x91.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Also, keep in mind that while you're expanding capabilities by using many sessions, with each one of them having a context window of 4096 tokens, you still have to find ways to not overflow the root session context window.</p><p>After all, this session will manage the inputs and outputs of all child sessions, so it can quickly blow out of proportions.</p><p>For now I've just kept it simple, but in theory, there are many ways to mitigate this, such as using a sliding window, chained summarization, external memory etc.</p><h3>Recursion Limitation</h3><p>Initially, I wanted to go even further, I wanted to give the Worker tool / LLM an instance of itself, so it could recursively delegate tasks.</p><p>Unfortunately I encountered two issues:</p><ul><li><p>First, it seems like there is a built-in limitation preventing the result from referencing itself (self-referential structs with @Generable). I was even able to uncover that Apple engineers are using a force try! inside the Foundation Models code. &#128516;</p></li></ul><pre><code>FoundationModels/SchemaAugmentor.swift:209: Fatal error: 'try!' expression unexpectedly raised an error: FoundationModels.GenerationSchema.SchemaError.undefinedReferences(schema: Optional("SafeResponse&lt;WorkerResult&gt;"), references: ["WorkerResult"], context: FoundationModels.GenerationSchema.SchemaError.Context(debugDescription: "Undefined types: [WorkerResult]", underlyingErrors: []))</code></pre><ul><li><p>Second, for some reason, the worker really tends to spawn many workers, which themselves spawn many others, and so on. The number exponentially explodes at runtime.</p></li></ul><p>So for now, I would avoid such an architecture without solid testing beforehand.</p><h3>Observability</h3><p>In the demo app, I've implemented a <a href="https://github.com/bilqisium/AgenticFoundationModels/tree/main/AgenticFoundationModels/CallHistoryTracking">history</a> tab with a full trace of all the instructions, prompts, calls, responses of all LLMs and tools.</p><p>It's really instructive to see what happens in real time. You can even tweak the architecture and the prompts and see the changes.</p><h3>Performance</h3><p>While profiling the app, I was able to confirm that for my use cases, the overhead of parallelism was minimal, or sometimes even improved performance a tiny bit. It seems like the Neural Engine is made to handle both sequential and concurrent executions of Foundation Models. (which makes sense, since those kind of models can be used anywhere in the system, at any time)</p><h2>Wrapping it up</h2><p>I hope I have given you a glimpse of what's possible.</p><p>What we did is essentially an automated implementation of <a href="https://en.wikipedia.org/wiki/MapReduce">Map/Reduce</a>, expressed in natural language.</p><p>The LLM is able to decide by itself which tools to call, and to make those calls sequential or parallel.</p><p>Think about the concurrency code and all the small details that could be necessary to achieve such a task manually.</p><p>Now all you need to do is explain it in plain old English, and it will just work.</p><p>There are so many agentic patterns that can be implemented, such as agent-to-agent messaging, persistent memory, federation with other online models, etc.</p><p>I encourage you to <a href="https://github.com/bilqisium/AgenticFoundationModels/tree/main">clone the repository</a>, build the app, and play with it.</p><p>For instance, you can try using the same prompt in normal and agentic mode and compare the results. You can also monitor the token usage and tweak the agents and the prompts. Reach out to me with your findings and remarks!</p><p>While it's true that we are a bit limited by this first model, I suspect Apple will introduce larger models, as well as online ones.</p><p>After all, the framework is called FoundationModel<strong>s</strong>, plural, and the API design kind of <a href="https://developer.apple.com/documentation/foundationmodels/languagemodelsession/init(model:guardrails:tools:transcript:)">gives away the fact that it can be a single interface to multiple models</a>.</p><p>With a more powerful LLM, and more advanced tools, the possibilities are virtually limitless. We will be able to do so much more for our users, as we already can with this model.</p><p>Did that trigger ideas for your apps? What do you think about those agentic capabilities?</p><p>I hope this was useful to you. I have many more experiments from where this one came from, so stay tuned!</p><div><hr></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.natashatherobot.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">This Substack is reader-supported. To receive new posts and support my work, consider becoming a free or paid subscriber.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p></p><p><em>This is a guest post by <a href="https://bilqisium.com">Tarek M. Ben Lechhab</a>, indie Apple developer, freelancer, and AI enthusiast, feel free to take a look at his publication.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://bilqisium.substack.com&quot;,&quot;text&quot;:&quot;Read other posts by Tarek&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="https://bilqisium.substack.com"><span>Read other posts by Tarek</span></a></p><div><hr></div><p></p>]]></content:encoded></item><item><title><![CDATA[How to Add Custom Guardrails to Your FoundationModels Generation]]></title><description><![CDATA[Learn how to add custom guardrails to Apple&#8217;s on-device FoundationModels framework to validate and filter user input using structured prompts and model-generated reasoning.]]></description><link>https://www.natashatherobot.com/p/add-custom-guardrails-foundationmodels</link><guid isPermaLink="false">https://www.natashatherobot.com/p/add-custom-guardrails-foundationmodels</guid><dc:creator><![CDATA[NatashaTheRobot]]></dc:creator><pubDate>Sat, 05 Jul 2025 09:53:17 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!fqWK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe744f53b-7033-4d5d-956a-c41cf1a4c070_2084x928.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In a <a href="https://www.natashatherobot.com/p/swiftui-foundationmodels-streamresponse">previous blog posts</a>, I gave an example of a StudyPlan app that uses Apple&#8217;s new FoundationModels framework to generated customized study plans for students. </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Ui_n!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68cfb6fb-a51a-49de-a812-5fdc95156b3c_470x900.webp" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Ui_n!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68cfb6fb-a51a-49de-a812-5fdc95156b3c_470x900.webp 424w, https://substackcdn.com/image/fetch/$s_!Ui_n!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68cfb6fb-a51a-49de-a812-5fdc95156b3c_470x900.webp 848w, https://substackcdn.com/image/fetch/$s_!Ui_n!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68cfb6fb-a51a-49de-a812-5fdc95156b3c_470x900.webp 1272w, https://substackcdn.com/image/fetch/$s_!Ui_n!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68cfb6fb-a51a-49de-a812-5fdc95156b3c_470x900.webp 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Ui_n!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68cfb6fb-a51a-49de-a812-5fdc95156b3c_470x900.webp" width="470" height="900" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/68cfb6fb-a51a-49de-a812-5fdc95156b3c_470x900.webp&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:900,&quot;width&quot;:470,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:22510,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/webp&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167574481?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68cfb6fb-a51a-49de-a812-5fdc95156b3c_470x900.webp&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Ui_n!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68cfb6fb-a51a-49de-a812-5fdc95156b3c_470x900.webp 424w, https://substackcdn.com/image/fetch/$s_!Ui_n!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68cfb6fb-a51a-49de-a812-5fdc95156b3c_470x900.webp 848w, https://substackcdn.com/image/fetch/$s_!Ui_n!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68cfb6fb-a51a-49de-a812-5fdc95156b3c_470x900.webp 1272w, https://substackcdn.com/image/fetch/$s_!Ui_n!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F68cfb6fb-a51a-49de-a812-5fdc95156b3c_470x900.webp 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>You&#8217;ll notice that while most input fields are restricted, the &#8220;Subject&#8221; field is completely open so the student can be very specific about their area of study. For example, instead of something general like &#8220;Math&#8221;, a younger student or their parent can input &#8220;Division&#8221; more specifically as the subject. </p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.natashatherobot.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">This Substack is reader-supported. To receive new posts and support my work, consider becoming a free or paid subscriber.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>However, this creates one problem. The Subject field becomes part of the main prompt used to input into the model, and it&#8217;s possible students put in weird or unproductive areas of study. The FoundationModels framework already includes guardrails for harmful and inappropriate content, but we may want to add our custom guardrails to protect against funny and non-educational content. </p><p>For example, imagine a student inputs &#8220;Baking Perfect Cookies&#8221; as the subject. While this will not trip up the FoundationModels guardrails as there is nothing harmful about this, it is still not a &#8220;real&#8221; subject that will help school-aged students study in order to pass standardized tests. I know not allowing baking cookings as a study plan is unfortunate, but the goal of our app is to specifically help students pass tests in school.</p><p>With the FoundationModels framework running on-device and being free, adding guardrails for these type of cases is super easier (and did I mention free?!!).</p><h2>The Guardrail Result Object</h2><p>Settings up a custom guardrail just means that you&#8217;ll be checking the user input for certain criteria that you specify in your prompt. Instead of having the model just return a true / false value of whether the subject is appropriate or not, it&#8217;s important to give the model more tokens to &#8220;reason&#8221; about it&#8217;s output. This allows the model to add more context and information to the decision, which you can also display to the user. </p><p>To make sure the model responses back in a structured way, we would create a <code>Generable</code> <code>GuardrailResult</code> object: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!fqWK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe744f53b-7033-4d5d-956a-c41cf1a4c070_2084x928.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!fqWK!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe744f53b-7033-4d5d-956a-c41cf1a4c070_2084x928.png 424w, https://substackcdn.com/image/fetch/$s_!fqWK!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe744f53b-7033-4d5d-956a-c41cf1a4c070_2084x928.png 848w, https://substackcdn.com/image/fetch/$s_!fqWK!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe744f53b-7033-4d5d-956a-c41cf1a4c070_2084x928.png 1272w, https://substackcdn.com/image/fetch/$s_!fqWK!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe744f53b-7033-4d5d-956a-c41cf1a4c070_2084x928.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!fqWK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe744f53b-7033-4d5d-956a-c41cf1a4c070_2084x928.png" width="1456" height="648" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e744f53b-7033-4d5d-956a-c41cf1a4c070_2084x928.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:648,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:397079,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167574481?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe744f53b-7033-4d5d-956a-c41cf1a4c070_2084x928.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!fqWK!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe744f53b-7033-4d5d-956a-c41cf1a4c070_2084x928.png 424w, https://substackcdn.com/image/fetch/$s_!fqWK!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe744f53b-7033-4d5d-956a-c41cf1a4c070_2084x928.png 848w, https://substackcdn.com/image/fetch/$s_!fqWK!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe744f53b-7033-4d5d-956a-c41cf1a4c070_2084x928.png 1272w, https://substackcdn.com/image/fetch/$s_!fqWK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe744f53b-7033-4d5d-956a-c41cf1a4c070_2084x928.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Notice that the ordering of the result properties is very important as we want the model to take the extra tokens to &#8220;reason&#8221; before &#8220;deciding&#8221; whether the subject from the user input is in face an educational subject. </p><h2>The Guardrail Prompt</h2><p>Next, it is important to specify your evaluation criteria in the prompt. Here is an example prompt for making sure the user&#8217;s subject is appropriate (note that it is not fully optimized and would need more work and testing): </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!geKm!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07572e9d-87b6-49c0-a538-e51bd02c2213_2104x944.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!geKm!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07572e9d-87b6-49c0-a538-e51bd02c2213_2104x944.png 424w, https://substackcdn.com/image/fetch/$s_!geKm!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07572e9d-87b6-49c0-a538-e51bd02c2213_2104x944.png 848w, https://substackcdn.com/image/fetch/$s_!geKm!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07572e9d-87b6-49c0-a538-e51bd02c2213_2104x944.png 1272w, https://substackcdn.com/image/fetch/$s_!geKm!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07572e9d-87b6-49c0-a538-e51bd02c2213_2104x944.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!geKm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07572e9d-87b6-49c0-a538-e51bd02c2213_2104x944.png" width="1456" height="653" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/07572e9d-87b6-49c0-a538-e51bd02c2213_2104x944.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:653,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:312974,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167574481?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07572e9d-87b6-49c0-a538-e51bd02c2213_2104x944.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!geKm!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07572e9d-87b6-49c0-a538-e51bd02c2213_2104x944.png 424w, https://substackcdn.com/image/fetch/$s_!geKm!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07572e9d-87b6-49c0-a538-e51bd02c2213_2104x944.png 848w, https://substackcdn.com/image/fetch/$s_!geKm!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07572e9d-87b6-49c0-a538-e51bd02c2213_2104x944.png 1272w, https://substackcdn.com/image/fetch/$s_!geKm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07572e9d-87b6-49c0-a538-e51bd02c2213_2104x944.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h2>Generating a Guardrail Result</h2><p>Finally, you would simply pass in the subject from the user input and have a model respond with a <code>StudySubjectGuardrailResult</code> generation: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!TTAA!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5c9b5b5-1d36-401c-b9a3-db88fa7c2861_1436x570.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!TTAA!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5c9b5b5-1d36-401c-b9a3-db88fa7c2861_1436x570.png 424w, https://substackcdn.com/image/fetch/$s_!TTAA!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5c9b5b5-1d36-401c-b9a3-db88fa7c2861_1436x570.png 848w, https://substackcdn.com/image/fetch/$s_!TTAA!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5c9b5b5-1d36-401c-b9a3-db88fa7c2861_1436x570.png 1272w, https://substackcdn.com/image/fetch/$s_!TTAA!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5c9b5b5-1d36-401c-b9a3-db88fa7c2861_1436x570.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!TTAA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5c9b5b5-1d36-401c-b9a3-db88fa7c2861_1436x570.png" width="1436" height="570" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f5c9b5b5-1d36-401c-b9a3-db88fa7c2861_1436x570.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:570,&quot;width&quot;:1436,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:234391,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167574481?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5c9b5b5-1d36-401c-b9a3-db88fa7c2861_1436x570.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!TTAA!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5c9b5b5-1d36-401c-b9a3-db88fa7c2861_1436x570.png 424w, https://substackcdn.com/image/fetch/$s_!TTAA!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5c9b5b5-1d36-401c-b9a3-db88fa7c2861_1436x570.png 848w, https://substackcdn.com/image/fetch/$s_!TTAA!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5c9b5b5-1d36-401c-b9a3-db88fa7c2861_1436x570.png 1272w, https://substackcdn.com/image/fetch/$s_!TTAA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5c9b5b5-1d36-401c-b9a3-db88fa7c2861_1436x570.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h2>Running the Guardrail</h2><p>The first option to include the guardrail is to run the guardrail result generation model, and if it&#8217;s a valid subject, then run the separate model that generates a study plan: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!PCYC!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ce23b72-17d5-4939-a5c8-e23e4fa45961_1436x1228.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!PCYC!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ce23b72-17d5-4939-a5c8-e23e4fa45961_1436x1228.png 424w, https://substackcdn.com/image/fetch/$s_!PCYC!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ce23b72-17d5-4939-a5c8-e23e4fa45961_1436x1228.png 848w, https://substackcdn.com/image/fetch/$s_!PCYC!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ce23b72-17d5-4939-a5c8-e23e4fa45961_1436x1228.png 1272w, https://substackcdn.com/image/fetch/$s_!PCYC!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ce23b72-17d5-4939-a5c8-e23e4fa45961_1436x1228.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!PCYC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ce23b72-17d5-4939-a5c8-e23e4fa45961_1436x1228.png" width="1436" height="1228" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8ce23b72-17d5-4939-a5c8-e23e4fa45961_1436x1228.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1228,&quot;width&quot;:1436,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:364681,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167574481?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ce23b72-17d5-4939-a5c8-e23e4fa45961_1436x1228.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!PCYC!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ce23b72-17d5-4939-a5c8-e23e4fa45961_1436x1228.png 424w, https://substackcdn.com/image/fetch/$s_!PCYC!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ce23b72-17d5-4939-a5c8-e23e4fa45961_1436x1228.png 848w, https://substackcdn.com/image/fetch/$s_!PCYC!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ce23b72-17d5-4939-a5c8-e23e4fa45961_1436x1228.png 1272w, https://substackcdn.com/image/fetch/$s_!PCYC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ce23b72-17d5-4939-a5c8-e23e4fa45961_1436x1228.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>This is especially good if you have a streaming UI which will stream the study plan. You would want to first validate the study plan subject before displaying the study plan. </p><p>However, if your UI allows for generating the full study plan before displaying it to the user, then it&#8217;s a good practice to run both the guardrail and study plan generation in parallel. Then simply don&#8217;t show the study plan output if the guardrail fails. This saves time: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!iNi8!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a2ea71e-3472-4d57-b59e-cbfddc3e6450_1496x1366.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!iNi8!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a2ea71e-3472-4d57-b59e-cbfddc3e6450_1496x1366.png 424w, https://substackcdn.com/image/fetch/$s_!iNi8!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a2ea71e-3472-4d57-b59e-cbfddc3e6450_1496x1366.png 848w, https://substackcdn.com/image/fetch/$s_!iNi8!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a2ea71e-3472-4d57-b59e-cbfddc3e6450_1496x1366.png 1272w, https://substackcdn.com/image/fetch/$s_!iNi8!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a2ea71e-3472-4d57-b59e-cbfddc3e6450_1496x1366.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!iNi8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a2ea71e-3472-4d57-b59e-cbfddc3e6450_1496x1366.png" width="1456" height="1329" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3a2ea71e-3472-4d57-b59e-cbfddc3e6450_1496x1366.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1329,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:470749,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167574481?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a2ea71e-3472-4d57-b59e-cbfddc3e6450_1496x1366.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!iNi8!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a2ea71e-3472-4d57-b59e-cbfddc3e6450_1496x1366.png 424w, https://substackcdn.com/image/fetch/$s_!iNi8!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a2ea71e-3472-4d57-b59e-cbfddc3e6450_1496x1366.png 848w, https://substackcdn.com/image/fetch/$s_!iNi8!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a2ea71e-3472-4d57-b59e-cbfddc3e6450_1496x1366.png 1272w, https://substackcdn.com/image/fetch/$s_!iNi8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3a2ea71e-3472-4d57-b59e-cbfddc3e6450_1496x1366.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>In this case, our custom guardrail gets activated: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ucAL!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd081c974-b750-440f-a16e-3132428f8f88_1028x388.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ucAL!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd081c974-b750-440f-a16e-3132428f8f88_1028x388.png 424w, https://substackcdn.com/image/fetch/$s_!ucAL!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd081c974-b750-440f-a16e-3132428f8f88_1028x388.png 848w, https://substackcdn.com/image/fetch/$s_!ucAL!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd081c974-b750-440f-a16e-3132428f8f88_1028x388.png 1272w, https://substackcdn.com/image/fetch/$s_!ucAL!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd081c974-b750-440f-a16e-3132428f8f88_1028x388.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ucAL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd081c974-b750-440f-a16e-3132428f8f88_1028x388.png" width="1028" height="388" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d081c974-b750-440f-a16e-3132428f8f88_1028x388.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:388,&quot;width&quot;:1028,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:82860,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167574481?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd081c974-b750-440f-a16e-3132428f8f88_1028x388.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ucAL!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd081c974-b750-440f-a16e-3132428f8f88_1028x388.png 424w, https://substackcdn.com/image/fetch/$s_!ucAL!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd081c974-b750-440f-a16e-3132428f8f88_1028x388.png 848w, https://substackcdn.com/image/fetch/$s_!ucAL!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd081c974-b750-440f-a16e-3132428f8f88_1028x388.png 1272w, https://substackcdn.com/image/fetch/$s_!ucAL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd081c974-b750-440f-a16e-3132428f8f88_1028x388.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h2>Conclusion</h2><p>With Apple&#8217;s on-device FREE FoundationModel, it makes it very fast and easy to include custom guardrails for validating user input. </p><p>However, keep in mind that this model is small (on-device), so it may not be as sophisticated as the super big LLMs that we are used to with ChatGPT / Claude / Gemini Pro. From my testing, it was super easy for the guardrails to be wrong in many cases. This might mean I need to play around with my prompt more. So make sure to test your guardrails thoroughly with many examples to make sure you get the expected results! </p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.natashatherobot.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">This Substack is reader-supported. To receive new posts and support my work, consider becoming a free or paid subscriber.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Natural Language Search with Apple's FoundationModels framework?!]]></title><description><![CDATA[Can Apple's FoundationModels framework be used for searching through house listings?]]></description><link>https://www.natashatherobot.com/p/natural-language-search-foundationmodels-framework</link><guid isPermaLink="false">https://www.natashatherobot.com/p/natural-language-search-foundationmodels-framework</guid><dc:creator><![CDATA[NatashaTheRobot]]></dc:creator><pubDate>Fri, 04 Jul 2025 09:40:52 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!50mm!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5328f3b8-082b-4e7f-9d2f-2d68b8728340_1190x936.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Earlier today I saw an interesting <a href="https://x.com/rudrankriyam/status/1941009838244593994">tweet from Rudrank Riyam</a> as he&#8217;s attending Apple&#8217;s #WWDC25 recap event in Bangalore: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!50mm!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5328f3b8-082b-4e7f-9d2f-2d68b8728340_1190x936.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!50mm!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5328f3b8-082b-4e7f-9d2f-2d68b8728340_1190x936.png 424w, https://substackcdn.com/image/fetch/$s_!50mm!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5328f3b8-082b-4e7f-9d2f-2d68b8728340_1190x936.png 848w, https://substackcdn.com/image/fetch/$s_!50mm!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5328f3b8-082b-4e7f-9d2f-2d68b8728340_1190x936.png 1272w, https://substackcdn.com/image/fetch/$s_!50mm!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5328f3b8-082b-4e7f-9d2f-2d68b8728340_1190x936.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!50mm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5328f3b8-082b-4e7f-9d2f-2d68b8728340_1190x936.png" width="1190" height="936" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5328f3b8-082b-4e7f-9d2f-2d68b8728340_1190x936.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:936,&quot;width&quot;:1190,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1163237,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167505682?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5328f3b8-082b-4e7f-9d2f-2d68b8728340_1190x936.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!50mm!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5328f3b8-082b-4e7f-9d2f-2d68b8728340_1190x936.png 424w, https://substackcdn.com/image/fetch/$s_!50mm!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5328f3b8-082b-4e7f-9d2f-2d68b8728340_1190x936.png 848w, https://substackcdn.com/image/fetch/$s_!50mm!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5328f3b8-082b-4e7f-9d2f-2d68b8728340_1190x936.png 1272w, https://substackcdn.com/image/fetch/$s_!50mm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5328f3b8-082b-4e7f-9d2f-2d68b8728340_1190x936.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>What surprised me here was Apple&#8217;s example of using the FoundationModels framework for &#8220;Natural language search&#8221; - to search through house listings for example&#8230; </p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.natashatherobot.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">This Substack is reader-supported. To receive new posts and support my work, consider becoming a free or paid subscriber.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>First of all, the FoundationModels framework has an extremely limited context window of only 4096 tokens - that is both for INPUT AND OUTPUT combined. So in the context of text search, you wouldn&#8217;t be able to pass in that many objects to the model for the user to search. </p><p>But let&#8217;s say you do have a more limited number of options and want to use the FoundationModels framework to do the search. Would it be able to give you relevant results given how small the model is? I went ahead and tested it out using Apple&#8217;s example of house listings to see!</p><h2>The House Listings</h2><p>First - I created a <code>Generable</code> <code>HouseListing</code> object so that I create sample listings and easily pass them into the model. </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!vIZ7!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03a6c40f-12f2-4ec1-b2af-a2ffe9fdb8ef_716x414.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!vIZ7!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03a6c40f-12f2-4ec1-b2af-a2ffe9fdb8ef_716x414.png 424w, https://substackcdn.com/image/fetch/$s_!vIZ7!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03a6c40f-12f2-4ec1-b2af-a2ffe9fdb8ef_716x414.png 848w, https://substackcdn.com/image/fetch/$s_!vIZ7!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03a6c40f-12f2-4ec1-b2af-a2ffe9fdb8ef_716x414.png 1272w, https://substackcdn.com/image/fetch/$s_!vIZ7!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03a6c40f-12f2-4ec1-b2af-a2ffe9fdb8ef_716x414.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!vIZ7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03a6c40f-12f2-4ec1-b2af-a2ffe9fdb8ef_716x414.png" width="716" height="414" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/03a6c40f-12f2-4ec1-b2af-a2ffe9fdb8ef_716x414.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:414,&quot;width&quot;:716,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:99747,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167505682?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03a6c40f-12f2-4ec1-b2af-a2ffe9fdb8ef_716x414.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!vIZ7!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03a6c40f-12f2-4ec1-b2af-a2ffe9fdb8ef_716x414.png 424w, https://substackcdn.com/image/fetch/$s_!vIZ7!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03a6c40f-12f2-4ec1-b2af-a2ffe9fdb8ef_716x414.png 848w, https://substackcdn.com/image/fetch/$s_!vIZ7!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03a6c40f-12f2-4ec1-b2af-a2ffe9fdb8ef_716x414.png 1272w, https://substackcdn.com/image/fetch/$s_!vIZ7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03a6c40f-12f2-4ec1-b2af-a2ffe9fdb8ef_716x414.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Imagine you receive the house listings from your API and load them into an array of HouseListing structs. </p><p>The results is five of the following house listings: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!C2-G!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e5ec1bb-2ffe-4c0e-b99d-23a9720f4339_2146x804.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!C2-G!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e5ec1bb-2ffe-4c0e-b99d-23a9720f4339_2146x804.png 424w, https://substackcdn.com/image/fetch/$s_!C2-G!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e5ec1bb-2ffe-4c0e-b99d-23a9720f4339_2146x804.png 848w, https://substackcdn.com/image/fetch/$s_!C2-G!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e5ec1bb-2ffe-4c0e-b99d-23a9720f4339_2146x804.png 1272w, https://substackcdn.com/image/fetch/$s_!C2-G!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e5ec1bb-2ffe-4c0e-b99d-23a9720f4339_2146x804.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!C2-G!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e5ec1bb-2ffe-4c0e-b99d-23a9720f4339_2146x804.png" width="1456" height="545" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0e5ec1bb-2ffe-4c0e-b99d-23a9720f4339_2146x804.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:545,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:496522,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167505682?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e5ec1bb-2ffe-4c0e-b99d-23a9720f4339_2146x804.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!C2-G!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e5ec1bb-2ffe-4c0e-b99d-23a9720f4339_2146x804.png 424w, https://substackcdn.com/image/fetch/$s_!C2-G!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e5ec1bb-2ffe-4c0e-b99d-23a9720f4339_2146x804.png 848w, https://substackcdn.com/image/fetch/$s_!C2-G!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e5ec1bb-2ffe-4c0e-b99d-23a9720f4339_2146x804.png 1272w, https://substackcdn.com/image/fetch/$s_!C2-G!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e5ec1bb-2ffe-4c0e-b99d-23a9720f4339_2146x804.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!f0Pp!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e05029a-e4cc-4c25-93e3-ce0196a97b6f_2144x802.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!f0Pp!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e05029a-e4cc-4c25-93e3-ce0196a97b6f_2144x802.png 424w, https://substackcdn.com/image/fetch/$s_!f0Pp!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e05029a-e4cc-4c25-93e3-ce0196a97b6f_2144x802.png 848w, https://substackcdn.com/image/fetch/$s_!f0Pp!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e05029a-e4cc-4c25-93e3-ce0196a97b6f_2144x802.png 1272w, https://substackcdn.com/image/fetch/$s_!f0Pp!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e05029a-e4cc-4c25-93e3-ce0196a97b6f_2144x802.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!f0Pp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e05029a-e4cc-4c25-93e3-ce0196a97b6f_2144x802.png" width="1456" height="545" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0e05029a-e4cc-4c25-93e3-ce0196a97b6f_2144x802.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:545,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:497757,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167505682?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e05029a-e4cc-4c25-93e3-ce0196a97b6f_2144x802.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!f0Pp!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e05029a-e4cc-4c25-93e3-ce0196a97b6f_2144x802.png 424w, https://substackcdn.com/image/fetch/$s_!f0Pp!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e05029a-e4cc-4c25-93e3-ce0196a97b6f_2144x802.png 848w, https://substackcdn.com/image/fetch/$s_!f0Pp!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e05029a-e4cc-4c25-93e3-ce0196a97b6f_2144x802.png 1272w, https://substackcdn.com/image/fetch/$s_!f0Pp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e05029a-e4cc-4c25-93e3-ce0196a97b6f_2144x802.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!oWbd!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36f49284-d6fc-4744-b7e3-a187533a6fd2_2154x806.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!oWbd!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36f49284-d6fc-4744-b7e3-a187533a6fd2_2154x806.png 424w, https://substackcdn.com/image/fetch/$s_!oWbd!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36f49284-d6fc-4744-b7e3-a187533a6fd2_2154x806.png 848w, https://substackcdn.com/image/fetch/$s_!oWbd!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36f49284-d6fc-4744-b7e3-a187533a6fd2_2154x806.png 1272w, https://substackcdn.com/image/fetch/$s_!oWbd!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36f49284-d6fc-4744-b7e3-a187533a6fd2_2154x806.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!oWbd!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36f49284-d6fc-4744-b7e3-a187533a6fd2_2154x806.png" width="1456" height="545" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/36f49284-d6fc-4744-b7e3-a187533a6fd2_2154x806.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:545,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:525327,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167505682?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36f49284-d6fc-4744-b7e3-a187533a6fd2_2154x806.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!oWbd!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36f49284-d6fc-4744-b7e3-a187533a6fd2_2154x806.png 424w, https://substackcdn.com/image/fetch/$s_!oWbd!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36f49284-d6fc-4744-b7e3-a187533a6fd2_2154x806.png 848w, https://substackcdn.com/image/fetch/$s_!oWbd!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36f49284-d6fc-4744-b7e3-a187533a6fd2_2154x806.png 1272w, https://substackcdn.com/image/fetch/$s_!oWbd!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F36f49284-d6fc-4744-b7e3-a187533a6fd2_2154x806.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!hw_j!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd6cb615-d3c7-4e56-b484-06227a8310cf_2146x856.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!hw_j!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd6cb615-d3c7-4e56-b484-06227a8310cf_2146x856.png 424w, https://substackcdn.com/image/fetch/$s_!hw_j!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd6cb615-d3c7-4e56-b484-06227a8310cf_2146x856.png 848w, https://substackcdn.com/image/fetch/$s_!hw_j!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd6cb615-d3c7-4e56-b484-06227a8310cf_2146x856.png 1272w, https://substackcdn.com/image/fetch/$s_!hw_j!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd6cb615-d3c7-4e56-b484-06227a8310cf_2146x856.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!hw_j!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd6cb615-d3c7-4e56-b484-06227a8310cf_2146x856.png" width="1456" height="581" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/dd6cb615-d3c7-4e56-b484-06227a8310cf_2146x856.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:581,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:571245,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167505682?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd6cb615-d3c7-4e56-b484-06227a8310cf_2146x856.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!hw_j!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd6cb615-d3c7-4e56-b484-06227a8310cf_2146x856.png 424w, https://substackcdn.com/image/fetch/$s_!hw_j!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd6cb615-d3c7-4e56-b484-06227a8310cf_2146x856.png 848w, https://substackcdn.com/image/fetch/$s_!hw_j!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd6cb615-d3c7-4e56-b484-06227a8310cf_2146x856.png 1272w, https://substackcdn.com/image/fetch/$s_!hw_j!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd6cb615-d3c7-4e56-b484-06227a8310cf_2146x856.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Dz25!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F720fe0f0-788a-41dc-abce-8cd5233469ad_2128x946.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Dz25!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F720fe0f0-788a-41dc-abce-8cd5233469ad_2128x946.png 424w, https://substackcdn.com/image/fetch/$s_!Dz25!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F720fe0f0-788a-41dc-abce-8cd5233469ad_2128x946.png 848w, https://substackcdn.com/image/fetch/$s_!Dz25!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F720fe0f0-788a-41dc-abce-8cd5233469ad_2128x946.png 1272w, https://substackcdn.com/image/fetch/$s_!Dz25!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F720fe0f0-788a-41dc-abce-8cd5233469ad_2128x946.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Dz25!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F720fe0f0-788a-41dc-abce-8cd5233469ad_2128x946.png" width="1456" height="647" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/720fe0f0-788a-41dc-abce-8cd5233469ad_2128x946.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:647,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:593482,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167505682?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F720fe0f0-788a-41dc-abce-8cd5233469ad_2128x946.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Dz25!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F720fe0f0-788a-41dc-abce-8cd5233469ad_2128x946.png 424w, https://substackcdn.com/image/fetch/$s_!Dz25!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F720fe0f0-788a-41dc-abce-8cd5233469ad_2128x946.png 848w, https://substackcdn.com/image/fetch/$s_!Dz25!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F720fe0f0-788a-41dc-abce-8cd5233469ad_2128x946.png 1272w, https://substackcdn.com/image/fetch/$s_!Dz25!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F720fe0f0-788a-41dc-abce-8cd5233469ad_2128x946.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h2>The House Search Results</h2><p>Next, I created a Generable HouseSearchResults objects that will be generated by the FoundationModels framework that match the user&#8217;s search query: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!C2eS!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e037ec8-984a-4397-9b3c-3d2654a2f23a_1968x658.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!C2eS!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e037ec8-984a-4397-9b3c-3d2654a2f23a_1968x658.png 424w, https://substackcdn.com/image/fetch/$s_!C2eS!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e037ec8-984a-4397-9b3c-3d2654a2f23a_1968x658.png 848w, https://substackcdn.com/image/fetch/$s_!C2eS!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e037ec8-984a-4397-9b3c-3d2654a2f23a_1968x658.png 1272w, https://substackcdn.com/image/fetch/$s_!C2eS!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e037ec8-984a-4397-9b3c-3d2654a2f23a_1968x658.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!C2eS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e037ec8-984a-4397-9b3c-3d2654a2f23a_1968x658.png" width="1456" height="487" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5e037ec8-984a-4397-9b3c-3d2654a2f23a_1968x658.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:487,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:294571,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167505682?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e037ec8-984a-4397-9b3c-3d2654a2f23a_1968x658.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!C2eS!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e037ec8-984a-4397-9b3c-3d2654a2f23a_1968x658.png 424w, https://substackcdn.com/image/fetch/$s_!C2eS!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e037ec8-984a-4397-9b3c-3d2654a2f23a_1968x658.png 848w, https://substackcdn.com/image/fetch/$s_!C2eS!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e037ec8-984a-4397-9b3c-3d2654a2f23a_1968x658.png 1272w, https://substackcdn.com/image/fetch/$s_!C2eS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e037ec8-984a-4397-9b3c-3d2654a2f23a_1968x658.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h2>Searching for the Perfect House</h2><p>Using the new <code>#Playgrounds</code> macro, I can quickly test out if the model will return back the correct results based on the user query: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!4LKK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45787bab-0f3f-41e1-b048-4b46ad6ce41e_2172x1292.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!4LKK!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45787bab-0f3f-41e1-b048-4b46ad6ce41e_2172x1292.png 424w, https://substackcdn.com/image/fetch/$s_!4LKK!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45787bab-0f3f-41e1-b048-4b46ad6ce41e_2172x1292.png 848w, https://substackcdn.com/image/fetch/$s_!4LKK!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45787bab-0f3f-41e1-b048-4b46ad6ce41e_2172x1292.png 1272w, https://substackcdn.com/image/fetch/$s_!4LKK!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45787bab-0f3f-41e1-b048-4b46ad6ce41e_2172x1292.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!4LKK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45787bab-0f3f-41e1-b048-4b46ad6ce41e_2172x1292.png" width="1456" height="866" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/45787bab-0f3f-41e1-b048-4b46ad6ce41e_2172x1292.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:866,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:460012,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167505682?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45787bab-0f3f-41e1-b048-4b46ad6ce41e_2172x1292.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!4LKK!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45787bab-0f3f-41e1-b048-4b46ad6ce41e_2172x1292.png 424w, https://substackcdn.com/image/fetch/$s_!4LKK!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45787bab-0f3f-41e1-b048-4b46ad6ce41e_2172x1292.png 848w, https://substackcdn.com/image/fetch/$s_!4LKK!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45787bab-0f3f-41e1-b048-4b46ad6ce41e_2172x1292.png 1272w, https://substackcdn.com/image/fetch/$s_!4LKK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45787bab-0f3f-41e1-b048-4b46ad6ce41e_2172x1292.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>The result for &#8220;a house with a pool&#8221; was generated as follows: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!8Lll!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa08115c-f58e-481d-905a-966d2dee94ee_1332x380.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!8Lll!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa08115c-f58e-481d-905a-966d2dee94ee_1332x380.png 424w, https://substackcdn.com/image/fetch/$s_!8Lll!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa08115c-f58e-481d-905a-966d2dee94ee_1332x380.png 848w, https://substackcdn.com/image/fetch/$s_!8Lll!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa08115c-f58e-481d-905a-966d2dee94ee_1332x380.png 1272w, https://substackcdn.com/image/fetch/$s_!8Lll!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa08115c-f58e-481d-905a-966d2dee94ee_1332x380.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!8Lll!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa08115c-f58e-481d-905a-966d2dee94ee_1332x380.png" width="1332" height="380" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/aa08115c-f58e-481d-905a-966d2dee94ee_1332x380.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:380,&quot;width&quot;:1332,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:100066,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167505682?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa08115c-f58e-481d-905a-966d2dee94ee_1332x380.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!8Lll!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa08115c-f58e-481d-905a-966d2dee94ee_1332x380.png 424w, https://substackcdn.com/image/fetch/$s_!8Lll!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa08115c-f58e-481d-905a-966d2dee94ee_1332x380.png 848w, https://substackcdn.com/image/fetch/$s_!8Lll!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa08115c-f58e-481d-905a-966d2dee94ee_1332x380.png 1272w, https://substackcdn.com/image/fetch/$s_!8Lll!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faa08115c-f58e-481d-905a-966d2dee94ee_1332x380.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>WOW!!! IMPRESSIVE!!! IT WORKS&#8230; except&#8230; let&#8217;s take a look at the description for house number 5 again&#8230; </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!sTXK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b0898b5-e4eb-4af2-bf28-7ece2e78fb6e_2132x934.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!sTXK!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b0898b5-e4eb-4af2-bf28-7ece2e78fb6e_2132x934.png 424w, https://substackcdn.com/image/fetch/$s_!sTXK!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b0898b5-e4eb-4af2-bf28-7ece2e78fb6e_2132x934.png 848w, https://substackcdn.com/image/fetch/$s_!sTXK!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b0898b5-e4eb-4af2-bf28-7ece2e78fb6e_2132x934.png 1272w, https://substackcdn.com/image/fetch/$s_!sTXK!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b0898b5-e4eb-4af2-bf28-7ece2e78fb6e_2132x934.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!sTXK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b0898b5-e4eb-4af2-bf28-7ece2e78fb6e_2132x934.png" width="1456" height="638" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0b0898b5-e4eb-4af2-bf28-7ece2e78fb6e_2132x934.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:638,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:592429,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167505682?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b0898b5-e4eb-4af2-bf28-7ece2e78fb6e_2132x934.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!sTXK!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b0898b5-e4eb-4af2-bf28-7ece2e78fb6e_2132x934.png 424w, https://substackcdn.com/image/fetch/$s_!sTXK!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b0898b5-e4eb-4af2-bf28-7ece2e78fb6e_2132x934.png 848w, https://substackcdn.com/image/fetch/$s_!sTXK!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b0898b5-e4eb-4af2-bf28-7ece2e78fb6e_2132x934.png 1272w, https://substackcdn.com/image/fetch/$s_!sTXK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b0898b5-e4eb-4af2-bf28-7ece2e78fb6e_2132x934.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>THERE IS NO MENTION OF A POOL! From running different versions of this search prompt, my assessment is that it&#8217;s confusing the &#8220;kitchen" island with waterfall edges as a pool. </p><p>In fact, if you look closely at the reasoning of that the house &#8220;features a resort style pool with spa&#8221;, you can see that this specifically is mentioned for house #3: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!2HVr!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87ef807f-a3d1-42d0-9fd9-b76f2bb42316_1888x890.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!2HVr!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87ef807f-a3d1-42d0-9fd9-b76f2bb42316_1888x890.png 424w, https://substackcdn.com/image/fetch/$s_!2HVr!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87ef807f-a3d1-42d0-9fd9-b76f2bb42316_1888x890.png 848w, https://substackcdn.com/image/fetch/$s_!2HVr!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87ef807f-a3d1-42d0-9fd9-b76f2bb42316_1888x890.png 1272w, https://substackcdn.com/image/fetch/$s_!2HVr!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87ef807f-a3d1-42d0-9fd9-b76f2bb42316_1888x890.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!2HVr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87ef807f-a3d1-42d0-9fd9-b76f2bb42316_1888x890.png" width="1456" height="686" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/87ef807f-a3d1-42d0-9fd9-b76f2bb42316_1888x890.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:686,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:535104,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167505682?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87ef807f-a3d1-42d0-9fd9-b76f2bb42316_1888x890.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!2HVr!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87ef807f-a3d1-42d0-9fd9-b76f2bb42316_1888x890.png 424w, https://substackcdn.com/image/fetch/$s_!2HVr!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87ef807f-a3d1-42d0-9fd9-b76f2bb42316_1888x890.png 848w, https://substackcdn.com/image/fetch/$s_!2HVr!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87ef807f-a3d1-42d0-9fd9-b76f2bb42316_1888x890.png 1272w, https://substackcdn.com/image/fetch/$s_!2HVr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87ef807f-a3d1-42d0-9fd9-b76f2bb42316_1888x890.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Maybe it confused the 5 <code>numberOfBedrooms</code> as house number 5?!!</p><p>Also note that house #2, which does have a pool was NOT included in the results: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!8Lpb!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4e3718c-3bee-463b-bdef-5affaf6f38bc_2022x852.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!8Lpb!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4e3718c-3bee-463b-bdef-5affaf6f38bc_2022x852.png 424w, https://substackcdn.com/image/fetch/$s_!8Lpb!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4e3718c-3bee-463b-bdef-5affaf6f38bc_2022x852.png 848w, https://substackcdn.com/image/fetch/$s_!8Lpb!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4e3718c-3bee-463b-bdef-5affaf6f38bc_2022x852.png 1272w, https://substackcdn.com/image/fetch/$s_!8Lpb!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4e3718c-3bee-463b-bdef-5affaf6f38bc_2022x852.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!8Lpb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4e3718c-3bee-463b-bdef-5affaf6f38bc_2022x852.png" width="1456" height="614" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b4e3718c-3bee-463b-bdef-5affaf6f38bc_2022x852.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:614,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:503194,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167505682?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4e3718c-3bee-463b-bdef-5affaf6f38bc_2022x852.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!8Lpb!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4e3718c-3bee-463b-bdef-5affaf6f38bc_2022x852.png 424w, https://substackcdn.com/image/fetch/$s_!8Lpb!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4e3718c-3bee-463b-bdef-5affaf6f38bc_2022x852.png 848w, https://substackcdn.com/image/fetch/$s_!8Lpb!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4e3718c-3bee-463b-bdef-5affaf6f38bc_2022x852.png 1272w, https://substackcdn.com/image/fetch/$s_!8Lpb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4e3718c-3bee-463b-bdef-5affaf6f38bc_2022x852.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Now, sometimes the model does work&#8230; When I searched for a house near hiking trails, it correctly showed house #5:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!YUfu!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4964bdc6-a76a-4118-8e9f-ee0de1175d3a_2512x748.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!YUfu!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4964bdc6-a76a-4118-8e9f-ee0de1175d3a_2512x748.png 424w, https://substackcdn.com/image/fetch/$s_!YUfu!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4964bdc6-a76a-4118-8e9f-ee0de1175d3a_2512x748.png 848w, https://substackcdn.com/image/fetch/$s_!YUfu!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4964bdc6-a76a-4118-8e9f-ee0de1175d3a_2512x748.png 1272w, https://substackcdn.com/image/fetch/$s_!YUfu!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4964bdc6-a76a-4118-8e9f-ee0de1175d3a_2512x748.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!YUfu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4964bdc6-a76a-4118-8e9f-ee0de1175d3a_2512x748.png" width="1456" height="434" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4964bdc6-a76a-4118-8e9f-ee0de1175d3a_2512x748.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:434,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:462080,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167505682?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4964bdc6-a76a-4118-8e9f-ee0de1175d3a_2512x748.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!YUfu!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4964bdc6-a76a-4118-8e9f-ee0de1175d3a_2512x748.png 424w, https://substackcdn.com/image/fetch/$s_!YUfu!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4964bdc6-a76a-4118-8e9f-ee0de1175d3a_2512x748.png 848w, https://substackcdn.com/image/fetch/$s_!YUfu!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4964bdc6-a76a-4118-8e9f-ee0de1175d3a_2512x748.png 1272w, https://substackcdn.com/image/fetch/$s_!YUfu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4964bdc6-a76a-4118-8e9f-ee0de1175d3a_2512x748.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>However, I would argue that house #1, a farmhouse on 2.5 acres of land, should also show up in the results as it can easily have a trail on the property&#8230; This just shows that the model cannot deduce information. </p><p>You can see the deduction flaws as well. When I searched for &#8220;a house with an ocean view", it gave the following reasoning for the Cape Cod Cottage (house #4):</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!egBe!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fc77dbb-545f-4640-836e-36642d419000_2500x688.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!egBe!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fc77dbb-545f-4640-836e-36642d419000_2500x688.png 424w, https://substackcdn.com/image/fetch/$s_!egBe!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fc77dbb-545f-4640-836e-36642d419000_2500x688.png 848w, https://substackcdn.com/image/fetch/$s_!egBe!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fc77dbb-545f-4640-836e-36642d419000_2500x688.png 1272w, https://substackcdn.com/image/fetch/$s_!egBe!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fc77dbb-545f-4640-836e-36642d419000_2500x688.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!egBe!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fc77dbb-545f-4640-836e-36642d419000_2500x688.png" width="1456" height="401" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8fc77dbb-545f-4640-836e-36642d419000_2500x688.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:401,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:449606,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167505682?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fc77dbb-545f-4640-836e-36642d419000_2500x688.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!egBe!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fc77dbb-545f-4640-836e-36642d419000_2500x688.png 424w, https://substackcdn.com/image/fetch/$s_!egBe!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fc77dbb-545f-4640-836e-36642d419000_2500x688.png 848w, https://substackcdn.com/image/fetch/$s_!egBe!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fc77dbb-545f-4640-836e-36642d419000_2500x688.png 1272w, https://substackcdn.com/image/fetch/$s_!egBe!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fc77dbb-545f-4640-836e-36642d419000_2500x688.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>The answer is technically correct - in the description it says that &#8220;the second floor offers additional bedrooms with dormer windows and ocean glimpses.&#8221; But the model never mentioned the &#8220;ocean glimpses&#8221; as the reason for why it chose house number 4. Instead siting the proximity to the beach, which doesn&#8217;t necessarily mean ocean views directly from the house.  </p><h2>Conclusion</h2><p>The example of searching using natural language with the FoundationModels framework just exposes the extreme limitations of this small on-device model. Make sure to test thoroughly for all use-cases, as the word relationships of this model are not as sophisticated (e.g. kitchen island = pool) as the super big LLMs we&#8217;re used to like ChatGPT and Claude. </p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.natashatherobot.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">This Substack is reader-supported. To receive new posts and support my work, consider becoming a free or paid subscriber.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[The Anatomy of a LiquidGlass Button in iOS 26]]></title><description><![CDATA[Learn about the new glass and glassProminent modifiers in iOS 26 :)]]></description><link>https://www.natashatherobot.com/p/liquidglass-button-ios-26</link><guid isPermaLink="false">https://www.natashatherobot.com/p/liquidglass-button-ios-26</guid><dc:creator><![CDATA[NatashaTheRobot]]></dc:creator><pubDate>Fri, 04 Jul 2025 04:49:33 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/e68143c4-0f8e-4b95-b8f9-060b6f1ad1f7_1060x540.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Today&#8217;s topic is a bit different. I&#8217;ve been building a FoundationModels-powered app for iOS 26, which of course means I get to adopt Liquid Glass :) However, I got a bit confused by how buttons work, so I wanted to write it out here with examples for reference. </p><p>Let&#8217;s start with a regular, non-Liquid Glass button: </p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.natashatherobot.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">This Substack is reader-supported. To receive new posts and support my work, consider becoming a free or paid subscriber.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!qPRz!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1356c719-b068-4c37-b110-bc62d7ee1992_1062x516.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!qPRz!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1356c719-b068-4c37-b110-bc62d7ee1992_1062x516.png 424w, https://substackcdn.com/image/fetch/$s_!qPRz!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1356c719-b068-4c37-b110-bc62d7ee1992_1062x516.png 848w, https://substackcdn.com/image/fetch/$s_!qPRz!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1356c719-b068-4c37-b110-bc62d7ee1992_1062x516.png 1272w, https://substackcdn.com/image/fetch/$s_!qPRz!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1356c719-b068-4c37-b110-bc62d7ee1992_1062x516.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!qPRz!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1356c719-b068-4c37-b110-bc62d7ee1992_1062x516.png" width="1062" height="516" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1356c719-b068-4c37-b110-bc62d7ee1992_1062x516.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:516,&quot;width&quot;:1062,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:137036,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167491966?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1356c719-b068-4c37-b110-bc62d7ee1992_1062x516.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!qPRz!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1356c719-b068-4c37-b110-bc62d7ee1992_1062x516.png 424w, https://substackcdn.com/image/fetch/$s_!qPRz!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1356c719-b068-4c37-b110-bc62d7ee1992_1062x516.png 848w, https://substackcdn.com/image/fetch/$s_!qPRz!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1356c719-b068-4c37-b110-bc62d7ee1992_1062x516.png 1272w, https://substackcdn.com/image/fetch/$s_!qPRz!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1356c719-b068-4c37-b110-bc62d7ee1992_1062x516.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>The output is a non-bordered plain button: </p><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;95ed8275-5755-4855-a070-056c4e4c1224&quot;,&quot;duration&quot;:null}"></div><p></p><p>Now the fun part - let&#8217;s make it a glass button! Simply add the <code>.buttonStyle(.glass)</code> to the button property: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!4p_M!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa2c456a2-7c93-47a7-80c2-a3bc927d9e0f_1068x556.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!4p_M!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa2c456a2-7c93-47a7-80c2-a3bc927d9e0f_1068x556.png 424w, https://substackcdn.com/image/fetch/$s_!4p_M!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa2c456a2-7c93-47a7-80c2-a3bc927d9e0f_1068x556.png 848w, https://substackcdn.com/image/fetch/$s_!4p_M!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa2c456a2-7c93-47a7-80c2-a3bc927d9e0f_1068x556.png 1272w, https://substackcdn.com/image/fetch/$s_!4p_M!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa2c456a2-7c93-47a7-80c2-a3bc927d9e0f_1068x556.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!4p_M!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa2c456a2-7c93-47a7-80c2-a3bc927d9e0f_1068x556.png" width="1068" height="556" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a2c456a2-7c93-47a7-80c2-a3bc927d9e0f_1068x556.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:556,&quot;width&quot;:1068,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:150580,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167491966?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa2c456a2-7c93-47a7-80c2-a3bc927d9e0f_1068x556.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!4p_M!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa2c456a2-7c93-47a7-80c2-a3bc927d9e0f_1068x556.png 424w, https://substackcdn.com/image/fetch/$s_!4p_M!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa2c456a2-7c93-47a7-80c2-a3bc927d9e0f_1068x556.png 848w, https://substackcdn.com/image/fetch/$s_!4p_M!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa2c456a2-7c93-47a7-80c2-a3bc927d9e0f_1068x556.png 1272w, https://substackcdn.com/image/fetch/$s_!4p_M!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa2c456a2-7c93-47a7-80c2-a3bc927d9e0f_1068x556.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>The output is the button with a slight white background, but that is much more fun when pressed!</p><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;3e27b90c-e407-4082-8477-d9854ec25b25&quot;,&quot;duration&quot;:null}"></div><p>While the button just looks white on a white background - remember it is a glass on top of it&#8217;s background. So white on white will be more white. If we change the background color to something else, we can see the glass much better!</p><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;23fc36a3-526b-4ab6-a908-2050b4dc7466&quot;,&quot;duration&quot;:null}"></div><p>It&#8217;s hard to see this glass button, which is fine if this button is not that important and should stay to the side. But what if we want it to be more prominent? In that case, we can set the <code>buttonStyle</code> to <code>glassProminent</code>: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!esS2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbcfff68-66a0-42d9-b071-7994f42c46d8_1062x568.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!esS2!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbcfff68-66a0-42d9-b071-7994f42c46d8_1062x568.png 424w, https://substackcdn.com/image/fetch/$s_!esS2!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbcfff68-66a0-42d9-b071-7994f42c46d8_1062x568.png 848w, https://substackcdn.com/image/fetch/$s_!esS2!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbcfff68-66a0-42d9-b071-7994f42c46d8_1062x568.png 1272w, https://substackcdn.com/image/fetch/$s_!esS2!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbcfff68-66a0-42d9-b071-7994f42c46d8_1062x568.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!esS2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbcfff68-66a0-42d9-b071-7994f42c46d8_1062x568.png" width="1062" height="568" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bbcfff68-66a0-42d9-b071-7994f42c46d8_1062x568.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:568,&quot;width&quot;:1062,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:155581,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167491966?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbcfff68-66a0-42d9-b071-7994f42c46d8_1062x568.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!esS2!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbcfff68-66a0-42d9-b071-7994f42c46d8_1062x568.png 424w, https://substackcdn.com/image/fetch/$s_!esS2!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbcfff68-66a0-42d9-b071-7994f42c46d8_1062x568.png 848w, https://substackcdn.com/image/fetch/$s_!esS2!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbcfff68-66a0-42d9-b071-7994f42c46d8_1062x568.png 1272w, https://substackcdn.com/image/fetch/$s_!esS2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbbcfff68-66a0-42d9-b071-7994f42c46d8_1062x568.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Now, the button will have a background!</p><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;4410292b-5811-487d-bf70-ca17ca02dab1&quot;,&quot;duration&quot;:null}"></div><p>But what if we want a different background than the default blue one? This is where we run into problems - hopefully this is a beta issue&#8230; </p><p>The ideal solution is that you would simply change the button tint color to your desired color: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!6itZ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff8fce6cc-1aaf-4723-a648-643bca8aa099_1054x620.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!6itZ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff8fce6cc-1aaf-4723-a648-643bca8aa099_1054x620.png 424w, https://substackcdn.com/image/fetch/$s_!6itZ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff8fce6cc-1aaf-4723-a648-643bca8aa099_1054x620.png 848w, https://substackcdn.com/image/fetch/$s_!6itZ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff8fce6cc-1aaf-4723-a648-643bca8aa099_1054x620.png 1272w, https://substackcdn.com/image/fetch/$s_!6itZ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff8fce6cc-1aaf-4723-a648-643bca8aa099_1054x620.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!6itZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff8fce6cc-1aaf-4723-a648-643bca8aa099_1054x620.png" width="1054" height="620" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f8fce6cc-1aaf-4723-a648-643bca8aa099_1054x620.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:620,&quot;width&quot;:1054,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:164254,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167491966?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff8fce6cc-1aaf-4723-a648-643bca8aa099_1054x620.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!6itZ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff8fce6cc-1aaf-4723-a648-643bca8aa099_1054x620.png 424w, https://substackcdn.com/image/fetch/$s_!6itZ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff8fce6cc-1aaf-4723-a648-643bca8aa099_1054x620.png 848w, https://substackcdn.com/image/fetch/$s_!6itZ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff8fce6cc-1aaf-4723-a648-643bca8aa099_1054x620.png 1272w, https://substackcdn.com/image/fetch/$s_!6itZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff8fce6cc-1aaf-4723-a648-643bca8aa099_1054x620.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>This works, but only in DARK MODE!!</p><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;8de5ae0d-9ecf-4eca-8655-9f39f83203b5&quot;,&quot;duration&quot;:null}"></div><p>Sadly - in light mode, the red button currently just expands but stays the same color red&#8230; for now hopefully! </p><p>But there is one solution which gets slightly better results for light and dark mode (but still not the same for light mode). You can set the <code>buttonStyle</code> to a regular <code>borderProminent</code> one, and just add an interactive <code>glassEffect</code>: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!17-q!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc113d0f-e104-43a2-9089-4a42a6488833_1044x650.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!17-q!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc113d0f-e104-43a2-9089-4a42a6488833_1044x650.png 424w, https://substackcdn.com/image/fetch/$s_!17-q!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc113d0f-e104-43a2-9089-4a42a6488833_1044x650.png 848w, https://substackcdn.com/image/fetch/$s_!17-q!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc113d0f-e104-43a2-9089-4a42a6488833_1044x650.png 1272w, https://substackcdn.com/image/fetch/$s_!17-q!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc113d0f-e104-43a2-9089-4a42a6488833_1044x650.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!17-q!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc113d0f-e104-43a2-9089-4a42a6488833_1044x650.png" width="1044" height="650" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/dc113d0f-e104-43a2-9089-4a42a6488833_1044x650.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:650,&quot;width&quot;:1044,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:184950,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167491966?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc113d0f-e104-43a2-9089-4a42a6488833_1044x650.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!17-q!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc113d0f-e104-43a2-9089-4a42a6488833_1044x650.png 424w, https://substackcdn.com/image/fetch/$s_!17-q!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc113d0f-e104-43a2-9089-4a42a6488833_1044x650.png 848w, https://substackcdn.com/image/fetch/$s_!17-q!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc113d0f-e104-43a2-9089-4a42a6488833_1044x650.png 1272w, https://substackcdn.com/image/fetch/$s_!17-q!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdc113d0f-e104-43a2-9089-4a42a6488833_1044x650.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;17672ae3-df55-46cd-8bc4-926206c0dc2f&quot;,&quot;duration&quot;:null}"></div><p>It works better in dark mode, but is still a bit buggy: </p><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;94a268e3-653c-4b64-9f58-ca2844757274&quot;,&quot;duration&quot;:null}"></div><h2>Making a Circular Button</h2><p>Now, what if you want to make your button a perfect circle? We would want the following code to work: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!L_5O!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc98a53a7-da95-490b-b966-2d5865fb8e66_1090x716.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!L_5O!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc98a53a7-da95-490b-b966-2d5865fb8e66_1090x716.png 424w, https://substackcdn.com/image/fetch/$s_!L_5O!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc98a53a7-da95-490b-b966-2d5865fb8e66_1090x716.png 848w, https://substackcdn.com/image/fetch/$s_!L_5O!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc98a53a7-da95-490b-b966-2d5865fb8e66_1090x716.png 1272w, https://substackcdn.com/image/fetch/$s_!L_5O!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc98a53a7-da95-490b-b966-2d5865fb8e66_1090x716.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!L_5O!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc98a53a7-da95-490b-b966-2d5865fb8e66_1090x716.png" width="1090" height="716" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c98a53a7-da95-490b-b966-2d5865fb8e66_1090x716.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:716,&quot;width&quot;:1090,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:205772,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167491966?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc98a53a7-da95-490b-b966-2d5865fb8e66_1090x716.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!L_5O!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc98a53a7-da95-490b-b966-2d5865fb8e66_1090x716.png 424w, https://substackcdn.com/image/fetch/$s_!L_5O!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc98a53a7-da95-490b-b966-2d5865fb8e66_1090x716.png 848w, https://substackcdn.com/image/fetch/$s_!L_5O!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc98a53a7-da95-490b-b966-2d5865fb8e66_1090x716.png 1272w, https://substackcdn.com/image/fetch/$s_!L_5O!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc98a53a7-da95-490b-b966-2d5865fb8e66_1090x716.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Unfortunately, it does not. The <code>glassEffect</code> doesn&#8217;t fit the shape&#8230; </p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!O6Qy!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6e39e40b-9bc1-4b11-9a77-29e7ea08cfd0_262x176.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!O6Qy!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6e39e40b-9bc1-4b11-9a77-29e7ea08cfd0_262x176.png 424w, https://substackcdn.com/image/fetch/$s_!O6Qy!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6e39e40b-9bc1-4b11-9a77-29e7ea08cfd0_262x176.png 848w, https://substackcdn.com/image/fetch/$s_!O6Qy!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6e39e40b-9bc1-4b11-9a77-29e7ea08cfd0_262x176.png 1272w, https://substackcdn.com/image/fetch/$s_!O6Qy!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6e39e40b-9bc1-4b11-9a77-29e7ea08cfd0_262x176.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!O6Qy!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6e39e40b-9bc1-4b11-9a77-29e7ea08cfd0_262x176.png" width="262" height="176" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6e39e40b-9bc1-4b11-9a77-29e7ea08cfd0_262x176.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:176,&quot;width&quot;:262,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:19802,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167491966?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6e39e40b-9bc1-4b11-9a77-29e7ea08cfd0_262x176.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!O6Qy!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6e39e40b-9bc1-4b11-9a77-29e7ea08cfd0_262x176.png 424w, https://substackcdn.com/image/fetch/$s_!O6Qy!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6e39e40b-9bc1-4b11-9a77-29e7ea08cfd0_262x176.png 848w, https://substackcdn.com/image/fetch/$s_!O6Qy!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6e39e40b-9bc1-4b11-9a77-29e7ea08cfd0_262x176.png 1272w, https://substackcdn.com/image/fetch/$s_!O6Qy!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6e39e40b-9bc1-4b11-9a77-29e7ea08cfd0_262x176.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>I know what you&#8217;re thinking - we can add a shape to the <code>glassEffect</code>&#8230; </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!imjh!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faee511f8-5f8c-49d1-8d74-c8301c1b4219_1170x708.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!imjh!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faee511f8-5f8c-49d1-8d74-c8301c1b4219_1170x708.png 424w, https://substackcdn.com/image/fetch/$s_!imjh!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faee511f8-5f8c-49d1-8d74-c8301c1b4219_1170x708.png 848w, https://substackcdn.com/image/fetch/$s_!imjh!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faee511f8-5f8c-49d1-8d74-c8301c1b4219_1170x708.png 1272w, https://substackcdn.com/image/fetch/$s_!imjh!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faee511f8-5f8c-49d1-8d74-c8301c1b4219_1170x708.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!imjh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faee511f8-5f8c-49d1-8d74-c8301c1b4219_1170x708.png" width="1170" height="708" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/aee511f8-5f8c-49d1-8d74-c8301c1b4219_1170x708.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:708,&quot;width&quot;:1170,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:211913,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167491966?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faee511f8-5f8c-49d1-8d74-c8301c1b4219_1170x708.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!imjh!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faee511f8-5f8c-49d1-8d74-c8301c1b4219_1170x708.png 424w, https://substackcdn.com/image/fetch/$s_!imjh!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faee511f8-5f8c-49d1-8d74-c8301c1b4219_1170x708.png 848w, https://substackcdn.com/image/fetch/$s_!imjh!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faee511f8-5f8c-49d1-8d74-c8301c1b4219_1170x708.png 1272w, https://substackcdn.com/image/fetch/$s_!imjh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faee511f8-5f8c-49d1-8d74-c8301c1b4219_1170x708.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>While this works initially, the weird shape issue returns when the user clicks on the button: </p><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;bf791abe-41b2-47f8-b5dd-d78bd2d61912&quot;,&quot;duration&quot;:null}"></div><p>The solution.. for now&#8230; is to clip the shape of the button into a circle: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!OO5y!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F81d93e32-3193-4958-b287-cfd0aecd51e7_1144x718.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!OO5y!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F81d93e32-3193-4958-b287-cfd0aecd51e7_1144x718.png 424w, https://substackcdn.com/image/fetch/$s_!OO5y!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F81d93e32-3193-4958-b287-cfd0aecd51e7_1144x718.png 848w, https://substackcdn.com/image/fetch/$s_!OO5y!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F81d93e32-3193-4958-b287-cfd0aecd51e7_1144x718.png 1272w, https://substackcdn.com/image/fetch/$s_!OO5y!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F81d93e32-3193-4958-b287-cfd0aecd51e7_1144x718.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!OO5y!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F81d93e32-3193-4958-b287-cfd0aecd51e7_1144x718.png" width="1144" height="718" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/81d93e32-3193-4958-b287-cfd0aecd51e7_1144x718.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:718,&quot;width&quot;:1144,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:217306,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167491966?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F81d93e32-3193-4958-b287-cfd0aecd51e7_1144x718.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!OO5y!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F81d93e32-3193-4958-b287-cfd0aecd51e7_1144x718.png 424w, https://substackcdn.com/image/fetch/$s_!OO5y!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F81d93e32-3193-4958-b287-cfd0aecd51e7_1144x718.png 848w, https://substackcdn.com/image/fetch/$s_!OO5y!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F81d93e32-3193-4958-b287-cfd0aecd51e7_1144x718.png 1272w, https://substackcdn.com/image/fetch/$s_!OO5y!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F81d93e32-3193-4958-b287-cfd0aecd51e7_1144x718.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Finally - it works&#8230; Note that I removed the tint to show the effect more prominently: </p><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;a92afeeb-88c3-4466-a9a6-37e9bd907318&quot;,&quot;duration&quot;:null}"></div><p>Hopefully this will get fixed in future betas and &#8220;just work&#8221; :) </p><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.natashatherobot.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">This Substack is reader-supported. To receive new posts and support my work, consider becoming a free or paid subscriber.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[A Swift Developer’s Guide to Prompt Engineering with Apple’s FoundationModels]]></title><description><![CDATA[Learn how to craft effective, guided prompts for Apple&#8217;s Foundation Model using Swift, SwiftUI, and the powerful FoundationModels framework.]]></description><link>https://www.natashatherobot.com/p/swift-prompt-engineering-apples-foundationmodels</link><guid isPermaLink="false">https://www.natashatherobot.com/p/swift-prompt-engineering-apples-foundationmodels</guid><dc:creator><![CDATA[NatashaTheRobot]]></dc:creator><pubDate>Mon, 30 Jun 2025 11:03:30 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!wFYe!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc60e7216-4ad3-4f85-bf18-3ec1012f96b7_1134x966.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Each Large Language Model (LLM) has its own prompting style, but Apple&#8217;s new Foundation Model is a bit unique because it is specifically trained to work with Swift and SwiftUI.</p><p>To learn more about the Foundation Model and how it is prompted, I watched the following WWDC25 session:</p><ul><li><p><a href="https://developer.apple.com/videos/play/wwdc2025/248/">Explore prompt design &amp; safety for on-device foundation models</a></p></li><li><p><a href="https://developer.apple.com/videos/play/wwdc2025/259/?time=1472">Code-along: Bring on-device AI to your app using the Foundation Models framework</a></p></li><li><p><a href="https://developer.apple.com/videos/play/wwdc2025/301/">Deep dive into the Foundation Models framework</a></p></li></ul><p>In this blog post, I&#8217;ll summarize the prompting techniques for easier future reference. </p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.natashatherobot.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">This Substack is reader-supported. To receive new posts and support my work, consider becoming a free or paid subscriber.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><h2>Prompt Testing</h2><p>As with all LLMs, it is important to test different variations of the prompt to figure out which one gets the best results for your app&#8217;s use-case. </p><p>One big issue with the FoundationModels is it&#8217;s extremely limited context size. Only <strong>4096 tokens</strong> for BOTH input and output tokens. This means that your prompt counts against the context window. So you have to strike the right balance between providing a powerful prompt but keeping it short. </p><p>The other big issue is that the FoundationModels are extremely guardrailed against unsafe input and output. While this is a great thing in theory, in practice this can produce a lot of false positives. In other words, your innocent prompt may accidentally trigger the guardrails. Something that Apple includes in their documentation as well: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!jOYF!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5cfa8d41-8f41-4114-b68d-72d3da1f5958_1636x454.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!jOYF!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5cfa8d41-8f41-4114-b68d-72d3da1f5958_1636x454.png 424w, https://substackcdn.com/image/fetch/$s_!jOYF!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5cfa8d41-8f41-4114-b68d-72d3da1f5958_1636x454.png 848w, https://substackcdn.com/image/fetch/$s_!jOYF!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5cfa8d41-8f41-4114-b68d-72d3da1f5958_1636x454.png 1272w, https://substackcdn.com/image/fetch/$s_!jOYF!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5cfa8d41-8f41-4114-b68d-72d3da1f5958_1636x454.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!jOYF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5cfa8d41-8f41-4114-b68d-72d3da1f5958_1636x454.png" width="1456" height="404" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5cfa8d41-8f41-4114-b68d-72d3da1f5958_1636x454.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:404,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!jOYF!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5cfa8d41-8f41-4114-b68d-72d3da1f5958_1636x454.png 424w, https://substackcdn.com/image/fetch/$s_!jOYF!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5cfa8d41-8f41-4114-b68d-72d3da1f5958_1636x454.png 848w, https://substackcdn.com/image/fetch/$s_!jOYF!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5cfa8d41-8f41-4114-b68d-72d3da1f5958_1636x454.png 1272w, https://substackcdn.com/image/fetch/$s_!jOYF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5cfa8d41-8f41-4114-b68d-72d3da1f5958_1636x454.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Fortunately, it is super easy to test prompts right in any Xcode project using the new <code>Playgrounds</code> framework! </p><p>In your project, simply create a <code>Playgrounds.swift</code> file, <code>import Playgrounds</code> and start playing around. The reason I say to do this in your project is because it&#8217;ll have access to all your types. </p><p>Here is how simple it is to get started with testing your prompts with Playgrounds: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!O0XE!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff37847cd-ad47-4a7f-b2b2-dace89e38be6_2632x1012.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!O0XE!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff37847cd-ad47-4a7f-b2b2-dace89e38be6_2632x1012.png 424w, https://substackcdn.com/image/fetch/$s_!O0XE!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff37847cd-ad47-4a7f-b2b2-dace89e38be6_2632x1012.png 848w, https://substackcdn.com/image/fetch/$s_!O0XE!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff37847cd-ad47-4a7f-b2b2-dace89e38be6_2632x1012.png 1272w, https://substackcdn.com/image/fetch/$s_!O0XE!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff37847cd-ad47-4a7f-b2b2-dace89e38be6_2632x1012.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!O0XE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff37847cd-ad47-4a7f-b2b2-dace89e38be6_2632x1012.png" width="1456" height="560" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f37847cd-ad47-4a7f-b2b2-dace89e38be6_2632x1012.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:560,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:372305,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167137025?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff37847cd-ad47-4a7f-b2b2-dace89e38be6_2632x1012.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!O0XE!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff37847cd-ad47-4a7f-b2b2-dace89e38be6_2632x1012.png 424w, https://substackcdn.com/image/fetch/$s_!O0XE!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff37847cd-ad47-4a7f-b2b2-dace89e38be6_2632x1012.png 848w, https://substackcdn.com/image/fetch/$s_!O0XE!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff37847cd-ad47-4a7f-b2b2-dace89e38be6_2632x1012.png 1272w, https://substackcdn.com/image/fetch/$s_!O0XE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff37847cd-ad47-4a7f-b2b2-dace89e38be6_2632x1012.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h2>Guides</h2><p>Before you even write a prompt, the FoundationModels framework provides a powerful <code>Generable</code> macro that defines the structure of the model&#8217;s output for you. For example, let&#8217;s imagine we&#8217;re building an education app where study plans are generated on demand based on student requirements. </p><p>The <code>StudyPlan</code> object that the Foundation Model should generate would take this structure: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Bws0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9fa8dd4-1548-4fc0-84ad-39d9833a31fe_720x322.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Bws0!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9fa8dd4-1548-4fc0-84ad-39d9833a31fe_720x322.png 424w, https://substackcdn.com/image/fetch/$s_!Bws0!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9fa8dd4-1548-4fc0-84ad-39d9833a31fe_720x322.png 848w, https://substackcdn.com/image/fetch/$s_!Bws0!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9fa8dd4-1548-4fc0-84ad-39d9833a31fe_720x322.png 1272w, https://substackcdn.com/image/fetch/$s_!Bws0!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9fa8dd4-1548-4fc0-84ad-39d9833a31fe_720x322.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Bws0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9fa8dd4-1548-4fc0-84ad-39d9833a31fe_720x322.png" width="720" height="322" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c9fa8dd4-1548-4fc0-84ad-39d9833a31fe_720x322.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:322,&quot;width&quot;:720,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:70234,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167137025?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9fa8dd4-1548-4fc0-84ad-39d9833a31fe_720x322.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Bws0!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9fa8dd4-1548-4fc0-84ad-39d9833a31fe_720x322.png 424w, https://substackcdn.com/image/fetch/$s_!Bws0!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9fa8dd4-1548-4fc0-84ad-39d9833a31fe_720x322.png 848w, https://substackcdn.com/image/fetch/$s_!Bws0!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9fa8dd4-1548-4fc0-84ad-39d9833a31fe_720x322.png 1272w, https://substackcdn.com/image/fetch/$s_!Bws0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9fa8dd4-1548-4fc0-84ad-39d9833a31fe_720x322.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>To generate, simply include the <code>StudyPlan</code> object as what the model is generating in the response: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!IJRm!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27a17e86-c703-46e3-ac90-1e6360dec5db_2572x1286.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!IJRm!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27a17e86-c703-46e3-ac90-1e6360dec5db_2572x1286.png 424w, https://substackcdn.com/image/fetch/$s_!IJRm!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27a17e86-c703-46e3-ac90-1e6360dec5db_2572x1286.png 848w, https://substackcdn.com/image/fetch/$s_!IJRm!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27a17e86-c703-46e3-ac90-1e6360dec5db_2572x1286.png 1272w, https://substackcdn.com/image/fetch/$s_!IJRm!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27a17e86-c703-46e3-ac90-1e6360dec5db_2572x1286.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!IJRm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27a17e86-c703-46e3-ac90-1e6360dec5db_2572x1286.png" width="1456" height="728" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/27a17e86-c703-46e3-ac90-1e6360dec5db_2572x1286.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:728,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:587432,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167137025?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27a17e86-c703-46e3-ac90-1e6360dec5db_2572x1286.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!IJRm!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27a17e86-c703-46e3-ac90-1e6360dec5db_2572x1286.png 424w, https://substackcdn.com/image/fetch/$s_!IJRm!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27a17e86-c703-46e3-ac90-1e6360dec5db_2572x1286.png 848w, https://substackcdn.com/image/fetch/$s_!IJRm!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27a17e86-c703-46e3-ac90-1e6360dec5db_2572x1286.png 1272w, https://substackcdn.com/image/fetch/$s_!IJRm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F27a17e86-c703-46e3-ac90-1e6360dec5db_2572x1286.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>As a starting point, this is pretty vague. But instead of starting by optimizing the prompt, we can use a <code>Guide</code> for each variable that we need generated to be a lot more specific with what we want. </p><p>To start with, we can add a description for each variable explaining what it is for: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Iltb!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5910b6c1-aaaa-4d65-a54e-959f7bb4292d_1142x686.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Iltb!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5910b6c1-aaaa-4d65-a54e-959f7bb4292d_1142x686.png 424w, https://substackcdn.com/image/fetch/$s_!Iltb!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5910b6c1-aaaa-4d65-a54e-959f7bb4292d_1142x686.png 848w, https://substackcdn.com/image/fetch/$s_!Iltb!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5910b6c1-aaaa-4d65-a54e-959f7bb4292d_1142x686.png 1272w, https://substackcdn.com/image/fetch/$s_!Iltb!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5910b6c1-aaaa-4d65-a54e-959f7bb4292d_1142x686.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Iltb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5910b6c1-aaaa-4d65-a54e-959f7bb4292d_1142x686.png" width="1142" height="686" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5910b6c1-aaaa-4d65-a54e-959f7bb4292d_1142x686.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:686,&quot;width&quot;:1142,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:188004,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167137025?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5910b6c1-aaaa-4d65-a54e-959f7bb4292d_1142x686.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Iltb!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5910b6c1-aaaa-4d65-a54e-959f7bb4292d_1142x686.png 424w, https://substackcdn.com/image/fetch/$s_!Iltb!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5910b6c1-aaaa-4d65-a54e-959f7bb4292d_1142x686.png 848w, https://substackcdn.com/image/fetch/$s_!Iltb!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5910b6c1-aaaa-4d65-a54e-959f7bb4292d_1142x686.png 1272w, https://substackcdn.com/image/fetch/$s_!Iltb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5910b6c1-aaaa-4d65-a54e-959f7bb4292d_1142x686.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Now your prompt is much more targeted for each variable, and you don&#8217;t have to include these details separately in the main prompt. </p><h3>String Guides</h3><p>But wait, there are more Guides! For example, let&#8217;s say our app focuses on only 5 subjects: Math, English, History, Science, and Philosophy. You can add it in as an <strong>.anyOf</strong> Guide for the subject variable: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!LNNg!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F22b4ee9d-c194-4b5c-8f50-719911daa1e1_1150x810.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!LNNg!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F22b4ee9d-c194-4b5c-8f50-719911daa1e1_1150x810.png 424w, https://substackcdn.com/image/fetch/$s_!LNNg!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F22b4ee9d-c194-4b5c-8f50-719911daa1e1_1150x810.png 848w, https://substackcdn.com/image/fetch/$s_!LNNg!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F22b4ee9d-c194-4b5c-8f50-719911daa1e1_1150x810.png 1272w, https://substackcdn.com/image/fetch/$s_!LNNg!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F22b4ee9d-c194-4b5c-8f50-719911daa1e1_1150x810.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!LNNg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F22b4ee9d-c194-4b5c-8f50-719911daa1e1_1150x810.png" width="1150" height="810" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/22b4ee9d-c194-4b5c-8f50-719911daa1e1_1150x810.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:810,&quot;width&quot;:1150,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:233756,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167137025?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F22b4ee9d-c194-4b5c-8f50-719911daa1e1_1150x810.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!LNNg!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F22b4ee9d-c194-4b5c-8f50-719911daa1e1_1150x810.png 424w, https://substackcdn.com/image/fetch/$s_!LNNg!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F22b4ee9d-c194-4b5c-8f50-719911daa1e1_1150x810.png 848w, https://substackcdn.com/image/fetch/$s_!LNNg!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F22b4ee9d-c194-4b5c-8f50-719911daa1e1_1150x810.png 1272w, https://substackcdn.com/image/fetch/$s_!LNNg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F22b4ee9d-c194-4b5c-8f50-719911daa1e1_1150x810.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Now you ensure that the generated response will be one of these five, which your app specifically supports. </p><p>Instead of using this guide, <code>Generable</code> type also supports enums, so this also works well: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!zODO!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56a6dbbf-b962-4cd2-b493-a4ac9821aeff_2590x1136.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!zODO!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56a6dbbf-b962-4cd2-b493-a4ac9821aeff_2590x1136.png 424w, https://substackcdn.com/image/fetch/$s_!zODO!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56a6dbbf-b962-4cd2-b493-a4ac9821aeff_2590x1136.png 848w, https://substackcdn.com/image/fetch/$s_!zODO!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56a6dbbf-b962-4cd2-b493-a4ac9821aeff_2590x1136.png 1272w, https://substackcdn.com/image/fetch/$s_!zODO!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56a6dbbf-b962-4cd2-b493-a4ac9821aeff_2590x1136.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!zODO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56a6dbbf-b962-4cd2-b493-a4ac9821aeff_2590x1136.png" width="1456" height="639" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/56a6dbbf-b962-4cd2-b493-a4ac9821aeff_2590x1136.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:639,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:528956,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167137025?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56a6dbbf-b962-4cd2-b493-a4ac9821aeff_2590x1136.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!zODO!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56a6dbbf-b962-4cd2-b493-a4ac9821aeff_2590x1136.png 424w, https://substackcdn.com/image/fetch/$s_!zODO!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56a6dbbf-b962-4cd2-b493-a4ac9821aeff_2590x1136.png 848w, https://substackcdn.com/image/fetch/$s_!zODO!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56a6dbbf-b962-4cd2-b493-a4ac9821aeff_2590x1136.png 1272w, https://substackcdn.com/image/fetch/$s_!zODO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56a6dbbf-b962-4cd2-b493-a4ac9821aeff_2590x1136.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>If you are using a String as a variable, it also supports <code>.constant</code> (always the same value - let&#8217;s say the school name in our case):</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!miFP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c25afd9-6424-4397-a841-9d41e981494a_858x154.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!miFP!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c25afd9-6424-4397-a841-9d41e981494a_858x154.png 424w, https://substackcdn.com/image/fetch/$s_!miFP!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c25afd9-6424-4397-a841-9d41e981494a_858x154.png 848w, https://substackcdn.com/image/fetch/$s_!miFP!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c25afd9-6424-4397-a841-9d41e981494a_858x154.png 1272w, https://substackcdn.com/image/fetch/$s_!miFP!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c25afd9-6424-4397-a841-9d41e981494a_858x154.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!miFP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c25afd9-6424-4397-a841-9d41e981494a_858x154.png" width="858" height="154" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5c25afd9-6424-4397-a841-9d41e981494a_858x154.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:154,&quot;width&quot;:858,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:40064,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167137025?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c25afd9-6424-4397-a841-9d41e981494a_858x154.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!miFP!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c25afd9-6424-4397-a841-9d41e981494a_858x154.png 424w, https://substackcdn.com/image/fetch/$s_!miFP!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c25afd9-6424-4397-a841-9d41e981494a_858x154.png 848w, https://substackcdn.com/image/fetch/$s_!miFP!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c25afd9-6424-4397-a841-9d41e981494a_858x154.png 1272w, https://substackcdn.com/image/fetch/$s_!miFP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c25afd9-6424-4397-a841-9d41e981494a_858x154.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>This will always generate &#8220;My Online School&#8221; for the school variable.</p><p>You can also put in a regex into the Guide! For example, this ensures that the teachers generated name always starts with &#8220;Mr.&#8221; or &#8220;Mrs.&#8221;!</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!N8Og!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1a1acab-5e87-44ad-81e1-98071c4002b9_588x138.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!N8Og!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1a1acab-5e87-44ad-81e1-98071c4002b9_588x138.png 424w, https://substackcdn.com/image/fetch/$s_!N8Og!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1a1acab-5e87-44ad-81e1-98071c4002b9_588x138.png 848w, https://substackcdn.com/image/fetch/$s_!N8Og!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1a1acab-5e87-44ad-81e1-98071c4002b9_588x138.png 1272w, https://substackcdn.com/image/fetch/$s_!N8Og!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1a1acab-5e87-44ad-81e1-98071c4002b9_588x138.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!N8Og!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1a1acab-5e87-44ad-81e1-98071c4002b9_588x138.png" width="588" height="138" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c1a1acab-5e87-44ad-81e1-98071c4002b9_588x138.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:138,&quot;width&quot;:588,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:31689,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167137025?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1a1acab-5e87-44ad-81e1-98071c4002b9_588x138.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!N8Og!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1a1acab-5e87-44ad-81e1-98071c4002b9_588x138.png 424w, https://substackcdn.com/image/fetch/$s_!N8Og!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1a1acab-5e87-44ad-81e1-98071c4002b9_588x138.png 848w, https://substackcdn.com/image/fetch/$s_!N8Og!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1a1acab-5e87-44ad-81e1-98071c4002b9_588x138.png 1272w, https://substackcdn.com/image/fetch/$s_!N8Og!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc1a1acab-5e87-44ad-81e1-98071c4002b9_588x138.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>And if you&#8217;re into Swift&#8217;s native <code>RegexBuilder</code> framework, that is also supported! </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Kr1_!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43490e87-8441-4009-a349-7a01c2915940_494x572.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Kr1_!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43490e87-8441-4009-a349-7a01c2915940_494x572.png 424w, https://substackcdn.com/image/fetch/$s_!Kr1_!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43490e87-8441-4009-a349-7a01c2915940_494x572.png 848w, https://substackcdn.com/image/fetch/$s_!Kr1_!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43490e87-8441-4009-a349-7a01c2915940_494x572.png 1272w, https://substackcdn.com/image/fetch/$s_!Kr1_!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43490e87-8441-4009-a349-7a01c2915940_494x572.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Kr1_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43490e87-8441-4009-a349-7a01c2915940_494x572.png" width="494" height="572" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/43490e87-8441-4009-a349-7a01c2915940_494x572.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:572,&quot;width&quot;:494,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:68384,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167137025?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43490e87-8441-4009-a349-7a01c2915940_494x572.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Kr1_!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43490e87-8441-4009-a349-7a01c2915940_494x572.png 424w, https://substackcdn.com/image/fetch/$s_!Kr1_!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43490e87-8441-4009-a349-7a01c2915940_494x572.png 848w, https://substackcdn.com/image/fetch/$s_!Kr1_!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43490e87-8441-4009-a349-7a01c2915940_494x572.png 1272w, https://substackcdn.com/image/fetch/$s_!Kr1_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43490e87-8441-4009-a349-7a01c2915940_494x572.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h3>Number Guides </h3><p>Let&#8217;s say our app only supports study plans that are under 10 weeks. It is easy to set this in the Guide using the <code>.minimum</code>, <code>.maximum</code>, or <code>.range </code>variables - supported for Int / Float / Double / Decimal types:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!x3Gr!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd41cd0db-90a8-40b1-aeac-a0da5fd0ce7c_1054x244.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!x3Gr!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd41cd0db-90a8-40b1-aeac-a0da5fd0ce7c_1054x244.png 424w, https://substackcdn.com/image/fetch/$s_!x3Gr!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd41cd0db-90a8-40b1-aeac-a0da5fd0ce7c_1054x244.png 848w, https://substackcdn.com/image/fetch/$s_!x3Gr!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd41cd0db-90a8-40b1-aeac-a0da5fd0ce7c_1054x244.png 1272w, https://substackcdn.com/image/fetch/$s_!x3Gr!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd41cd0db-90a8-40b1-aeac-a0da5fd0ce7c_1054x244.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!x3Gr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd41cd0db-90a8-40b1-aeac-a0da5fd0ce7c_1054x244.png" width="1054" height="244" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d41cd0db-90a8-40b1-aeac-a0da5fd0ce7c_1054x244.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:244,&quot;width&quot;:1054,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:79354,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167137025?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd41cd0db-90a8-40b1-aeac-a0da5fd0ce7c_1054x244.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!x3Gr!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd41cd0db-90a8-40b1-aeac-a0da5fd0ce7c_1054x244.png 424w, https://substackcdn.com/image/fetch/$s_!x3Gr!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd41cd0db-90a8-40b1-aeac-a0da5fd0ce7c_1054x244.png 848w, https://substackcdn.com/image/fetch/$s_!x3Gr!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd41cd0db-90a8-40b1-aeac-a0da5fd0ce7c_1054x244.png 1272w, https://substackcdn.com/image/fetch/$s_!x3Gr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd41cd0db-90a8-40b1-aeac-a0da5fd0ce7c_1054x244.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><h3>Array Guides </h3><p>Finally - you can be very specific with how many objects you want generated in an array. Say, for example, that I want to include 3 prerequisites for each study plan. It&#8217;s as simple as specifying the count to be 3: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!f_Em!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07b6b0b8-d89e-44cc-bb08-a42b050f9383_1034x286.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!f_Em!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07b6b0b8-d89e-44cc-bb08-a42b050f9383_1034x286.png 424w, https://substackcdn.com/image/fetch/$s_!f_Em!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07b6b0b8-d89e-44cc-bb08-a42b050f9383_1034x286.png 848w, https://substackcdn.com/image/fetch/$s_!f_Em!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07b6b0b8-d89e-44cc-bb08-a42b050f9383_1034x286.png 1272w, https://substackcdn.com/image/fetch/$s_!f_Em!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07b6b0b8-d89e-44cc-bb08-a42b050f9383_1034x286.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!f_Em!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07b6b0b8-d89e-44cc-bb08-a42b050f9383_1034x286.png" width="1034" height="286" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/07b6b0b8-d89e-44cc-bb08-a42b050f9383_1034x286.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:286,&quot;width&quot;:1034,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:80141,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167137025?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07b6b0b8-d89e-44cc-bb08-a42b050f9383_1034x286.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!f_Em!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07b6b0b8-d89e-44cc-bb08-a42b050f9383_1034x286.png 424w, https://substackcdn.com/image/fetch/$s_!f_Em!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07b6b0b8-d89e-44cc-bb08-a42b050f9383_1034x286.png 848w, https://substackcdn.com/image/fetch/$s_!f_Em!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07b6b0b8-d89e-44cc-bb08-a42b050f9383_1034x286.png 1272w, https://substackcdn.com/image/fetch/$s_!f_Em!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F07b6b0b8-d89e-44cc-bb08-a42b050f9383_1034x286.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>The final generated guided output will look like this: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!P8jQ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd798e42-5ba9-4ed1-bf98-a13afa63b26d_2406x1328.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!P8jQ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd798e42-5ba9-4ed1-bf98-a13afa63b26d_2406x1328.png 424w, https://substackcdn.com/image/fetch/$s_!P8jQ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd798e42-5ba9-4ed1-bf98-a13afa63b26d_2406x1328.png 848w, https://substackcdn.com/image/fetch/$s_!P8jQ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd798e42-5ba9-4ed1-bf98-a13afa63b26d_2406x1328.png 1272w, https://substackcdn.com/image/fetch/$s_!P8jQ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd798e42-5ba9-4ed1-bf98-a13afa63b26d_2406x1328.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!P8jQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd798e42-5ba9-4ed1-bf98-a13afa63b26d_2406x1328.png" width="1456" height="804" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/cd798e42-5ba9-4ed1-bf98-a13afa63b26d_2406x1328.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:804,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:671276,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167137025?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd798e42-5ba9-4ed1-bf98-a13afa63b26d_2406x1328.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!P8jQ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd798e42-5ba9-4ed1-bf98-a13afa63b26d_2406x1328.png 424w, https://substackcdn.com/image/fetch/$s_!P8jQ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd798e42-5ba9-4ed1-bf98-a13afa63b26d_2406x1328.png 848w, https://substackcdn.com/image/fetch/$s_!P8jQ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd798e42-5ba9-4ed1-bf98-a13afa63b26d_2406x1328.png 1272w, https://substackcdn.com/image/fetch/$s_!P8jQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd798e42-5ba9-4ed1-bf98-a13afa63b26d_2406x1328.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Guided generation with the FoundationModels framework is extremely impressive because the model has been trained specifically for it. You don&#8217;t have to worry that it will go &#8220;off-script&#8221; and hallucinate enum types that don&#8217;t exist. And with only a few tokens of context window, you can use this powerful prompting technique. </p><h2>Order of Properties</h2><p>When you consider the Generable object as a prompt in itself, ordering becomes super important. For example, in the above example of the <code>StudyPlan</code> object, notice that we first generate the <code>subject</code>, then the <code>weeklyTopics</code>. The weekly topics directly relate to the subject. </p><p>Now what if the <code>subject</code> is put after the <code>weeklyTopics</code>?</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!wZKP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F761a496e-8c09-496c-940c-500807e821a3_2578x1376.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!wZKP!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F761a496e-8c09-496c-940c-500807e821a3_2578x1376.png 424w, https://substackcdn.com/image/fetch/$s_!wZKP!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F761a496e-8c09-496c-940c-500807e821a3_2578x1376.png 848w, https://substackcdn.com/image/fetch/$s_!wZKP!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F761a496e-8c09-496c-940c-500807e821a3_2578x1376.png 1272w, https://substackcdn.com/image/fetch/$s_!wZKP!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F761a496e-8c09-496c-940c-500807e821a3_2578x1376.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!wZKP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F761a496e-8c09-496c-940c-500807e821a3_2578x1376.png" width="1456" height="777" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/761a496e-8c09-496c-940c-500807e821a3_2578x1376.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:777,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:699910,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167137025?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F761a496e-8c09-496c-940c-500807e821a3_2578x1376.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!wZKP!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F761a496e-8c09-496c-940c-500807e821a3_2578x1376.png 424w, https://substackcdn.com/image/fetch/$s_!wZKP!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F761a496e-8c09-496c-940c-500807e821a3_2578x1376.png 848w, https://substackcdn.com/image/fetch/$s_!wZKP!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F761a496e-8c09-496c-940c-500807e821a3_2578x1376.png 1272w, https://substackcdn.com/image/fetch/$s_!wZKP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F761a496e-8c09-496c-940c-500807e821a3_2578x1376.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Notice that the Foundation Model no longer knows the subject and is generating the <code>weeklyTopics</code> and the <code>prerequisites</code> with &#8220;Topic A&#8221; and &#8220;Topic B&#8221; as the subject! That is because LLMs generate one token (*subword*) at a time, so if it hasn&#8217;t generated the subject yet, it will not &#8220;know&#8221; what it is!</p><p>So make sure you test out different order of properties as an additional form of prompting! For example - if you first generate a short story and need a summary of that story, generate the story first then the summary to improve the summary based on the story. This is also something I do as I write my blog posts - I write the blog post first then the title after :) </p><h2>Use Natural Language Length Qualifiers for Longer Text</h2><p>Now let&#8217;s say I want a lot more details of what is included in the weekly topic study plan as I find it to not be detailed enough for my app: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!unHB!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F30a4d0e3-75c8-49e0-bfde-2b3f8dee93af_954x942.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!unHB!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F30a4d0e3-75c8-49e0-bfde-2b3f8dee93af_954x942.png 424w, https://substackcdn.com/image/fetch/$s_!unHB!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F30a4d0e3-75c8-49e0-bfde-2b3f8dee93af_954x942.png 848w, https://substackcdn.com/image/fetch/$s_!unHB!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F30a4d0e3-75c8-49e0-bfde-2b3f8dee93af_954x942.png 1272w, https://substackcdn.com/image/fetch/$s_!unHB!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F30a4d0e3-75c8-49e0-bfde-2b3f8dee93af_954x942.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!unHB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F30a4d0e3-75c8-49e0-bfde-2b3f8dee93af_954x942.png" width="954" height="942" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/30a4d0e3-75c8-49e0-bfde-2b3f8dee93af_954x942.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:942,&quot;width&quot;:954,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:181037,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167137025?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F30a4d0e3-75c8-49e0-bfde-2b3f8dee93af_954x942.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!unHB!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F30a4d0e3-75c8-49e0-bfde-2b3f8dee93af_954x942.png 424w, https://substackcdn.com/image/fetch/$s_!unHB!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F30a4d0e3-75c8-49e0-bfde-2b3f8dee93af_954x942.png 848w, https://substackcdn.com/image/fetch/$s_!unHB!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F30a4d0e3-75c8-49e0-bfde-2b3f8dee93af_954x942.png 1272w, https://substackcdn.com/image/fetch/$s_!unHB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F30a4d0e3-75c8-49e0-bfde-2b3f8dee93af_954x942.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>I will go ahead and create a WeeklyTopic object to get both the title and a more detailed description: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!1HgX!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46b7092f-c6c1-4b0d-aca0-d9a66821e2ad_1210x508.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!1HgX!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46b7092f-c6c1-4b0d-aca0-d9a66821e2ad_1210x508.png 424w, https://substackcdn.com/image/fetch/$s_!1HgX!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46b7092f-c6c1-4b0d-aca0-d9a66821e2ad_1210x508.png 848w, https://substackcdn.com/image/fetch/$s_!1HgX!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46b7092f-c6c1-4b0d-aca0-d9a66821e2ad_1210x508.png 1272w, https://substackcdn.com/image/fetch/$s_!1HgX!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46b7092f-c6c1-4b0d-aca0-d9a66821e2ad_1210x508.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!1HgX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46b7092f-c6c1-4b0d-aca0-d9a66821e2ad_1210x508.png" width="1210" height="508" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/46b7092f-c6c1-4b0d-aca0-d9a66821e2ad_1210x508.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:508,&quot;width&quot;:1210,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:128023,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167137025?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46b7092f-c6c1-4b0d-aca0-d9a66821e2ad_1210x508.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!1HgX!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46b7092f-c6c1-4b0d-aca0-d9a66821e2ad_1210x508.png 424w, https://substackcdn.com/image/fetch/$s_!1HgX!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46b7092f-c6c1-4b0d-aca0-d9a66821e2ad_1210x508.png 848w, https://substackcdn.com/image/fetch/$s_!1HgX!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46b7092f-c6c1-4b0d-aca0-d9a66821e2ad_1210x508.png 1272w, https://substackcdn.com/image/fetch/$s_!1HgX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46b7092f-c6c1-4b0d-aca0-d9a66821e2ad_1210x508.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>When I generate this as part of my <code>StudyPlan</code>, I&#8217;m not too happy with the result - it is still too vague and general: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!bJek!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ac3741a-70d9-4692-b12d-8824194b90a0_1306x1286.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!bJek!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ac3741a-70d9-4692-b12d-8824194b90a0_1306x1286.png 424w, https://substackcdn.com/image/fetch/$s_!bJek!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ac3741a-70d9-4692-b12d-8824194b90a0_1306x1286.png 848w, https://substackcdn.com/image/fetch/$s_!bJek!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ac3741a-70d9-4692-b12d-8824194b90a0_1306x1286.png 1272w, https://substackcdn.com/image/fetch/$s_!bJek!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ac3741a-70d9-4692-b12d-8824194b90a0_1306x1286.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!bJek!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ac3741a-70d9-4692-b12d-8824194b90a0_1306x1286.png" width="1306" height="1286" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1ac3741a-70d9-4692-b12d-8824194b90a0_1306x1286.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1286,&quot;width&quot;:1306,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:234502,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167137025?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ac3741a-70d9-4692-b12d-8824194b90a0_1306x1286.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!bJek!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ac3741a-70d9-4692-b12d-8824194b90a0_1306x1286.png 424w, https://substackcdn.com/image/fetch/$s_!bJek!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ac3741a-70d9-4692-b12d-8824194b90a0_1306x1286.png 848w, https://substackcdn.com/image/fetch/$s_!bJek!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ac3741a-70d9-4692-b12d-8824194b90a0_1306x1286.png 1272w, https://substackcdn.com/image/fetch/$s_!bJek!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ac3741a-70d9-4692-b12d-8824194b90a0_1306x1286.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>This is where I can include a length qualifier to my Guided prompt for the description variable to that this field needs to be &#8220;in detail&#8221;: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!xBlg!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac9061cf-ad15-41d3-8de8-194c69b52e58_1220x518.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!xBlg!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac9061cf-ad15-41d3-8de8-194c69b52e58_1220x518.png 424w, https://substackcdn.com/image/fetch/$s_!xBlg!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac9061cf-ad15-41d3-8de8-194c69b52e58_1220x518.png 848w, https://substackcdn.com/image/fetch/$s_!xBlg!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac9061cf-ad15-41d3-8de8-194c69b52e58_1220x518.png 1272w, https://substackcdn.com/image/fetch/$s_!xBlg!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac9061cf-ad15-41d3-8de8-194c69b52e58_1220x518.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!xBlg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac9061cf-ad15-41d3-8de8-194c69b52e58_1220x518.png" width="1220" height="518" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ac9061cf-ad15-41d3-8de8-194c69b52e58_1220x518.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:518,&quot;width&quot;:1220,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:143115,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167137025?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac9061cf-ad15-41d3-8de8-194c69b52e58_1220x518.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!xBlg!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac9061cf-ad15-41d3-8de8-194c69b52e58_1220x518.png 424w, https://substackcdn.com/image/fetch/$s_!xBlg!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac9061cf-ad15-41d3-8de8-194c69b52e58_1220x518.png 848w, https://substackcdn.com/image/fetch/$s_!xBlg!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac9061cf-ad15-41d3-8de8-194c69b52e58_1220x518.png 1272w, https://substackcdn.com/image/fetch/$s_!xBlg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac9061cf-ad15-41d3-8de8-194c69b52e58_1220x518.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Play around with super specific lengths to get just the righ ouput for both longer and shorter styles. You can use &#8220;In a few words&#8221;, &#8220;In a single paragraph&#8221;, &#8220;In three sentences&#8221; etc. to describe the length of output you want. This is also a great way to control the prompt context window. </p><h2>Character Role</h2><p>Models work very well when being given a character description. Let&#8217;s say we want to be a super fun online school for kindergarten students. You can create a fun kindergarten teacher character for your study plan in the instructions: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!4Cqr!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feae939e8-20ed-41cf-93ec-8ac7ef35b479_2468x1112.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!4Cqr!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feae939e8-20ed-41cf-93ec-8ac7ef35b479_2468x1112.png 424w, https://substackcdn.com/image/fetch/$s_!4Cqr!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feae939e8-20ed-41cf-93ec-8ac7ef35b479_2468x1112.png 848w, https://substackcdn.com/image/fetch/$s_!4Cqr!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feae939e8-20ed-41cf-93ec-8ac7ef35b479_2468x1112.png 1272w, https://substackcdn.com/image/fetch/$s_!4Cqr!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feae939e8-20ed-41cf-93ec-8ac7ef35b479_2468x1112.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!4Cqr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feae939e8-20ed-41cf-93ec-8ac7ef35b479_2468x1112.png" width="1456" height="656" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/eae939e8-20ed-41cf-93ec-8ac7ef35b479_2468x1112.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:656,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:684361,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167137025?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feae939e8-20ed-41cf-93ec-8ac7ef35b479_2468x1112.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!4Cqr!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feae939e8-20ed-41cf-93ec-8ac7ef35b479_2468x1112.png 424w, https://substackcdn.com/image/fetch/$s_!4Cqr!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feae939e8-20ed-41cf-93ec-8ac7ef35b479_2468x1112.png 848w, https://substackcdn.com/image/fetch/$s_!4Cqr!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feae939e8-20ed-41cf-93ec-8ac7ef35b479_2468x1112.png 1272w, https://substackcdn.com/image/fetch/$s_!4Cqr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feae939e8-20ed-41cf-93ec-8ac7ef35b479_2468x1112.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Now this looks like a much more fun study plan for math I wish someone created for me&#8230;</p><p>In other cases, you may use the session instructions to provide an expected tone for the model. For example, in a personal guided diary app, you may instruct the model to respond to negativity in an empathetic way: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!4_Bc!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffab8efd-9659-4ba0-87cf-3d9f04d590d1_932x880.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!4_Bc!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffab8efd-9659-4ba0-87cf-3d9f04d590d1_932x880.png 424w, https://substackcdn.com/image/fetch/$s_!4_Bc!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffab8efd-9659-4ba0-87cf-3d9f04d590d1_932x880.png 848w, https://substackcdn.com/image/fetch/$s_!4_Bc!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffab8efd-9659-4ba0-87cf-3d9f04d590d1_932x880.png 1272w, https://substackcdn.com/image/fetch/$s_!4_Bc!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffab8efd-9659-4ba0-87cf-3d9f04d590d1_932x880.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!4_Bc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffab8efd-9659-4ba0-87cf-3d9f04d590d1_932x880.png" width="932" height="880" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ffab8efd-9659-4ba0-87cf-3d9f04d590d1_932x880.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:880,&quot;width&quot;:932,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:368792,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167137025?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffab8efd-9659-4ba0-87cf-3d9f04d590d1_932x880.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!4_Bc!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffab8efd-9659-4ba0-87cf-3d9f04d590d1_932x880.png 424w, https://substackcdn.com/image/fetch/$s_!4_Bc!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffab8efd-9659-4ba0-87cf-3d9f04d590d1_932x880.png 848w, https://substackcdn.com/image/fetch/$s_!4_Bc!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffab8efd-9659-4ba0-87cf-3d9f04d590d1_932x880.png 1272w, https://substackcdn.com/image/fetch/$s_!4_Bc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffab8efd-9659-4ba0-87cf-3d9f04d590d1_932x880.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h2>Few Shot Prompting</h2><p>One very effective prompting technique is called few-shot prompting, meaning that you give the model a few examples of what to generate. This is extremely easy to do in the FoundationModels framework with the Generative macro. The macro automatically converts any Generative object into a string, so it&#8217;s as simple as first create an example: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!fLbW!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90d54229-a169-4561-a267-85cc3919b68f_1130x924.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!fLbW!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90d54229-a169-4561-a267-85cc3919b68f_1130x924.png 424w, https://substackcdn.com/image/fetch/$s_!fLbW!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90d54229-a169-4561-a267-85cc3919b68f_1130x924.png 848w, https://substackcdn.com/image/fetch/$s_!fLbW!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90d54229-a169-4561-a267-85cc3919b68f_1130x924.png 1272w, https://substackcdn.com/image/fetch/$s_!fLbW!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90d54229-a169-4561-a267-85cc3919b68f_1130x924.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!fLbW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90d54229-a169-4561-a267-85cc3919b68f_1130x924.png" width="1130" height="924" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/90d54229-a169-4561-a267-85cc3919b68f_1130x924.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:924,&quot;width&quot;:1130,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:292025,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167137025?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90d54229-a169-4561-a267-85cc3919b68f_1130x924.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!fLbW!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90d54229-a169-4561-a267-85cc3919b68f_1130x924.png 424w, https://substackcdn.com/image/fetch/$s_!fLbW!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90d54229-a169-4561-a267-85cc3919b68f_1130x924.png 848w, https://substackcdn.com/image/fetch/$s_!fLbW!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90d54229-a169-4561-a267-85cc3919b68f_1130x924.png 1272w, https://substackcdn.com/image/fetch/$s_!fLbW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F90d54229-a169-4561-a267-85cc3919b68f_1130x924.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>or two: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!fjyD!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F38845fb1-1294-46f8-bed3-1feb39ce37df_1194x1044.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!fjyD!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F38845fb1-1294-46f8-bed3-1feb39ce37df_1194x1044.png 424w, https://substackcdn.com/image/fetch/$s_!fjyD!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F38845fb1-1294-46f8-bed3-1feb39ce37df_1194x1044.png 848w, https://substackcdn.com/image/fetch/$s_!fjyD!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F38845fb1-1294-46f8-bed3-1feb39ce37df_1194x1044.png 1272w, https://substackcdn.com/image/fetch/$s_!fjyD!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F38845fb1-1294-46f8-bed3-1feb39ce37df_1194x1044.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!fjyD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F38845fb1-1294-46f8-bed3-1feb39ce37df_1194x1044.png" width="1194" height="1044" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/38845fb1-1294-46f8-bed3-1feb39ce37df_1194x1044.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1044,&quot;width&quot;:1194,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:336986,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167137025?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F38845fb1-1294-46f8-bed3-1feb39ce37df_1194x1044.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!fjyD!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F38845fb1-1294-46f8-bed3-1feb39ce37df_1194x1044.png 424w, https://substackcdn.com/image/fetch/$s_!fjyD!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F38845fb1-1294-46f8-bed3-1feb39ce37df_1194x1044.png 848w, https://substackcdn.com/image/fetch/$s_!fjyD!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F38845fb1-1294-46f8-bed3-1feb39ce37df_1194x1044.png 1272w, https://substackcdn.com/image/fetch/$s_!fjyD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F38845fb1-1294-46f8-bed3-1feb39ce37df_1194x1044.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Then just directly inserting the examples into the prompt!</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!MZjc!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fea4a77e9-5fc6-4c6c-95b7-f2abe9c7e0c5_1226x1470.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!MZjc!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fea4a77e9-5fc6-4c6c-95b7-f2abe9c7e0c5_1226x1470.png 424w, https://substackcdn.com/image/fetch/$s_!MZjc!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fea4a77e9-5fc6-4c6c-95b7-f2abe9c7e0c5_1226x1470.png 848w, https://substackcdn.com/image/fetch/$s_!MZjc!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fea4a77e9-5fc6-4c6c-95b7-f2abe9c7e0c5_1226x1470.png 1272w, https://substackcdn.com/image/fetch/$s_!MZjc!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fea4a77e9-5fc6-4c6c-95b7-f2abe9c7e0c5_1226x1470.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!MZjc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fea4a77e9-5fc6-4c6c-95b7-f2abe9c7e0c5_1226x1470.png" width="1226" height="1470" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ea4a77e9-5fc6-4c6c-95b7-f2abe9c7e0c5_1226x1470.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1470,&quot;width&quot;:1226,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:353988,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167137025?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fea4a77e9-5fc6-4c6c-95b7-f2abe9c7e0c5_1226x1470.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!MZjc!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fea4a77e9-5fc6-4c6c-95b7-f2abe9c7e0c5_1226x1470.png 424w, https://substackcdn.com/image/fetch/$s_!MZjc!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fea4a77e9-5fc6-4c6c-95b7-f2abe9c7e0c5_1226x1470.png 848w, https://substackcdn.com/image/fetch/$s_!MZjc!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fea4a77e9-5fc6-4c6c-95b7-f2abe9c7e0c5_1226x1470.png 1272w, https://substackcdn.com/image/fetch/$s_!MZjc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fea4a77e9-5fc6-4c6c-95b7-f2abe9c7e0c5_1226x1470.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>That&#8217;s it! Now my study plan is a lot more fun and fit for kindergarten-level students: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!GOsQ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6211a921-dc6f-4a8e-bd69-4b4749eb9bb7_1096x1142.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!GOsQ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6211a921-dc6f-4a8e-bd69-4b4749eb9bb7_1096x1142.png 424w, https://substackcdn.com/image/fetch/$s_!GOsQ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6211a921-dc6f-4a8e-bd69-4b4749eb9bb7_1096x1142.png 848w, https://substackcdn.com/image/fetch/$s_!GOsQ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6211a921-dc6f-4a8e-bd69-4b4749eb9bb7_1096x1142.png 1272w, https://substackcdn.com/image/fetch/$s_!GOsQ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6211a921-dc6f-4a8e-bd69-4b4749eb9bb7_1096x1142.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!GOsQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6211a921-dc6f-4a8e-bd69-4b4749eb9bb7_1096x1142.png" width="1096" height="1142" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6211a921-dc6f-4a8e-bd69-4b4749eb9bb7_1096x1142.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1142,&quot;width&quot;:1096,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:251341,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167137025?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6211a921-dc6f-4a8e-bd69-4b4749eb9bb7_1096x1142.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!GOsQ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6211a921-dc6f-4a8e-bd69-4b4749eb9bb7_1096x1142.png 424w, https://substackcdn.com/image/fetch/$s_!GOsQ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6211a921-dc6f-4a8e-bd69-4b4749eb9bb7_1096x1142.png 848w, https://substackcdn.com/image/fetch/$s_!GOsQ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6211a921-dc6f-4a8e-bd69-4b4749eb9bb7_1096x1142.png 1272w, https://substackcdn.com/image/fetch/$s_!GOsQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6211a921-dc6f-4a8e-bd69-4b4749eb9bb7_1096x1142.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h2>Playing with Temperature</h2><p>Since I&#8217;m making a bit of a fun learning app, I want the model to go a bit off-script and generate more fun lesson plans. This can be done in the response options:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!wO8q!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F62d1afd4-a9d5-4bf2-861f-8ada135cab95_1120x592.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!wO8q!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F62d1afd4-a9d5-4bf2-861f-8ada135cab95_1120x592.png 424w, https://substackcdn.com/image/fetch/$s_!wO8q!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F62d1afd4-a9d5-4bf2-861f-8ada135cab95_1120x592.png 848w, https://substackcdn.com/image/fetch/$s_!wO8q!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F62d1afd4-a9d5-4bf2-861f-8ada135cab95_1120x592.png 1272w, https://substackcdn.com/image/fetch/$s_!wO8q!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F62d1afd4-a9d5-4bf2-861f-8ada135cab95_1120x592.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!wO8q!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F62d1afd4-a9d5-4bf2-861f-8ada135cab95_1120x592.png" width="1120" height="592" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/62d1afd4-a9d5-4bf2-861f-8ada135cab95_1120x592.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:592,&quot;width&quot;:1120,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:183634,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167137025?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F62d1afd4-a9d5-4bf2-861f-8ada135cab95_1120x592.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!wO8q!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F62d1afd4-a9d5-4bf2-861f-8ada135cab95_1120x592.png 424w, https://substackcdn.com/image/fetch/$s_!wO8q!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F62d1afd4-a9d5-4bf2-861f-8ada135cab95_1120x592.png 848w, https://substackcdn.com/image/fetch/$s_!wO8q!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F62d1afd4-a9d5-4bf2-861f-8ada135cab95_1120x592.png 1272w, https://substackcdn.com/image/fetch/$s_!wO8q!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F62d1afd4-a9d5-4bf2-861f-8ada135cab95_1120x592.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Here, I set the temperature a bit higher to 0.8 to get more fun responses: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!wFYe!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc60e7216-4ad3-4f85-bf18-3ec1012f96b7_1134x966.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!wFYe!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc60e7216-4ad3-4f85-bf18-3ec1012f96b7_1134x966.png 424w, https://substackcdn.com/image/fetch/$s_!wFYe!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc60e7216-4ad3-4f85-bf18-3ec1012f96b7_1134x966.png 848w, https://substackcdn.com/image/fetch/$s_!wFYe!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc60e7216-4ad3-4f85-bf18-3ec1012f96b7_1134x966.png 1272w, https://substackcdn.com/image/fetch/$s_!wFYe!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc60e7216-4ad3-4f85-bf18-3ec1012f96b7_1134x966.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!wFYe!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc60e7216-4ad3-4f85-bf18-3ec1012f96b7_1134x966.png" width="1134" height="966" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c60e7216-4ad3-4f85-bf18-3ec1012f96b7_1134x966.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:966,&quot;width&quot;:1134,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:203568,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167137025?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc60e7216-4ad3-4f85-bf18-3ec1012f96b7_1134x966.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!wFYe!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc60e7216-4ad3-4f85-bf18-3ec1012f96b7_1134x966.png 424w, https://substackcdn.com/image/fetch/$s_!wFYe!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc60e7216-4ad3-4f85-bf18-3ec1012f96b7_1134x966.png 848w, https://substackcdn.com/image/fetch/$s_!wFYe!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc60e7216-4ad3-4f85-bf18-3ec1012f96b7_1134x966.png 1272w, https://substackcdn.com/image/fetch/$s_!wFYe!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc60e7216-4ad3-4f85-bf18-3ec1012f96b7_1134x966.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>I tried higher temperatures, but that produces inconsistent and more non-sensical responses. So that is just something to play around with and test. </p><p>If you want a much more conservative deterministic response that will follow the guides you set on your Generable option, set the sampling to greedy: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ACcB!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8a2a235-e8cd-401d-a367-abdd04d0b404_1132x596.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ACcB!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8a2a235-e8cd-401d-a367-abdd04d0b404_1132x596.png 424w, https://substackcdn.com/image/fetch/$s_!ACcB!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8a2a235-e8cd-401d-a367-abdd04d0b404_1132x596.png 848w, https://substackcdn.com/image/fetch/$s_!ACcB!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8a2a235-e8cd-401d-a367-abdd04d0b404_1132x596.png 1272w, https://substackcdn.com/image/fetch/$s_!ACcB!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8a2a235-e8cd-401d-a367-abdd04d0b404_1132x596.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ACcB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8a2a235-e8cd-401d-a367-abdd04d0b404_1132x596.png" width="1132" height="596" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a8a2a235-e8cd-401d-a367-abdd04d0b404_1132x596.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:596,&quot;width&quot;:1132,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:186612,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167137025?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8a2a235-e8cd-401d-a367-abdd04d0b404_1132x596.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ACcB!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8a2a235-e8cd-401d-a367-abdd04d0b404_1132x596.png 424w, https://substackcdn.com/image/fetch/$s_!ACcB!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8a2a235-e8cd-401d-a367-abdd04d0b404_1132x596.png 848w, https://substackcdn.com/image/fetch/$s_!ACcB!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8a2a235-e8cd-401d-a367-abdd04d0b404_1132x596.png 1272w, https://substackcdn.com/image/fetch/$s_!ACcB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8a2a235-e8cd-401d-a367-abdd04d0b404_1132x596.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>You&#8217;ll get a much more &#8220;normal&#8221; sounding study plan: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!JGtm!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8849b98-d3db-49e3-852f-2de634e8f2e8_1088x1128.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!JGtm!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8849b98-d3db-49e3-852f-2de634e8f2e8_1088x1128.png 424w, https://substackcdn.com/image/fetch/$s_!JGtm!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8849b98-d3db-49e3-852f-2de634e8f2e8_1088x1128.png 848w, https://substackcdn.com/image/fetch/$s_!JGtm!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8849b98-d3db-49e3-852f-2de634e8f2e8_1088x1128.png 1272w, https://substackcdn.com/image/fetch/$s_!JGtm!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8849b98-d3db-49e3-852f-2de634e8f2e8_1088x1128.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!JGtm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8849b98-d3db-49e3-852f-2de634e8f2e8_1088x1128.png" width="1088" height="1128" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e8849b98-d3db-49e3-852f-2de634e8f2e8_1088x1128.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1128,&quot;width&quot;:1088,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:244398,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167137025?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8849b98-d3db-49e3-852f-2de634e8f2e8_1088x1128.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!JGtm!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8849b98-d3db-49e3-852f-2de634e8f2e8_1088x1128.png 424w, https://substackcdn.com/image/fetch/$s_!JGtm!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8849b98-d3db-49e3-852f-2de634e8f2e8_1088x1128.png 848w, https://substackcdn.com/image/fetch/$s_!JGtm!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8849b98-d3db-49e3-852f-2de634e8f2e8_1088x1128.png 1272w, https://substackcdn.com/image/fetch/$s_!JGtm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8849b98-d3db-49e3-852f-2de634e8f2e8_1088x1128.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>I just want to say again how nice it is to test all of this right inside Xcode in the #Playground macro super fast versus the usual of making API calls and waiting for responses, debugging JSON decoding and all that! </p><h2>Other Tips</h2><p>A few other simple prompt tips include: </p><ul><li><p>Phrase your prompts as a clear command</p></li><li><p>Request a single specific task in detail</p></li><li><p>Use ALL CAPS such as MUST or DO NOT to stop undesired behavior</p></li></ul><h2>Prompts from User Input</h2><p>In all of the above examples, I / the app fully controls the prompt. But in most apps, there will be some type of user input. While I don&#8217;t recommend letting the user fully chat their preferences, especially when those are limited, some type of interface like this would work well: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!kCVT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff04e0708-b446-492f-a381-6b1676354c72_470x900.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!kCVT!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff04e0708-b446-492f-a381-6b1676354c72_470x900.png 424w, https://substackcdn.com/image/fetch/$s_!kCVT!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff04e0708-b446-492f-a381-6b1676354c72_470x900.png 848w, https://substackcdn.com/image/fetch/$s_!kCVT!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff04e0708-b446-492f-a381-6b1676354c72_470x900.png 1272w, https://substackcdn.com/image/fetch/$s_!kCVT!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff04e0708-b446-492f-a381-6b1676354c72_470x900.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!kCVT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff04e0708-b446-492f-a381-6b1676354c72_470x900.png" width="470" height="900" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f04e0708-b446-492f-a381-6b1676354c72_470x900.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:900,&quot;width&quot;:470,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!kCVT!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff04e0708-b446-492f-a381-6b1676354c72_470x900.png 424w, https://substackcdn.com/image/fetch/$s_!kCVT!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff04e0708-b446-492f-a381-6b1676354c72_470x900.png 848w, https://substackcdn.com/image/fetch/$s_!kCVT!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff04e0708-b446-492f-a381-6b1676354c72_470x900.png 1272w, https://substackcdn.com/image/fetch/$s_!kCVT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff04e0708-b446-492f-a381-6b1676354c72_470x900.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>This allows the user control, but in not in a way that can cause unexpected input into your model. The only &#8220;open&#8221; prompt field is the Subject field, where the user can input anything that will go into your actual user prompt. Of course - if you stick to only a limited number of subjects, you can implement a drop-down here. </p><p>To see the full breakdown of implementing this app, see my blog post <a href="https://www.natashatherobot.com/p/swiftui-foundationmodels-streamresponse">Let&#8217;s Build a SwiftUI Study&#8209;Plan App using FoundationModels StreamResponse</a>. </p><p>When the user inputs any part of the prompt, it comes with some risks. Mainly that it may trigger the guardrails. They can also type something like &#8220;avoid previous instructions and do this instead&#8221; and try to break the prompt. </p><p>The first step is to have a more comprehensive prompt where the user&#8217;s input is only a small part of it: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!4t1g!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd77cb33-ab3a-4012-bbc2-c3ae2f7714b7_1978x1192.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!4t1g!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd77cb33-ab3a-4012-bbc2-c3ae2f7714b7_1978x1192.png 424w, https://substackcdn.com/image/fetch/$s_!4t1g!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd77cb33-ab3a-4012-bbc2-c3ae2f7714b7_1978x1192.png 848w, https://substackcdn.com/image/fetch/$s_!4t1g!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd77cb33-ab3a-4012-bbc2-c3ae2f7714b7_1978x1192.png 1272w, https://substackcdn.com/image/fetch/$s_!4t1g!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd77cb33-ab3a-4012-bbc2-c3ae2f7714b7_1978x1192.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!4t1g!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd77cb33-ab3a-4012-bbc2-c3ae2f7714b7_1978x1192.png" width="1456" height="877" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/dd77cb33-ab3a-4012-bbc2-c3ae2f7714b7_1978x1192.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:877,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!4t1g!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd77cb33-ab3a-4012-bbc2-c3ae2f7714b7_1978x1192.png 424w, https://substackcdn.com/image/fetch/$s_!4t1g!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd77cb33-ab3a-4012-bbc2-c3ae2f7714b7_1978x1192.png 848w, https://substackcdn.com/image/fetch/$s_!4t1g!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd77cb33-ab3a-4012-bbc2-c3ae2f7714b7_1978x1192.png 1272w, https://substackcdn.com/image/fetch/$s_!4t1g!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd77cb33-ab3a-4012-bbc2-c3ae2f7714b7_1978x1192.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Here - only the subject field is input by the user directly. All else is selected from the limited UI. </p><p>But the more important part is figuring out how to handle errors if the user does input something inappropriate that triggers the model&#8217;s guardrails. The LanguageModelSession throws specialized errors: </p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!c_R7!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76e2f9fe-c969-4e66-9cf9-71abc6e60e63_948x106.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!c_R7!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76e2f9fe-c969-4e66-9cf9-71abc6e60e63_948x106.png 424w, https://substackcdn.com/image/fetch/$s_!c_R7!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76e2f9fe-c969-4e66-9cf9-71abc6e60e63_948x106.png 848w, https://substackcdn.com/image/fetch/$s_!c_R7!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76e2f9fe-c969-4e66-9cf9-71abc6e60e63_948x106.png 1272w, https://substackcdn.com/image/fetch/$s_!c_R7!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76e2f9fe-c969-4e66-9cf9-71abc6e60e63_948x106.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!c_R7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76e2f9fe-c969-4e66-9cf9-71abc6e60e63_948x106.png" width="948" height="106" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/76e2f9fe-c969-4e66-9cf9-71abc6e60e63_948x106.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:106,&quot;width&quot;:948,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!c_R7!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76e2f9fe-c969-4e66-9cf9-71abc6e60e63_948x106.png 424w, https://substackcdn.com/image/fetch/$s_!c_R7!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76e2f9fe-c969-4e66-9cf9-71abc6e60e63_948x106.png 848w, https://substackcdn.com/image/fetch/$s_!c_R7!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76e2f9fe-c969-4e66-9cf9-71abc6e60e63_948x106.png 1272w, https://substackcdn.com/image/fetch/$s_!c_R7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76e2f9fe-c969-4e66-9cf9-71abc6e60e63_948x106.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>It is your responsibility to think through how to handle these errors in your UI: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ZLDt!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c6c28ee-68de-4593-8565-fad8e25119c0_1904x988.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ZLDt!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c6c28ee-68de-4593-8565-fad8e25119c0_1904x988.png 424w, https://substackcdn.com/image/fetch/$s_!ZLDt!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c6c28ee-68de-4593-8565-fad8e25119c0_1904x988.png 848w, https://substackcdn.com/image/fetch/$s_!ZLDt!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c6c28ee-68de-4593-8565-fad8e25119c0_1904x988.png 1272w, https://substackcdn.com/image/fetch/$s_!ZLDt!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c6c28ee-68de-4593-8565-fad8e25119c0_1904x988.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ZLDt!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c6c28ee-68de-4593-8565-fad8e25119c0_1904x988.png" width="1456" height="756" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6c6c28ee-68de-4593-8565-fad8e25119c0_1904x988.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:756,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ZLDt!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c6c28ee-68de-4593-8565-fad8e25119c0_1904x988.png 424w, https://substackcdn.com/image/fetch/$s_!ZLDt!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c6c28ee-68de-4593-8565-fad8e25119c0_1904x988.png 848w, https://substackcdn.com/image/fetch/$s_!ZLDt!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c6c28ee-68de-4593-8565-fad8e25119c0_1904x988.png 1272w, https://substackcdn.com/image/fetch/$s_!ZLDt!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c6c28ee-68de-4593-8565-fad8e25119c0_1904x988.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>For example, if the user triggers the guardrails due to wrong behavior in a social app, you may have to implement a &#8220;3 strikes you&#8217;re out&#8221; policy to disable thtat user&#8217;s accounts or to make them invisible to others. </p><p>Other times, you may just ignore the error and not do anything and simply prompt the user to try again. Or adjust the UI accordingly to a fallback option. How you handle the user-related prompt input errors is different for every app use-case. Don&#8217;t forget to experiment with many edge cases and figure out how to handle this in your app!</p><h2>Conclusion</h2><p>After two years of working with Python and web-based LLM APIs, it&#8217;s incredibly exciting to finally have a model that <em>just works</em> with Swift and SwiftUI. Apple&#8217;s Foundation Model brings LLMs into the native app development workflow in a way that feels seamless, type-safe, and purpose-built. With tools like Generable, guided output, and on-device testing via Playgrounds, we can now experiment and iterate faster, without worrying about JSON formatting or remote API quirks. </p><p>Happy Prompting in Swift &#128640;</p><p> </p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.natashatherobot.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">This Substack is reader-supported. To receive new posts and support my work, consider becoming a free or paid subscriber.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Let’s Build a SwiftUI Study‑Plan App using FoundationModels StreamResponse]]></title><description><![CDATA[Learn how to build a real-time, token-streaming Study Plan app in SwiftUI using Apple&#8217;s FoundationModels framework and its powerful StreamResponse API.]]></description><link>https://www.natashatherobot.com/p/swiftui-foundationmodels-streamresponse</link><guid isPermaLink="false">https://www.natashatherobot.com/p/swiftui-foundationmodels-streamresponse</guid><dc:creator><![CDATA[NatashaTheRobot]]></dc:creator><pubDate>Sun, 29 Jun 2025 07:01:22 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!31xi!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6e217957-c7c6-4b27-8d9c-251f52d8370e_1308x670.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>This is a continuation of my beginner series about Apple&#8217;s FoundationModels Framework. Read <em><a href="https://www.natashatherobot.com/p/apple-foundation-models">Introduction to Apple's FoundationModels: Limitations, Capabilities, Tools</a> </em>first. </p><p>One of the most mind-blowing API design features of the FoundationModels framework is how it integrates with SwiftUI. Specifically, how you can show the results to the user as the model is generating them token-by-token. Let me show you the magic in the example Study Plan app I built: </p><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;9bf2e3f5-ee18-4e26-bda9-cfbc99a2b5f2&quot;,&quot;duration&quot;:null}"></div><p>So how does this work? It&#8217;s super simple! </p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.natashatherobot.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">This Substack is reader-supported. To receive new posts and support my work, consider becoming a free or paid subscriber.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><h2>Define the Generable Models</h2><p>The first step is to define the models that the FoundationModels framework will generate. For the Study Plan app, it&#8217;ll be a <code>StudyPlan</code> model with <code>WeeklyStudy</code> topics with <code>StudySessions</code>:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!31xi!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6e217957-c7c6-4b27-8d9c-251f52d8370e_1308x670.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!31xi!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6e217957-c7c6-4b27-8d9c-251f52d8370e_1308x670.png 424w, https://substackcdn.com/image/fetch/$s_!31xi!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6e217957-c7c6-4b27-8d9c-251f52d8370e_1308x670.png 848w, https://substackcdn.com/image/fetch/$s_!31xi!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6e217957-c7c6-4b27-8d9c-251f52d8370e_1308x670.png 1272w, https://substackcdn.com/image/fetch/$s_!31xi!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6e217957-c7c6-4b27-8d9c-251f52d8370e_1308x670.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!31xi!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6e217957-c7c6-4b27-8d9c-251f52d8370e_1308x670.png" width="1308" height="670" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6e217957-c7c6-4b27-8d9c-251f52d8370e_1308x670.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:670,&quot;width&quot;:1308,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:197702,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167081157?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6e217957-c7c6-4b27-8d9c-251f52d8370e_1308x670.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!31xi!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6e217957-c7c6-4b27-8d9c-251f52d8370e_1308x670.png 424w, https://substackcdn.com/image/fetch/$s_!31xi!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6e217957-c7c6-4b27-8d9c-251f52d8370e_1308x670.png 848w, https://substackcdn.com/image/fetch/$s_!31xi!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6e217957-c7c6-4b27-8d9c-251f52d8370e_1308x670.png 1272w, https://substackcdn.com/image/fetch/$s_!31xi!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6e217957-c7c6-4b27-8d9c-251f52d8370e_1308x670.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!eYvH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d82fca9-dbc7-402d-b57c-48790a22e681_1290x566.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!eYvH!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d82fca9-dbc7-402d-b57c-48790a22e681_1290x566.png 424w, https://substackcdn.com/image/fetch/$s_!eYvH!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d82fca9-dbc7-402d-b57c-48790a22e681_1290x566.png 848w, https://substackcdn.com/image/fetch/$s_!eYvH!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d82fca9-dbc7-402d-b57c-48790a22e681_1290x566.png 1272w, https://substackcdn.com/image/fetch/$s_!eYvH!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d82fca9-dbc7-402d-b57c-48790a22e681_1290x566.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!eYvH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d82fca9-dbc7-402d-b57c-48790a22e681_1290x566.png" width="1290" height="566" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6d82fca9-dbc7-402d-b57c-48790a22e681_1290x566.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:566,&quot;width&quot;:1290,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:167088,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167081157?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d82fca9-dbc7-402d-b57c-48790a22e681_1290x566.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!eYvH!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d82fca9-dbc7-402d-b57c-48790a22e681_1290x566.png 424w, https://substackcdn.com/image/fetch/$s_!eYvH!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d82fca9-dbc7-402d-b57c-48790a22e681_1290x566.png 848w, https://substackcdn.com/image/fetch/$s_!eYvH!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d82fca9-dbc7-402d-b57c-48790a22e681_1290x566.png 1272w, https://substackcdn.com/image/fetch/$s_!eYvH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6d82fca9-dbc7-402d-b57c-48790a22e681_1290x566.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!hTZ2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F250d856e-d249-4609-8372-aa1d4f1f5d0c_1368x690.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!hTZ2!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F250d856e-d249-4609-8372-aa1d4f1f5d0c_1368x690.png 424w, https://substackcdn.com/image/fetch/$s_!hTZ2!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F250d856e-d249-4609-8372-aa1d4f1f5d0c_1368x690.png 848w, https://substackcdn.com/image/fetch/$s_!hTZ2!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F250d856e-d249-4609-8372-aa1d4f1f5d0c_1368x690.png 1272w, https://substackcdn.com/image/fetch/$s_!hTZ2!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F250d856e-d249-4609-8372-aa1d4f1f5d0c_1368x690.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!hTZ2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F250d856e-d249-4609-8372-aa1d4f1f5d0c_1368x690.png" width="1368" height="690" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/250d856e-d249-4609-8372-aa1d4f1f5d0c_1368x690.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:690,&quot;width&quot;:1368,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:212530,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167081157?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F250d856e-d249-4609-8372-aa1d4f1f5d0c_1368x690.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!hTZ2!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F250d856e-d249-4609-8372-aa1d4f1f5d0c_1368x690.png 424w, https://substackcdn.com/image/fetch/$s_!hTZ2!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F250d856e-d249-4609-8372-aa1d4f1f5d0c_1368x690.png 848w, https://substackcdn.com/image/fetch/$s_!hTZ2!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F250d856e-d249-4609-8372-aa1d4f1f5d0c_1368x690.png 1272w, https://substackcdn.com/image/fetch/$s_!hTZ2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F250d856e-d249-4609-8372-aa1d4f1f5d0c_1368x690.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Note that the FoundationModel will generate ALL fields regardless of whether they are being displayed to the user or not. So if you have a bigger model that has some non-generated content and some generated content, keep the generated content as separate objects, and just sync the generated info back into the bigger model (maybe saved in SwiftData) once it fully generates. Keep the Generable models as separate entities only used for generating information as needed!  </p><h2>The UI </h2><p>One option is to build a chat-based UI for getting the user&#8217;s study plan preferences that are needed as input to the model. However, I would argue that this is more difficult for the user than building a much more quick and simple input screen, especially if you do have extremely specific input: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!kCVT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff04e0708-b446-492f-a381-6b1676354c72_470x900.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!kCVT!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff04e0708-b446-492f-a381-6b1676354c72_470x900.png 424w, https://substackcdn.com/image/fetch/$s_!kCVT!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff04e0708-b446-492f-a381-6b1676354c72_470x900.png 848w, https://substackcdn.com/image/fetch/$s_!kCVT!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff04e0708-b446-492f-a381-6b1676354c72_470x900.png 1272w, https://substackcdn.com/image/fetch/$s_!kCVT!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff04e0708-b446-492f-a381-6b1676354c72_470x900.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!kCVT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff04e0708-b446-492f-a381-6b1676354c72_470x900.png" width="470" height="900" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f04e0708-b446-492f-a381-6b1676354c72_470x900.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:900,&quot;width&quot;:470,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:159808,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167081157?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5808d63a-9a1e-45cd-930f-504ea77b1d76_470x946.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!kCVT!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff04e0708-b446-492f-a381-6b1676354c72_470x900.png 424w, https://substackcdn.com/image/fetch/$s_!kCVT!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff04e0708-b446-492f-a381-6b1676354c72_470x900.png 848w, https://substackcdn.com/image/fetch/$s_!kCVT!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff04e0708-b446-492f-a381-6b1676354c72_470x900.png 1272w, https://substackcdn.com/image/fetch/$s_!kCVT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff04e0708-b446-492f-a381-6b1676354c72_470x900.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>I would argue that even though we&#8217;re used to the chat-based interfaces of ChatGPT, it might not be the best UI for most use-cased on mobile. Especially when it&#8217;s as simple as the form above. </p><p>Once the user enters the Subject of their study and clicks on &#8220;Generate Study Plan&#8221;, the model is ready to stream! </p><p>Once the app gathers the required information from the user, it can be put into the prompt. </p><h2>The Prompt</h2><p>Using the specific input values of the user, the prompt is generated as follows in the <code>StudyPlanViewModel</code>: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!4t1g!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd77cb33-ab3a-4012-bbc2-c3ae2f7714b7_1978x1192.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!4t1g!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd77cb33-ab3a-4012-bbc2-c3ae2f7714b7_1978x1192.png 424w, https://substackcdn.com/image/fetch/$s_!4t1g!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd77cb33-ab3a-4012-bbc2-c3ae2f7714b7_1978x1192.png 848w, https://substackcdn.com/image/fetch/$s_!4t1g!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd77cb33-ab3a-4012-bbc2-c3ae2f7714b7_1978x1192.png 1272w, https://substackcdn.com/image/fetch/$s_!4t1g!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd77cb33-ab3a-4012-bbc2-c3ae2f7714b7_1978x1192.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!4t1g!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd77cb33-ab3a-4012-bbc2-c3ae2f7714b7_1978x1192.png" width="1456" height="877" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/dd77cb33-ab3a-4012-bbc2-c3ae2f7714b7_1978x1192.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:877,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:375917,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167081157?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd77cb33-ab3a-4012-bbc2-c3ae2f7714b7_1978x1192.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!4t1g!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd77cb33-ab3a-4012-bbc2-c3ae2f7714b7_1978x1192.png 424w, https://substackcdn.com/image/fetch/$s_!4t1g!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd77cb33-ab3a-4012-bbc2-c3ae2f7714b7_1978x1192.png 848w, https://substackcdn.com/image/fetch/$s_!4t1g!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd77cb33-ab3a-4012-bbc2-c3ae2f7714b7_1978x1192.png 1272w, https://substackcdn.com/image/fetch/$s_!4t1g!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdd77cb33-ab3a-4012-bbc2-c3ae2f7714b7_1978x1192.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Again - keep in mind the context window here. The longer the prompt, the less context for output tokens&#8230; So it&#8217;s a balance. You want the prompt to be specific, but not so long so that it eats up the context window. This is where it&#8217;s important to test out shorter versions of the prompt to provide the same quality level of output. </p><h2>PartiallyGenerated</h2><p>Let&#8217;s go back to running a &#8220;Hello, World!&#8221; prompt in the FoundationModels framework: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!n40Z!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcef7aae2-c260-4b65-8c4f-66c78e47b847_2644x1192.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!n40Z!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcef7aae2-c260-4b65-8c4f-66c78e47b847_2644x1192.png 424w, https://substackcdn.com/image/fetch/$s_!n40Z!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcef7aae2-c260-4b65-8c4f-66c78e47b847_2644x1192.png 848w, https://substackcdn.com/image/fetch/$s_!n40Z!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcef7aae2-c260-4b65-8c4f-66c78e47b847_2644x1192.png 1272w, https://substackcdn.com/image/fetch/$s_!n40Z!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcef7aae2-c260-4b65-8c4f-66c78e47b847_2644x1192.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!n40Z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcef7aae2-c260-4b65-8c4f-66c78e47b847_2644x1192.png" width="1456" height="656" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/cef7aae2-c260-4b65-8c4f-66c78e47b847_2644x1192.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:656,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:418743,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167081157?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcef7aae2-c260-4b65-8c4f-66c78e47b847_2644x1192.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!n40Z!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcef7aae2-c260-4b65-8c4f-66c78e47b847_2644x1192.png 424w, https://substackcdn.com/image/fetch/$s_!n40Z!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcef7aae2-c260-4b65-8c4f-66c78e47b847_2644x1192.png 848w, https://substackcdn.com/image/fetch/$s_!n40Z!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcef7aae2-c260-4b65-8c4f-66c78e47b847_2644x1192.png 1272w, https://substackcdn.com/image/fetch/$s_!n40Z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcef7aae2-c260-4b65-8c4f-66c78e47b847_2644x1192.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>As you can see, the model took 1 second to respond with &#8220;Hello! How can I assist you today?&#8221; This seems super fast, and it is! But as your prompt and output requirements become bigger and bigger the time can significantly slow down. </p><p>Since we don&#8217;t want the user starting at a spinner, the FoundationModels API provides a nice <code>streamResponse</code> function for the session that will stream the response as it is generated token-by-token by the model: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!cKoq!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7a3d256-f648-440b-9857-13f9eb0bd6e2_2658x1236.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!cKoq!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7a3d256-f648-440b-9857-13f9eb0bd6e2_2658x1236.png 424w, https://substackcdn.com/image/fetch/$s_!cKoq!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7a3d256-f648-440b-9857-13f9eb0bd6e2_2658x1236.png 848w, https://substackcdn.com/image/fetch/$s_!cKoq!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7a3d256-f648-440b-9857-13f9eb0bd6e2_2658x1236.png 1272w, https://substackcdn.com/image/fetch/$s_!cKoq!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7a3d256-f648-440b-9857-13f9eb0bd6e2_2658x1236.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!cKoq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7a3d256-f648-440b-9857-13f9eb0bd6e2_2658x1236.png" width="1456" height="677" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f7a3d256-f648-440b-9857-13f9eb0bd6e2_2658x1236.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:677,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:426162,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167081157?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7a3d256-f648-440b-9857-13f9eb0bd6e2_2658x1236.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!cKoq!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7a3d256-f648-440b-9857-13f9eb0bd6e2_2658x1236.png 424w, https://substackcdn.com/image/fetch/$s_!cKoq!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7a3d256-f648-440b-9857-13f9eb0bd6e2_2658x1236.png 848w, https://substackcdn.com/image/fetch/$s_!cKoq!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7a3d256-f648-440b-9857-13f9eb0bd6e2_2658x1236.png 1272w, https://substackcdn.com/image/fetch/$s_!cKoq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7a3d256-f648-440b-9857-13f9eb0bd6e2_2658x1236.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Notice that it first printed <strong>&#8220;Hello&#8221;</strong>, then continued to<strong> &#8220;Hello! How can I assist&#8221;</strong> then <strong>&#8220;Hello! How can I assist you today?&#8221;</strong>. Each of these output is of <strong>String.PartiallyGenerated </strong>type which is output by the stream:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!EThh!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F990c2e08-f4f2-4e14-bea6-3dc87be9c036_1290x616.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!EThh!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F990c2e08-f4f2-4e14-bea6-3dc87be9c036_1290x616.png 424w, https://substackcdn.com/image/fetch/$s_!EThh!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F990c2e08-f4f2-4e14-bea6-3dc87be9c036_1290x616.png 848w, https://substackcdn.com/image/fetch/$s_!EThh!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F990c2e08-f4f2-4e14-bea6-3dc87be9c036_1290x616.png 1272w, https://substackcdn.com/image/fetch/$s_!EThh!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F990c2e08-f4f2-4e14-bea6-3dc87be9c036_1290x616.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!EThh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F990c2e08-f4f2-4e14-bea6-3dc87be9c036_1290x616.png" width="1290" height="616" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/990c2e08-f4f2-4e14-bea6-3dc87be9c036_1290x616.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:616,&quot;width&quot;:1290,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:188955,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167081157?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F990c2e08-f4f2-4e14-bea6-3dc87be9c036_1290x616.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!EThh!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F990c2e08-f4f2-4e14-bea6-3dc87be9c036_1290x616.png 424w, https://substackcdn.com/image/fetch/$s_!EThh!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F990c2e08-f4f2-4e14-bea6-3dc87be9c036_1290x616.png 848w, https://substackcdn.com/image/fetch/$s_!EThh!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F990c2e08-f4f2-4e14-bea6-3dc87be9c036_1290x616.png 1272w, https://substackcdn.com/image/fetch/$s_!EThh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F990c2e08-f4f2-4e14-bea6-3dc87be9c036_1290x616.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>The <code>Generable</code> macro will automatically create the <code>PartiallyGenerated</code> type for any object in the same way - so nothing else is needed to be done to our custom <code>StudyPlan</code> project for this to work! </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!mnw1!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6541a16-93cb-4d6a-b5a9-527b2162a456_1326x558.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!mnw1!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6541a16-93cb-4d6a-b5a9-527b2162a456_1326x558.png 424w, https://substackcdn.com/image/fetch/$s_!mnw1!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6541a16-93cb-4d6a-b5a9-527b2162a456_1326x558.png 848w, https://substackcdn.com/image/fetch/$s_!mnw1!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6541a16-93cb-4d6a-b5a9-527b2162a456_1326x558.png 1272w, https://substackcdn.com/image/fetch/$s_!mnw1!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6541a16-93cb-4d6a-b5a9-527b2162a456_1326x558.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!mnw1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6541a16-93cb-4d6a-b5a9-527b2162a456_1326x558.png" width="1326" height="558" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b6541a16-93cb-4d6a-b5a9-527b2162a456_1326x558.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:558,&quot;width&quot;:1326,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:182842,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167081157?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6541a16-93cb-4d6a-b5a9-527b2162a456_1326x558.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!mnw1!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6541a16-93cb-4d6a-b5a9-527b2162a456_1326x558.png 424w, https://substackcdn.com/image/fetch/$s_!mnw1!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6541a16-93cb-4d6a-b5a9-527b2162a456_1326x558.png 848w, https://substackcdn.com/image/fetch/$s_!mnw1!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6541a16-93cb-4d6a-b5a9-527b2162a456_1326x558.png 1272w, https://substackcdn.com/image/fetch/$s_!mnw1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6541a16-93cb-4d6a-b5a9-527b2162a456_1326x558.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>We simply use the <code>PartiallyGenerated</code> type directly in the View or ViewModel! That&#8217;s it! </p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!XZTz!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc49250c6-8539-4b59-a29b-39f8aa7a30ca_1370x236.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!XZTz!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc49250c6-8539-4b59-a29b-39f8aa7a30ca_1370x236.png 424w, https://substackcdn.com/image/fetch/$s_!XZTz!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc49250c6-8539-4b59-a29b-39f8aa7a30ca_1370x236.png 848w, https://substackcdn.com/image/fetch/$s_!XZTz!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc49250c6-8539-4b59-a29b-39f8aa7a30ca_1370x236.png 1272w, https://substackcdn.com/image/fetch/$s_!XZTz!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc49250c6-8539-4b59-a29b-39f8aa7a30ca_1370x236.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!XZTz!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc49250c6-8539-4b59-a29b-39f8aa7a30ca_1370x236.png" width="1370" height="236" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c49250c6-8539-4b59-a29b-39f8aa7a30ca_1370x236.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:236,&quot;width&quot;:1370,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:84085,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167081157?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc49250c6-8539-4b59-a29b-39f8aa7a30ca_1370x236.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!XZTz!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc49250c6-8539-4b59-a29b-39f8aa7a30ca_1370x236.png 424w, https://substackcdn.com/image/fetch/$s_!XZTz!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc49250c6-8539-4b59-a29b-39f8aa7a30ca_1370x236.png 848w, https://substackcdn.com/image/fetch/$s_!XZTz!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc49250c6-8539-4b59-a29b-39f8aa7a30ca_1370x236.png 1272w, https://substackcdn.com/image/fetch/$s_!XZTz!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc49250c6-8539-4b59-a29b-39f8aa7a30ca_1370x236.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!NvJ5!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55437705-eef7-44c6-9b08-20d71533b0b8_1144x202.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!NvJ5!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55437705-eef7-44c6-9b08-20d71533b0b8_1144x202.png 424w, https://substackcdn.com/image/fetch/$s_!NvJ5!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55437705-eef7-44c6-9b08-20d71533b0b8_1144x202.png 848w, https://substackcdn.com/image/fetch/$s_!NvJ5!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55437705-eef7-44c6-9b08-20d71533b0b8_1144x202.png 1272w, https://substackcdn.com/image/fetch/$s_!NvJ5!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55437705-eef7-44c6-9b08-20d71533b0b8_1144x202.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!NvJ5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55437705-eef7-44c6-9b08-20d71533b0b8_1144x202.png" width="1144" height="202" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/55437705-eef7-44c6-9b08-20d71533b0b8_1144x202.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:202,&quot;width&quot;:1144,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:59154,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167081157?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55437705-eef7-44c6-9b08-20d71533b0b8_1144x202.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!NvJ5!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55437705-eef7-44c6-9b08-20d71533b0b8_1144x202.png 424w, https://substackcdn.com/image/fetch/$s_!NvJ5!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55437705-eef7-44c6-9b08-20d71533b0b8_1144x202.png 848w, https://substackcdn.com/image/fetch/$s_!NvJ5!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55437705-eef7-44c6-9b08-20d71533b0b8_1144x202.png 1272w, https://substackcdn.com/image/fetch/$s_!NvJ5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55437705-eef7-44c6-9b08-20d71533b0b8_1144x202.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>The same applies for other embedding <code>Generable</code> objects inside the StudyPlan! </p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!0WTI!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c7333af-334e-4464-9a41-3717d0c7d9a1_1192x196.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!0WTI!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c7333af-334e-4464-9a41-3717d0c7d9a1_1192x196.png 424w, https://substackcdn.com/image/fetch/$s_!0WTI!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c7333af-334e-4464-9a41-3717d0c7d9a1_1192x196.png 848w, https://substackcdn.com/image/fetch/$s_!0WTI!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c7333af-334e-4464-9a41-3717d0c7d9a1_1192x196.png 1272w, https://substackcdn.com/image/fetch/$s_!0WTI!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c7333af-334e-4464-9a41-3717d0c7d9a1_1192x196.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!0WTI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c7333af-334e-4464-9a41-3717d0c7d9a1_1192x196.png" width="1192" height="196" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2c7333af-334e-4464-9a41-3717d0c7d9a1_1192x196.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:196,&quot;width&quot;:1192,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:61571,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167081157?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c7333af-334e-4464-9a41-3717d0c7d9a1_1192x196.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!0WTI!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c7333af-334e-4464-9a41-3717d0c7d9a1_1192x196.png 424w, https://substackcdn.com/image/fetch/$s_!0WTI!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c7333af-334e-4464-9a41-3717d0c7d9a1_1192x196.png 848w, https://substackcdn.com/image/fetch/$s_!0WTI!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c7333af-334e-4464-9a41-3717d0c7d9a1_1192x196.png 1272w, https://substackcdn.com/image/fetch/$s_!0WTI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c7333af-334e-4464-9a41-3717d0c7d9a1_1192x196.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!nZCH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7e247c6-6774-480f-a57f-7143f06324b7_1130x206.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!nZCH!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7e247c6-6774-480f-a57f-7143f06324b7_1130x206.png 424w, https://substackcdn.com/image/fetch/$s_!nZCH!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7e247c6-6774-480f-a57f-7143f06324b7_1130x206.png 848w, https://substackcdn.com/image/fetch/$s_!nZCH!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7e247c6-6774-480f-a57f-7143f06324b7_1130x206.png 1272w, https://substackcdn.com/image/fetch/$s_!nZCH!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7e247c6-6774-480f-a57f-7143f06324b7_1130x206.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!nZCH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7e247c6-6774-480f-a57f-7143f06324b7_1130x206.png" width="1130" height="206" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f7e247c6-6774-480f-a57f-7143f06324b7_1130x206.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:206,&quot;width&quot;:1130,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:57455,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167081157?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7e247c6-6774-480f-a57f-7143f06324b7_1130x206.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!nZCH!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7e247c6-6774-480f-a57f-7143f06324b7_1130x206.png 424w, https://substackcdn.com/image/fetch/$s_!nZCH!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7e247c6-6774-480f-a57f-7143f06324b7_1130x206.png 848w, https://substackcdn.com/image/fetch/$s_!nZCH!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7e247c6-6774-480f-a57f-7143f06324b7_1130x206.png 1272w, https://substackcdn.com/image/fetch/$s_!nZCH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7e247c6-6774-480f-a57f-7143f06324b7_1130x206.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>The only difference here is that <strong>every variable of the PartiallyGenerated object can be nil </strong>even if the variable is required in the original object! </p><p>For example, my <code>StudyPlan</code> object with all required parameters: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!RzJb!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fced22edd-5892-4cb3-8990-aa0683e98a25_886x402.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!RzJb!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fced22edd-5892-4cb3-8990-aa0683e98a25_886x402.png 424w, https://substackcdn.com/image/fetch/$s_!RzJb!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fced22edd-5892-4cb3-8990-aa0683e98a25_886x402.png 848w, https://substackcdn.com/image/fetch/$s_!RzJb!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fced22edd-5892-4cb3-8990-aa0683e98a25_886x402.png 1272w, https://substackcdn.com/image/fetch/$s_!RzJb!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fced22edd-5892-4cb3-8990-aa0683e98a25_886x402.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!RzJb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fced22edd-5892-4cb3-8990-aa0683e98a25_886x402.png" width="886" height="402" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ced22edd-5892-4cb3-8990-aa0683e98a25_886x402.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:402,&quot;width&quot;:886,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:110399,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167081157?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fced22edd-5892-4cb3-8990-aa0683e98a25_886x402.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!RzJb!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fced22edd-5892-4cb3-8990-aa0683e98a25_886x402.png 424w, https://substackcdn.com/image/fetch/$s_!RzJb!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fced22edd-5892-4cb3-8990-aa0683e98a25_886x402.png 848w, https://substackcdn.com/image/fetch/$s_!RzJb!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fced22edd-5892-4cb3-8990-aa0683e98a25_886x402.png 1272w, https://substackcdn.com/image/fetch/$s_!RzJb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fced22edd-5892-4cb3-8990-aa0683e98a25_886x402.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Becomes this as a <code>PartiallyGenerated</code> object that I can view by expanding the Generable macro: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!c3fK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F110f530b-6026-4c02-acb7-af8955b70816_1310x440.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!c3fK!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F110f530b-6026-4c02-acb7-af8955b70816_1310x440.png 424w, https://substackcdn.com/image/fetch/$s_!c3fK!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F110f530b-6026-4c02-acb7-af8955b70816_1310x440.png 848w, https://substackcdn.com/image/fetch/$s_!c3fK!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F110f530b-6026-4c02-acb7-af8955b70816_1310x440.png 1272w, https://substackcdn.com/image/fetch/$s_!c3fK!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F110f530b-6026-4c02-acb7-af8955b70816_1310x440.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!c3fK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F110f530b-6026-4c02-acb7-af8955b70816_1310x440.png" width="1310" height="440" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/110f530b-6026-4c02-acb7-af8955b70816_1310x440.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:440,&quot;width&quot;:1310,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:230831,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167081157?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F110f530b-6026-4c02-acb7-af8955b70816_1310x440.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!c3fK!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F110f530b-6026-4c02-acb7-af8955b70816_1310x440.png 424w, https://substackcdn.com/image/fetch/$s_!c3fK!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F110f530b-6026-4c02-acb7-af8955b70816_1310x440.png 848w, https://substackcdn.com/image/fetch/$s_!c3fK!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F110f530b-6026-4c02-acb7-af8955b70816_1310x440.png 1272w, https://substackcdn.com/image/fetch/$s_!c3fK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F110f530b-6026-4c02-acb7-af8955b70816_1310x440.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>These PartiallyGenerated objects are then used in the same way to display the information as the originals (but keeping in mind that every value may be nil!). They will just keep changing as the model is generated! For example, here is the <code>StudyPlanDisplayView</code>:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!UE8H!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98b6b46f-e158-4ff9-9d38-a30b8a88a0ea_1682x1382.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!UE8H!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98b6b46f-e158-4ff9-9d38-a30b8a88a0ea_1682x1382.png 424w, https://substackcdn.com/image/fetch/$s_!UE8H!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98b6b46f-e158-4ff9-9d38-a30b8a88a0ea_1682x1382.png 848w, https://substackcdn.com/image/fetch/$s_!UE8H!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98b6b46f-e158-4ff9-9d38-a30b8a88a0ea_1682x1382.png 1272w, https://substackcdn.com/image/fetch/$s_!UE8H!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98b6b46f-e158-4ff9-9d38-a30b8a88a0ea_1682x1382.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!UE8H!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98b6b46f-e158-4ff9-9d38-a30b8a88a0ea_1682x1382.png" width="1456" height="1196" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/98b6b46f-e158-4ff9-9d38-a30b8a88a0ea_1682x1382.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1196,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:423372,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167081157?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98b6b46f-e158-4ff9-9d38-a30b8a88a0ea_1682x1382.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!UE8H!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98b6b46f-e158-4ff9-9d38-a30b8a88a0ea_1682x1382.png 424w, https://substackcdn.com/image/fetch/$s_!UE8H!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98b6b46f-e158-4ff9-9d38-a30b8a88a0ea_1682x1382.png 848w, https://substackcdn.com/image/fetch/$s_!UE8H!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98b6b46f-e158-4ff9-9d38-a30b8a88a0ea_1682x1382.png 1272w, https://substackcdn.com/image/fetch/$s_!UE8H!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98b6b46f-e158-4ff9-9d38-a30b8a88a0ea_1682x1382.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>As each field is generated, the view gets filled out magically!</p><h2>Update the PartiallyGenerated Object</h2><p>After the user fills out their study plan parameters in the UI and click the &#8220;Generate Study Plan&#8221; button, we will use the LanguageModelSession&#8217;s <code>streamResponse</code> function to generate the study plan inside the view model. </p><p>The key here is to always update the <strong>StudyPlan.PartiallyGenerated </strong>object with the latest partial generation from the stream!</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!OPeI!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e5435a0-aa5b-4b16-ac5c-7860b486643c_1412x1412.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!OPeI!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e5435a0-aa5b-4b16-ac5c-7860b486643c_1412x1412.png 424w, https://substackcdn.com/image/fetch/$s_!OPeI!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e5435a0-aa5b-4b16-ac5c-7860b486643c_1412x1412.png 848w, https://substackcdn.com/image/fetch/$s_!OPeI!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e5435a0-aa5b-4b16-ac5c-7860b486643c_1412x1412.png 1272w, https://substackcdn.com/image/fetch/$s_!OPeI!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e5435a0-aa5b-4b16-ac5c-7860b486643c_1412x1412.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!OPeI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e5435a0-aa5b-4b16-ac5c-7860b486643c_1412x1412.png" width="1412" height="1412" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7e5435a0-aa5b-4b16-ac5c-7860b486643c_1412x1412.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1412,&quot;width&quot;:1412,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:392346,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167081157?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e5435a0-aa5b-4b16-ac5c-7860b486643c_1412x1412.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!OPeI!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e5435a0-aa5b-4b16-ac5c-7860b486643c_1412x1412.png 424w, https://substackcdn.com/image/fetch/$s_!OPeI!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e5435a0-aa5b-4b16-ac5c-7860b486643c_1412x1412.png 848w, https://substackcdn.com/image/fetch/$s_!OPeI!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e5435a0-aa5b-4b16-ac5c-7860b486643c_1412x1412.png 1272w, https://substackcdn.com/image/fetch/$s_!OPeI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7e5435a0-aa5b-4b16-ac5c-7860b486643c_1412x1412.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>As the objects keeps getting updated, make sure to set up your view in a way that will automatically update it with the view model as a <strong>StateObject</strong>: </p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!m66R!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39317f2c-2f3c-4a7e-b3c2-b12e1aa6e7a9_944x132.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!m66R!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39317f2c-2f3c-4a7e-b3c2-b12e1aa6e7a9_944x132.png 424w, https://substackcdn.com/image/fetch/$s_!m66R!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39317f2c-2f3c-4a7e-b3c2-b12e1aa6e7a9_944x132.png 848w, https://substackcdn.com/image/fetch/$s_!m66R!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39317f2c-2f3c-4a7e-b3c2-b12e1aa6e7a9_944x132.png 1272w, https://substackcdn.com/image/fetch/$s_!m66R!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39317f2c-2f3c-4a7e-b3c2-b12e1aa6e7a9_944x132.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!m66R!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39317f2c-2f3c-4a7e-b3c2-b12e1aa6e7a9_944x132.png" width="944" height="132" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/39317f2c-2f3c-4a7e-b3c2-b12e1aa6e7a9_944x132.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:132,&quot;width&quot;:944,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:40835,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167081157?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39317f2c-2f3c-4a7e-b3c2-b12e1aa6e7a9_944x132.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!m66R!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39317f2c-2f3c-4a7e-b3c2-b12e1aa6e7a9_944x132.png 424w, https://substackcdn.com/image/fetch/$s_!m66R!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39317f2c-2f3c-4a7e-b3c2-b12e1aa6e7a9_944x132.png 848w, https://substackcdn.com/image/fetch/$s_!m66R!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39317f2c-2f3c-4a7e-b3c2-b12e1aa6e7a9_944x132.png 1272w, https://substackcdn.com/image/fetch/$s_!m66R!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F39317f2c-2f3c-4a7e-b3c2-b12e1aa6e7a9_944x132.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Later on in the code where the study plan is displayed:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!SwlG!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb792430-c1d5-465c-9895-cbe4105c3a48_1254x268.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!SwlG!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb792430-c1d5-465c-9895-cbe4105c3a48_1254x268.png 424w, https://substackcdn.com/image/fetch/$s_!SwlG!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb792430-c1d5-465c-9895-cbe4105c3a48_1254x268.png 848w, https://substackcdn.com/image/fetch/$s_!SwlG!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb792430-c1d5-465c-9895-cbe4105c3a48_1254x268.png 1272w, https://substackcdn.com/image/fetch/$s_!SwlG!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb792430-c1d5-465c-9895-cbe4105c3a48_1254x268.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!SwlG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb792430-c1d5-465c-9895-cbe4105c3a48_1254x268.png" width="1254" height="268" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bb792430-c1d5-465c-9895-cbe4105c3a48_1254x268.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:268,&quot;width&quot;:1254,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:84748,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167081157?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb792430-c1d5-465c-9895-cbe4105c3a48_1254x268.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!SwlG!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb792430-c1d5-465c-9895-cbe4105c3a48_1254x268.png 424w, https://substackcdn.com/image/fetch/$s_!SwlG!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb792430-c1d5-465c-9895-cbe4105c3a48_1254x268.png 848w, https://substackcdn.com/image/fetch/$s_!SwlG!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb792430-c1d5-465c-9895-cbe4105c3a48_1254x268.png 1272w, https://substackcdn.com/image/fetch/$s_!SwlG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb792430-c1d5-465c-9895-cbe4105c3a48_1254x268.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>That&#8217;s it!</p><h2>Error Handling</h2><p>There are special errors that can be generated during the model&#8217;s generation process: </p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!c_R7!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76e2f9fe-c969-4e66-9cf9-71abc6e60e63_948x106.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!c_R7!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76e2f9fe-c969-4e66-9cf9-71abc6e60e63_948x106.png 424w, https://substackcdn.com/image/fetch/$s_!c_R7!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76e2f9fe-c969-4e66-9cf9-71abc6e60e63_948x106.png 848w, https://substackcdn.com/image/fetch/$s_!c_R7!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76e2f9fe-c969-4e66-9cf9-71abc6e60e63_948x106.png 1272w, https://substackcdn.com/image/fetch/$s_!c_R7!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76e2f9fe-c969-4e66-9cf9-71abc6e60e63_948x106.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!c_R7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76e2f9fe-c969-4e66-9cf9-71abc6e60e63_948x106.png" width="948" height="106" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/76e2f9fe-c969-4e66-9cf9-71abc6e60e63_948x106.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:106,&quot;width&quot;:948,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:37795,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167081157?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76e2f9fe-c969-4e66-9cf9-71abc6e60e63_948x106.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!c_R7!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76e2f9fe-c969-4e66-9cf9-71abc6e60e63_948x106.png 424w, https://substackcdn.com/image/fetch/$s_!c_R7!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76e2f9fe-c969-4e66-9cf9-71abc6e60e63_948x106.png 848w, https://substackcdn.com/image/fetch/$s_!c_R7!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76e2f9fe-c969-4e66-9cf9-71abc6e60e63_948x106.png 1272w, https://substackcdn.com/image/fetch/$s_!c_R7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76e2f9fe-c969-4e66-9cf9-71abc6e60e63_948x106.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>There are already many errors and new errors may be added in the future as the API expands!</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ZLDt!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c6c28ee-68de-4593-8565-fad8e25119c0_1904x988.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ZLDt!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c6c28ee-68de-4593-8565-fad8e25119c0_1904x988.png 424w, https://substackcdn.com/image/fetch/$s_!ZLDt!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c6c28ee-68de-4593-8565-fad8e25119c0_1904x988.png 848w, https://substackcdn.com/image/fetch/$s_!ZLDt!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c6c28ee-68de-4593-8565-fad8e25119c0_1904x988.png 1272w, https://substackcdn.com/image/fetch/$s_!ZLDt!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c6c28ee-68de-4593-8565-fad8e25119c0_1904x988.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ZLDt!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c6c28ee-68de-4593-8565-fad8e25119c0_1904x988.png" width="1456" height="756" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6c6c28ee-68de-4593-8565-fad8e25119c0_1904x988.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:756,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:618048,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167081157?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c6c28ee-68de-4593-8565-fad8e25119c0_1904x988.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ZLDt!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c6c28ee-68de-4593-8565-fad8e25119c0_1904x988.png 424w, https://substackcdn.com/image/fetch/$s_!ZLDt!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c6c28ee-68de-4593-8565-fad8e25119c0_1904x988.png 848w, https://substackcdn.com/image/fetch/$s_!ZLDt!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c6c28ee-68de-4593-8565-fad8e25119c0_1904x988.png 1272w, https://substackcdn.com/image/fetch/$s_!ZLDt!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c6c28ee-68de-4593-8565-fad8e25119c0_1904x988.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h2>Conclusion</h2><p>Apple&#8217;s FoundationModels framework makes it remarkably easy and surprisingly delightful to build intelligent, real-time generative apps in SwiftUI. With just a few lines of code, you can stream output token-by-token, giving users immediate feedback and a far more engaging experience than waiting for a full response to load. By using the <code>Generable</code> macro and leveraging <code>PartiallyGenerated</code> types, you can seamlessly display evolving content in your UI as the model generates it!</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.natashatherobot.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">This Substack is reader-supported. To receive new posts and support my work, consider becoming a free or paid subscriber.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p></p><p></p>]]></content:encoded></item><item><title><![CDATA[Introduction to Apple's FoundationModels: Limitations, Capabilities, Tools]]></title><description><![CDATA[Learn how to get started with Apple's FoundationModels Framework]]></description><link>https://www.natashatherobot.com/p/apple-foundation-models</link><guid isPermaLink="false">https://www.natashatherobot.com/p/apple-foundation-models</guid><dc:creator><![CDATA[NatashaTheRobot]]></dc:creator><pubDate>Sat, 28 Jun 2025 13:29:24 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!yx5l!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33a160c9-b7cd-42dd-b1f0-1b2cf993ef58_1962x778.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I was finally able to upgrade to macOS Tahoe, and now I&#8217;m excited to experiment with Apple&#8217;s new FoundationModels!! I&#8217;m going to start out by watching the WWDC25 videos about these models, experimenting with them, and writing about them here for later reference. Note that these will be introductory posts based on the videos and documentation for now, but will get more advanced as I get to experiment and learn and build in time to release a few apps I have in mind for September. </p><p>This blog post is focused on the <a href="https://developer.apple.com/videos/play/wwdc2025/286/">Meet the Foundation Models framework</a> video: </p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.natashatherobot.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">This Substack is reader-supported. To receive new posts and support my work, consider becoming a free or paid subscriber.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><h2>Limitations</h2><p>While extremely impressive and a dream-come-true for many Apple Developers - an on-device FREE PRIVATE model!! - it&#8217;s important to keep in mind that the model is highly limited. </p><p>First - it is small enough to fit on device. A big PRO! But the CON is that the model will just not be as powerful as LLMs provided by OpenAI, Google, or Anthropic. Expect it to not &#8220;know&#8221; as much as users are used to from larger LLMs, to hallucinate, and have severe logic limitations. This model will not &#8220;think&#8221; or do a web search or run quick code in a Python interpreter to verify information as the new OpenAI / Google / Anthropic agentic models do. </p><p>Instead, focus on it&#8217;s strengths - processing natural language. As mentioned in the video, the FoundationModel should be used for the following simple tasks with text: </p><ul><li><p>Summarization</p></li><li><p>Extraction</p></li><li><p>Classification</p></li><li><p>Tagging</p></li><li><p>Composition</p></li><li><p>Revision</p></li></ul><p>Again - all of these tasks are focused around processing existing simple language. <a href="https://machinelearning.apple.com/research/apple-foundation-models-2025-updates">Read more about the FoundationModel training data here.</a></p><h3>Training Cut-off Date</h3><p>As already mentioned, I wouldn&#8217;t rely on this model too much for important factual information - unless it is summarizing the information that I explicitly give it. But this is especially true for the most up-to-date information. </p><p>I don&#8217;t think we have a model training cut-off date, but many of these models have been trained over a year ago! And the more time passes, the more irrelevant the recent events data becomes. Here is what happens when I ask for today&#8217;s date: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!hGTx!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25809dde-88ec-4a0c-92c5-e584d17177c3_1282x352.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!hGTx!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25809dde-88ec-4a0c-92c5-e584d17177c3_1282x352.png 424w, https://substackcdn.com/image/fetch/$s_!hGTx!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25809dde-88ec-4a0c-92c5-e584d17177c3_1282x352.png 848w, https://substackcdn.com/image/fetch/$s_!hGTx!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25809dde-88ec-4a0c-92c5-e584d17177c3_1282x352.png 1272w, https://substackcdn.com/image/fetch/$s_!hGTx!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25809dde-88ec-4a0c-92c5-e584d17177c3_1282x352.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!hGTx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25809dde-88ec-4a0c-92c5-e584d17177c3_1282x352.png" width="1282" height="352" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/25809dde-88ec-4a0c-92c5-e584d17177c3_1282x352.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:352,&quot;width&quot;:1282,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:85292,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167029899?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25809dde-88ec-4a0c-92c5-e584d17177c3_1282x352.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!hGTx!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25809dde-88ec-4a0c-92c5-e584d17177c3_1282x352.png 424w, https://substackcdn.com/image/fetch/$s_!hGTx!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25809dde-88ec-4a0c-92c5-e584d17177c3_1282x352.png 848w, https://substackcdn.com/image/fetch/$s_!hGTx!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25809dde-88ec-4a0c-92c5-e584d17177c3_1282x352.png 1272w, https://substackcdn.com/image/fetch/$s_!hGTx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25809dde-88ec-4a0c-92c5-e584d17177c3_1282x352.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>And just to confirm the training cut-off, here is what we get if ask who the current U.S. President is: </p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!baPi!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a5b5fb1-2a99-40dc-99c7-7b7db68e14db_1596x324.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!baPi!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a5b5fb1-2a99-40dc-99c7-7b7db68e14db_1596x324.png 424w, https://substackcdn.com/image/fetch/$s_!baPi!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a5b5fb1-2a99-40dc-99c7-7b7db68e14db_1596x324.png 848w, https://substackcdn.com/image/fetch/$s_!baPi!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a5b5fb1-2a99-40dc-99c7-7b7db68e14db_1596x324.png 1272w, https://substackcdn.com/image/fetch/$s_!baPi!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a5b5fb1-2a99-40dc-99c7-7b7db68e14db_1596x324.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!baPi!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a5b5fb1-2a99-40dc-99c7-7b7db68e14db_1596x324.png" width="1456" height="296" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1a5b5fb1-2a99-40dc-99c7-7b7db68e14db_1596x324.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:296,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:89348,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167029899?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a5b5fb1-2a99-40dc-99c7-7b7db68e14db_1596x324.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!baPi!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a5b5fb1-2a99-40dc-99c7-7b7db68e14db_1596x324.png 424w, https://substackcdn.com/image/fetch/$s_!baPi!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a5b5fb1-2a99-40dc-99c7-7b7db68e14db_1596x324.png 848w, https://substackcdn.com/image/fetch/$s_!baPi!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a5b5fb1-2a99-40dc-99c7-7b7db68e14db_1596x324.png 1272w, https://substackcdn.com/image/fetch/$s_!baPi!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a5b5fb1-2a99-40dc-99c7-7b7db68e14db_1596x324.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Looks like the training cut-off is October 2023&#8230; </p><h3>Limited Context Window</h3><p>The FoundationModel is limited to only <strong>4096 tokens</strong> - both input AND output!! This is approximately 3,000 words&#8230; So don&#8217;t count on summarizing long text / PDFs&#8230; or even building a long chat. Keep it short and simple! </p><h3>Limited Language Support</h3><p>It&#8217;s hard to find information about which languages are supported by the Foundation Model, but there is a small footnote in the <a href="https://www.apple.com/in/newsroom/2025/06/apple-supercharges-its-tools-and-technologies-for-developers/#:~:text=Today's%20updates%20join%20the%20ever,at%20beta.apple.com.">Apple supercharges its tools and technologies for developers to foster creativity, innovation, and design</a> press release that mentions the same languages as supported by Apple Intelligence: </p><ul><li><p>English</p></li><li><p>French</p></li><li><p>German</p></li><li><p>Italian</p></li><li><p>Portuguese (Brazil)</p></li><li><p>Spanish</p></li><li><p>Japanese</p></li><li><p>Korean</p></li><li><p>Chinese (simplified)</p></li></ul><p>With more languages coming &#8220;by the end of this year&#8221;: Danish, Dutch, Norwegian, Portuguese (Portugal), Swedish, Turkish, Chinese (traditional), and Vietnamese. Not even Hindi :( </p><h3>Text-Only Input</h3><p>Many of us (and our users) are now take multimodal models for granted - we&#8217;re used to being able to input audio, video, images, PDFs, etc and get a very nice impressive response. However, with the FoundationModels framework, we need to take a step back. Back to LLM capabilities only. Only text input works as of now. </p><h3>Safety and Guardrails</h3><p>The FoundationModel is extremely guardrailed: </p><blockquote><p>First, the framework uses an on-device language model that&#8217;s trained to handle sensitive topics with care. Second, the framework uses guardrails that Apple developed with a responsible AI approach. These guardrails flag sensitive content, such as self-harm, violence, and adult sexual material, from model input and output.</p><p><em>- <a href="https://developer.apple.com/documentation/foundationmodels/improving-safety-from-generative-model-output">Improving safety from generative model output</a></em></p></blockquote><p>While this is good on the surface of how language models should behave, in practice this creates a lot of false positives, which is pointed out in the documentation: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!jOYF!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5cfa8d41-8f41-4114-b68d-72d3da1f5958_1636x454.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!jOYF!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5cfa8d41-8f41-4114-b68d-72d3da1f5958_1636x454.png 424w, https://substackcdn.com/image/fetch/$s_!jOYF!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5cfa8d41-8f41-4114-b68d-72d3da1f5958_1636x454.png 848w, https://substackcdn.com/image/fetch/$s_!jOYF!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5cfa8d41-8f41-4114-b68d-72d3da1f5958_1636x454.png 1272w, https://substackcdn.com/image/fetch/$s_!jOYF!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5cfa8d41-8f41-4114-b68d-72d3da1f5958_1636x454.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!jOYF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5cfa8d41-8f41-4114-b68d-72d3da1f5958_1636x454.png" width="1456" height="404" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5cfa8d41-8f41-4114-b68d-72d3da1f5958_1636x454.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:404,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:118661,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167029899?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5cfa8d41-8f41-4114-b68d-72d3da1f5958_1636x454.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!jOYF!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5cfa8d41-8f41-4114-b68d-72d3da1f5958_1636x454.png 424w, https://substackcdn.com/image/fetch/$s_!jOYF!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5cfa8d41-8f41-4114-b68d-72d3da1f5958_1636x454.png 848w, https://substackcdn.com/image/fetch/$s_!jOYF!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5cfa8d41-8f41-4114-b68d-72d3da1f5958_1636x454.png 1272w, https://substackcdn.com/image/fetch/$s_!jOYF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5cfa8d41-8f41-4114-b68d-72d3da1f5958_1636x454.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Again - you will have to really test the prompts to make sure the app&#8217;s guardrails will not be activated unexpectedly. </p><h3>Unknown Updates</h3><p>It seems like Apple plans to update the FoundationModels framework before next year (probably several times). And we, as developers, have no idea when it will happen and how it will impact our existing apps. After all - Apple cannot test that the new model will not break our current specific app use-case. And there doesn&#8217;t seem to be a way to refer to a specific release of the model. </p><h2>Availability</h2><p>The first issue with using FoundationModels is understanding their availability and therefore including a fallback experience for users who do not have these available. According to <a href="https://developer.apple.com/documentation/foundationmodels/generating-content-and-performing-tasks-with-foundation-models">Apple&#8217;s documentation</a>: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!tIN3!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e6eacf2-fb07-4de7-a889-c79e988a2765_1182x326.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!tIN3!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e6eacf2-fb07-4de7-a889-c79e988a2765_1182x326.png 424w, https://substackcdn.com/image/fetch/$s_!tIN3!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e6eacf2-fb07-4de7-a889-c79e988a2765_1182x326.png 848w, https://substackcdn.com/image/fetch/$s_!tIN3!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e6eacf2-fb07-4de7-a889-c79e988a2765_1182x326.png 1272w, https://substackcdn.com/image/fetch/$s_!tIN3!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e6eacf2-fb07-4de7-a889-c79e988a2765_1182x326.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!tIN3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e6eacf2-fb07-4de7-a889-c79e988a2765_1182x326.png" width="1182" height="326" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1e6eacf2-fb07-4de7-a889-c79e988a2765_1182x326.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:326,&quot;width&quot;:1182,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:61424,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167029899?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e6eacf2-fb07-4de7-a889-c79e988a2765_1182x326.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!tIN3!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e6eacf2-fb07-4de7-a889-c79e988a2765_1182x326.png 424w, https://substackcdn.com/image/fetch/$s_!tIN3!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e6eacf2-fb07-4de7-a889-c79e988a2765_1182x326.png 848w, https://substackcdn.com/image/fetch/$s_!tIN3!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e6eacf2-fb07-4de7-a889-c79e988a2765_1182x326.png 1272w, https://substackcdn.com/image/fetch/$s_!tIN3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1e6eacf2-fb07-4de7-a889-c79e988a2765_1182x326.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>The <a href="https://www.apple.com/in/apple-intelligence/">Apple Intelligence webpage</a> lists the following devices as compatible:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!42OJ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc7be3448-6547-4021-a199-21a3ffcc5f46_1070x1084.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!42OJ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc7be3448-6547-4021-a199-21a3ffcc5f46_1070x1084.png 424w, https://substackcdn.com/image/fetch/$s_!42OJ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc7be3448-6547-4021-a199-21a3ffcc5f46_1070x1084.png 848w, https://substackcdn.com/image/fetch/$s_!42OJ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc7be3448-6547-4021-a199-21a3ffcc5f46_1070x1084.png 1272w, https://substackcdn.com/image/fetch/$s_!42OJ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc7be3448-6547-4021-a199-21a3ffcc5f46_1070x1084.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!42OJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc7be3448-6547-4021-a199-21a3ffcc5f46_1070x1084.png" width="1070" height="1084" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c7be3448-6547-4021-a199-21a3ffcc5f46_1070x1084.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1084,&quot;width&quot;:1070,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:631827,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167029899?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc7be3448-6547-4021-a199-21a3ffcc5f46_1070x1084.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!42OJ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc7be3448-6547-4021-a199-21a3ffcc5f46_1070x1084.png 424w, https://substackcdn.com/image/fetch/$s_!42OJ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc7be3448-6547-4021-a199-21a3ffcc5f46_1070x1084.png 848w, https://substackcdn.com/image/fetch/$s_!42OJ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc7be3448-6547-4021-a199-21a3ffcc5f46_1070x1084.png 1272w, https://substackcdn.com/image/fetch/$s_!42OJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc7be3448-6547-4021-a199-21a3ffcc5f46_1070x1084.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>And of course, users must have <strong>iOS 26+, macOS 26+, and visionOS 26+</strong> installed on their compatible device. </p><p>The code for checking availability and displaying error messages in your view is as follows: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!P9B3!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e041588-8e7d-41fc-a94a-a140017c6fe0_1660x1254.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!P9B3!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e041588-8e7d-41fc-a94a-a140017c6fe0_1660x1254.png 424w, https://substackcdn.com/image/fetch/$s_!P9B3!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e041588-8e7d-41fc-a94a-a140017c6fe0_1660x1254.png 848w, https://substackcdn.com/image/fetch/$s_!P9B3!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e041588-8e7d-41fc-a94a-a140017c6fe0_1660x1254.png 1272w, https://substackcdn.com/image/fetch/$s_!P9B3!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e041588-8e7d-41fc-a94a-a140017c6fe0_1660x1254.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!P9B3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e041588-8e7d-41fc-a94a-a140017c6fe0_1660x1254.png" width="1456" height="1100" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9e041588-8e7d-41fc-a94a-a140017c6fe0_1660x1254.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1100,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:458426,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167029899?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e041588-8e7d-41fc-a94a-a140017c6fe0_1660x1254.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!P9B3!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e041588-8e7d-41fc-a94a-a140017c6fe0_1660x1254.png 424w, https://substackcdn.com/image/fetch/$s_!P9B3!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e041588-8e7d-41fc-a94a-a140017c6fe0_1660x1254.png 848w, https://substackcdn.com/image/fetch/$s_!P9B3!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e041588-8e7d-41fc-a94a-a140017c6fe0_1660x1254.png 1272w, https://substackcdn.com/image/fetch/$s_!P9B3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e041588-8e7d-41fc-a94a-a140017c6fe0_1660x1254.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Note that there are currently three reasons for the model being unavailable: </p><ul><li><p>The device is not eligible (see above for eligible devices from the Apple Intelligence website)</p></li><li><p>Apple Intelligence is not enabled - this is a simple fix for the user if they want the extra features. </p></li><li><p>Model not ready</p></li></ul><p>Since this framework is in beta and will for sure change in the future, it&#8217;s also important to include an unknown default reason that may be added in future versions. </p><p>Now onto the fun part!</p><h2>Hello World</h2><p>To quickly play around with the model, we can now quickly add the <code>#Playground</code><strong> </strong>macro to any Swift file and see the results right away! Simply import the <strong>Playgrounds framework</strong> and start testing out different prompts. </p><p>Getting started with the FoundationModels takes only three simple steps: </p><ol><li><p>Import the FoundationModels framework</p></li><li><p>Create a <code>LanguageModelSession</code> </p></li><li><p>Pass it a prompt!</p></li></ol><p>That&#8217;s it! Only a few simple lines of code: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!yx5l!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33a160c9-b7cd-42dd-b1f0-1b2cf993ef58_1962x778.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!yx5l!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33a160c9-b7cd-42dd-b1f0-1b2cf993ef58_1962x778.png 424w, https://substackcdn.com/image/fetch/$s_!yx5l!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33a160c9-b7cd-42dd-b1f0-1b2cf993ef58_1962x778.png 848w, https://substackcdn.com/image/fetch/$s_!yx5l!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33a160c9-b7cd-42dd-b1f0-1b2cf993ef58_1962x778.png 1272w, https://substackcdn.com/image/fetch/$s_!yx5l!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33a160c9-b7cd-42dd-b1f0-1b2cf993ef58_1962x778.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!yx5l!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33a160c9-b7cd-42dd-b1f0-1b2cf993ef58_1962x778.png" width="1456" height="577" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/33a160c9-b7cd-42dd-b1f0-1b2cf993ef58_1962x778.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:577,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:271148,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167029899?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33a160c9-b7cd-42dd-b1f0-1b2cf993ef58_1962x778.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!yx5l!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33a160c9-b7cd-42dd-b1f0-1b2cf993ef58_1962x778.png 424w, https://substackcdn.com/image/fetch/$s_!yx5l!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33a160c9-b7cd-42dd-b1f0-1b2cf993ef58_1962x778.png 848w, https://substackcdn.com/image/fetch/$s_!yx5l!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33a160c9-b7cd-42dd-b1f0-1b2cf993ef58_1962x778.png 1272w, https://substackcdn.com/image/fetch/$s_!yx5l!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F33a160c9-b7cd-42dd-b1f0-1b2cf993ef58_1962x778.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h3>Instructions</h3><p>Now, if you&#8217;ve used other LLMs, we know that we need to first give the model a system prompt - called instructions in the FoundationModels language. This is done when setting up the <code>LanguageModelSession</code> initially: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!tR_w!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F724a26c7-e6ef-4ede-b12a-30825e029f2c_2632x888.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!tR_w!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F724a26c7-e6ef-4ede-b12a-30825e029f2c_2632x888.png 424w, https://substackcdn.com/image/fetch/$s_!tR_w!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F724a26c7-e6ef-4ede-b12a-30825e029f2c_2632x888.png 848w, https://substackcdn.com/image/fetch/$s_!tR_w!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F724a26c7-e6ef-4ede-b12a-30825e029f2c_2632x888.png 1272w, https://substackcdn.com/image/fetch/$s_!tR_w!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F724a26c7-e6ef-4ede-b12a-30825e029f2c_2632x888.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!tR_w!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F724a26c7-e6ef-4ede-b12a-30825e029f2c_2632x888.png" width="1456" height="491" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/724a26c7-e6ef-4ede-b12a-30825e029f2c_2632x888.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:491,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:375625,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167029899?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F724a26c7-e6ef-4ede-b12a-30825e029f2c_2632x888.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!tR_w!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F724a26c7-e6ef-4ede-b12a-30825e029f2c_2632x888.png 424w, https://substackcdn.com/image/fetch/$s_!tR_w!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F724a26c7-e6ef-4ede-b12a-30825e029f2c_2632x888.png 848w, https://substackcdn.com/image/fetch/$s_!tR_w!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F724a26c7-e6ef-4ede-b12a-30825e029f2c_2632x888.png 1272w, https://substackcdn.com/image/fetch/$s_!tR_w!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F724a26c7-e6ef-4ede-b12a-30825e029f2c_2632x888.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>One thing I really liked from the video was how they broke down the difference between Instructions vs Prompts: </p><ul><li><p>Instructions should only come from you, the developer / app</p></li><li><p>Prompts can come from you or the user! </p></li></ul><p>In other words, you should never allow the user access to modify the models instructions. </p><h3>Iteration</h3><p>If you have an array of items for the model to respond to, you can simply iterate over your array of items and get a list of responses from the model: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!fkjm!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84b938d0-1cbf-44b5-b88a-c3ea9e9e2889_2636x1358.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!fkjm!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84b938d0-1cbf-44b5-b88a-c3ea9e9e2889_2636x1358.png 424w, https://substackcdn.com/image/fetch/$s_!fkjm!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84b938d0-1cbf-44b5-b88a-c3ea9e9e2889_2636x1358.png 848w, https://substackcdn.com/image/fetch/$s_!fkjm!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84b938d0-1cbf-44b5-b88a-c3ea9e9e2889_2636x1358.png 1272w, https://substackcdn.com/image/fetch/$s_!fkjm!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84b938d0-1cbf-44b5-b88a-c3ea9e9e2889_2636x1358.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!fkjm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84b938d0-1cbf-44b5-b88a-c3ea9e9e2889_2636x1358.png" width="1456" height="750" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/84b938d0-1cbf-44b5-b88a-c3ea9e9e2889_2636x1358.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:750,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:557009,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167029899?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84b938d0-1cbf-44b5-b88a-c3ea9e9e2889_2636x1358.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!fkjm!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84b938d0-1cbf-44b5-b88a-c3ea9e9e2889_2636x1358.png 424w, https://substackcdn.com/image/fetch/$s_!fkjm!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84b938d0-1cbf-44b5-b88a-c3ea9e9e2889_2636x1358.png 848w, https://substackcdn.com/image/fetch/$s_!fkjm!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84b938d0-1cbf-44b5-b88a-c3ea9e9e2889_2636x1358.png 1272w, https://substackcdn.com/image/fetch/$s_!fkjm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84b938d0-1cbf-44b5-b88a-c3ea9e9e2889_2636x1358.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h3>Saved Conversation History</h3><p>This is something that I really love about the FoundationModels API - the message history is automatically saved by the LanguageModelSession for you! If you&#8217;ve used other LLM APIs, you&#8217;d know that you usually have to send the full message history to the model every single time you need a response! </p><p>So when I ask the model for this session about the topic of the last haiku, it knows automatically!</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!NgQQ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4412ddc0-f06d-4fb9-a9f3-2bb29755d96d_2634x1434.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!NgQQ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4412ddc0-f06d-4fb9-a9f3-2bb29755d96d_2634x1434.png 424w, https://substackcdn.com/image/fetch/$s_!NgQQ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4412ddc0-f06d-4fb9-a9f3-2bb29755d96d_2634x1434.png 848w, https://substackcdn.com/image/fetch/$s_!NgQQ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4412ddc0-f06d-4fb9-a9f3-2bb29755d96d_2634x1434.png 1272w, https://substackcdn.com/image/fetch/$s_!NgQQ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4412ddc0-f06d-4fb9-a9f3-2bb29755d96d_2634x1434.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!NgQQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4412ddc0-f06d-4fb9-a9f3-2bb29755d96d_2634x1434.png" width="1456" height="793" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4412ddc0-f06d-4fb9-a9f3-2bb29755d96d_2634x1434.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:793,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:619271,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167029899?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4412ddc0-f06d-4fb9-a9f3-2bb29755d96d_2634x1434.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!NgQQ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4412ddc0-f06d-4fb9-a9f3-2bb29755d96d_2634x1434.png 424w, https://substackcdn.com/image/fetch/$s_!NgQQ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4412ddc0-f06d-4fb9-a9f3-2bb29755d96d_2634x1434.png 848w, https://substackcdn.com/image/fetch/$s_!NgQQ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4412ddc0-f06d-4fb9-a9f3-2bb29755d96d_2634x1434.png 1272w, https://substackcdn.com/image/fetch/$s_!NgQQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4412ddc0-f06d-4fb9-a9f3-2bb29755d96d_2634x1434.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Funny enough, the model DID NOT follow the initial instructions to respond only in haiku format when asked about the topic of the last haiku. And one time it printed out the topic of the last haiku as orange instead of plum&#8230; So it is super important to test out these multi-turn interactions to make sure the user interactions stay on track and do not hallucinate the important information, especially when the user provides the prompt :) </p><h2>Full Transcript</h2><p>And if you do need a full transcript (maybe you need to send the full conversation history to an larger server-side API after all!), it is very easily available in the session object: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!SFUB!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F570c5880-8ff6-4139-9584-f7b5ba47c78c_2582x1228.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!SFUB!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F570c5880-8ff6-4139-9584-f7b5ba47c78c_2582x1228.png 424w, https://substackcdn.com/image/fetch/$s_!SFUB!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F570c5880-8ff6-4139-9584-f7b5ba47c78c_2582x1228.png 848w, https://substackcdn.com/image/fetch/$s_!SFUB!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F570c5880-8ff6-4139-9584-f7b5ba47c78c_2582x1228.png 1272w, https://substackcdn.com/image/fetch/$s_!SFUB!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F570c5880-8ff6-4139-9584-f7b5ba47c78c_2582x1228.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!SFUB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F570c5880-8ff6-4139-9584-f7b5ba47c78c_2582x1228.png" width="1456" height="692" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/570c5880-8ff6-4139-9584-f7b5ba47c78c_2582x1228.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:692,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:483030,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167029899?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F570c5880-8ff6-4139-9584-f7b5ba47c78c_2582x1228.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!SFUB!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F570c5880-8ff6-4139-9584-f7b5ba47c78c_2582x1228.png 424w, https://substackcdn.com/image/fetch/$s_!SFUB!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F570c5880-8ff6-4139-9584-f7b5ba47c78c_2582x1228.png 848w, https://substackcdn.com/image/fetch/$s_!SFUB!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F570c5880-8ff6-4139-9584-f7b5ba47c78c_2582x1228.png 1272w, https://substackcdn.com/image/fetch/$s_!SFUB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F570c5880-8ff6-4139-9584-f7b5ba47c78c_2582x1228.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h2>Generable - NO JSON!!! NO CODABLE!!!</h2><p>Now onto the super impressive things!!! The FoundationModels has introduced a <code>@Generable</code> macro, which will automatically turn the FoundationModels responses to a typed Swift object, without any JSON / Codable!!</p><p>It&#8217;s as simple as this: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!GUu6!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2773ee14-3f65-415d-90a0-8c463c0d6412_1018x408.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!GUu6!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2773ee14-3f65-415d-90a0-8c463c0d6412_1018x408.png 424w, https://substackcdn.com/image/fetch/$s_!GUu6!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2773ee14-3f65-415d-90a0-8c463c0d6412_1018x408.png 848w, https://substackcdn.com/image/fetch/$s_!GUu6!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2773ee14-3f65-415d-90a0-8c463c0d6412_1018x408.png 1272w, https://substackcdn.com/image/fetch/$s_!GUu6!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2773ee14-3f65-415d-90a0-8c463c0d6412_1018x408.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!GUu6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2773ee14-3f65-415d-90a0-8c463c0d6412_1018x408.png" width="1018" height="408" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2773ee14-3f65-415d-90a0-8c463c0d6412_1018x408.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:408,&quot;width&quot;:1018,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:92619,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167029899?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2773ee14-3f65-415d-90a0-8c463c0d6412_1018x408.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!GUu6!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2773ee14-3f65-415d-90a0-8c463c0d6412_1018x408.png 424w, https://substackcdn.com/image/fetch/$s_!GUu6!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2773ee14-3f65-415d-90a0-8c463c0d6412_1018x408.png 848w, https://substackcdn.com/image/fetch/$s_!GUu6!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2773ee14-3f65-415d-90a0-8c463c0d6412_1018x408.png 1272w, https://substackcdn.com/image/fetch/$s_!GUu6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2773ee14-3f65-415d-90a0-8c463c0d6412_1018x408.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Now just use this object as a <code>generating</code> item along with the prompt: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!S7w8!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26ef6ec6-938b-4a37-abfd-d9a3576297e4_2656x1410.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!S7w8!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26ef6ec6-938b-4a37-abfd-d9a3576297e4_2656x1410.png 424w, https://substackcdn.com/image/fetch/$s_!S7w8!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26ef6ec6-938b-4a37-abfd-d9a3576297e4_2656x1410.png 848w, https://substackcdn.com/image/fetch/$s_!S7w8!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26ef6ec6-938b-4a37-abfd-d9a3576297e4_2656x1410.png 1272w, https://substackcdn.com/image/fetch/$s_!S7w8!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26ef6ec6-938b-4a37-abfd-d9a3576297e4_2656x1410.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!S7w8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26ef6ec6-938b-4a37-abfd-d9a3576297e4_2656x1410.png" width="1456" height="773" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/26ef6ec6-938b-4a37-abfd-d9a3576297e4_2656x1410.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:773,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:677744,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167029899?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26ef6ec6-938b-4a37-abfd-d9a3576297e4_2656x1410.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!S7w8!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26ef6ec6-938b-4a37-abfd-d9a3576297e4_2656x1410.png 424w, https://substackcdn.com/image/fetch/$s_!S7w8!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26ef6ec6-938b-4a37-abfd-d9a3576297e4_2656x1410.png 848w, https://substackcdn.com/image/fetch/$s_!S7w8!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26ef6ec6-938b-4a37-abfd-d9a3576297e4_2656x1410.png 1272w, https://substackcdn.com/image/fetch/$s_!S7w8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F26ef6ec6-938b-4a37-abfd-d9a3576297e4_2656x1410.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Notice how the <code>response.content</code> object is automatically typed to the @Generable <code>SearchSuggestions</code> object! </p><h3>Property Ordering</h3><p>LLMs generate content one token (*sub-word*) at a time. This means that if you want the LLM to &#8220;reason&#8221; or &#8220;think&#8221; you can first add a longer-form property such as &#8220;analysis&#8221; first then the main smaller-form property after. </p><p>For example, we can create a SearchTerm object which has the analysis of why this search term is relevant first, and the actual term later. For the user, we will only show the term, but by putting &#8220;analysis&#8221; as the first property, we&#8217;re giving the model more tokens to &#8220;think&#8221; through before coming up with a compelling suggestion: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!V4F4!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff8ddb2ef-ed02-4277-8314-28667c356e8d_2666x1372.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!V4F4!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff8ddb2ef-ed02-4277-8314-28667c356e8d_2666x1372.png 424w, https://substackcdn.com/image/fetch/$s_!V4F4!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff8ddb2ef-ed02-4277-8314-28667c356e8d_2666x1372.png 848w, https://substackcdn.com/image/fetch/$s_!V4F4!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff8ddb2ef-ed02-4277-8314-28667c356e8d_2666x1372.png 1272w, https://substackcdn.com/image/fetch/$s_!V4F4!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff8ddb2ef-ed02-4277-8314-28667c356e8d_2666x1372.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!V4F4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff8ddb2ef-ed02-4277-8314-28667c356e8d_2666x1372.png" width="1456" height="749" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f8ddb2ef-ed02-4277-8314-28667c356e8d_2666x1372.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:749,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:686890,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167029899?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff8ddb2ef-ed02-4277-8314-28667c356e8d_2666x1372.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!V4F4!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff8ddb2ef-ed02-4277-8314-28667c356e8d_2666x1372.png 424w, https://substackcdn.com/image/fetch/$s_!V4F4!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff8ddb2ef-ed02-4277-8314-28667c356e8d_2666x1372.png 848w, https://substackcdn.com/image/fetch/$s_!V4F4!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff8ddb2ef-ed02-4277-8314-28667c356e8d_2666x1372.png 1272w, https://substackcdn.com/image/fetch/$s_!V4F4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff8ddb2ef-ed02-4277-8314-28667c356e8d_2666x1372.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h3>Generable Composition</h3><p>In the last example, you may have noticed something super cool! The Foundation Model is able to generate ALL nested Generable objects!  </p><p>Check out this TravelItinerary object with an array of Generable Destination objects with an array of Generable Activity objects! </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!_ad1!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcfbafe7a-c51c-46b6-af7b-89a5062bf6b6_1506x1120.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!_ad1!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcfbafe7a-c51c-46b6-af7b-89a5062bf6b6_1506x1120.png 424w, https://substackcdn.com/image/fetch/$s_!_ad1!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcfbafe7a-c51c-46b6-af7b-89a5062bf6b6_1506x1120.png 848w, https://substackcdn.com/image/fetch/$s_!_ad1!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcfbafe7a-c51c-46b6-af7b-89a5062bf6b6_1506x1120.png 1272w, https://substackcdn.com/image/fetch/$s_!_ad1!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcfbafe7a-c51c-46b6-af7b-89a5062bf6b6_1506x1120.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!_ad1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcfbafe7a-c51c-46b6-af7b-89a5062bf6b6_1506x1120.png" width="1456" height="1083" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/cfbafe7a-c51c-46b6-af7b-89a5062bf6b6_1506x1120.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1083,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:357546,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167029899?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcfbafe7a-c51c-46b6-af7b-89a5062bf6b6_1506x1120.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!_ad1!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcfbafe7a-c51c-46b6-af7b-89a5062bf6b6_1506x1120.png 424w, https://substackcdn.com/image/fetch/$s_!_ad1!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcfbafe7a-c51c-46b6-af7b-89a5062bf6b6_1506x1120.png 848w, https://substackcdn.com/image/fetch/$s_!_ad1!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcfbafe7a-c51c-46b6-af7b-89a5062bf6b6_1506x1120.png 1272w, https://substackcdn.com/image/fetch/$s_!_ad1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcfbafe7a-c51c-46b6-af7b-89a5062bf6b6_1506x1120.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>It&#8217;s able to generate all the objects! </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!d3vw!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b29dc6a-c068-4207-b8fa-35a3453cbbc8_2658x1184.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!d3vw!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b29dc6a-c068-4207-b8fa-35a3453cbbc8_2658x1184.png 424w, https://substackcdn.com/image/fetch/$s_!d3vw!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b29dc6a-c068-4207-b8fa-35a3453cbbc8_2658x1184.png 848w, https://substackcdn.com/image/fetch/$s_!d3vw!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b29dc6a-c068-4207-b8fa-35a3453cbbc8_2658x1184.png 1272w, https://substackcdn.com/image/fetch/$s_!d3vw!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b29dc6a-c068-4207-b8fa-35a3453cbbc8_2658x1184.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!d3vw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b29dc6a-c068-4207-b8fa-35a3453cbbc8_2658x1184.png" width="1456" height="649" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0b29dc6a-c068-4207-b8fa-35a3453cbbc8_2658x1184.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:649,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:695240,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167029899?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b29dc6a-c068-4207-b8fa-35a3453cbbc8_2658x1184.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!d3vw!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b29dc6a-c068-4207-b8fa-35a3453cbbc8_2658x1184.png 424w, https://substackcdn.com/image/fetch/$s_!d3vw!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b29dc6a-c068-4207-b8fa-35a3453cbbc8_2658x1184.png 848w, https://substackcdn.com/image/fetch/$s_!d3vw!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b29dc6a-c068-4207-b8fa-35a3453cbbc8_2658x1184.png 1272w, https://substackcdn.com/image/fetch/$s_!d3vw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b29dc6a-c068-4207-b8fa-35a3453cbbc8_2658x1184.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Again - note that travel is not a great use-case for this model as it may hallucinate travel information or provide old information that is not up-to-date. So just use this as an example of object composition&#8230; </p><h2>Tools</h2><p>As we discussed in the Limitations section, one of the issues with the Foundation Model is that it has a cutoff date maybe around October 2023, so it doesn&#8217;t have access to the most recent information, including today&#8217;s date!</p><p>But it&#8217;s not a big deal. We can give it the Tools it needs to get the relevant information to our app. Here is a simple <code>GetCurrentDateTool</code>: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!XYk7!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f95d531-6a81-4300-9777-130a0308fff8_900x1074.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!XYk7!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f95d531-6a81-4300-9777-130a0308fff8_900x1074.png 424w, https://substackcdn.com/image/fetch/$s_!XYk7!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f95d531-6a81-4300-9777-130a0308fff8_900x1074.png 848w, https://substackcdn.com/image/fetch/$s_!XYk7!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f95d531-6a81-4300-9777-130a0308fff8_900x1074.png 1272w, https://substackcdn.com/image/fetch/$s_!XYk7!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f95d531-6a81-4300-9777-130a0308fff8_900x1074.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!XYk7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f95d531-6a81-4300-9777-130a0308fff8_900x1074.png" width="900" height="1074" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9f95d531-6a81-4300-9777-130a0308fff8_900x1074.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1074,&quot;width&quot;:900,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:250687,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167029899?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f95d531-6a81-4300-9777-130a0308fff8_900x1074.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!XYk7!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f95d531-6a81-4300-9777-130a0308fff8_900x1074.png 424w, https://substackcdn.com/image/fetch/$s_!XYk7!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f95d531-6a81-4300-9777-130a0308fff8_900x1074.png 848w, https://substackcdn.com/image/fetch/$s_!XYk7!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f95d531-6a81-4300-9777-130a0308fff8_900x1074.png 1272w, https://substackcdn.com/image/fetch/$s_!XYk7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f95d531-6a81-4300-9777-130a0308fff8_900x1074.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>To use it - we simply include the tool in the <code>LanguageModelSession</code>: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!wyMM!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37b1979f-830c-4921-8cac-bdfffa00a66a_2018x924.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!wyMM!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37b1979f-830c-4921-8cac-bdfffa00a66a_2018x924.png 424w, https://substackcdn.com/image/fetch/$s_!wyMM!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37b1979f-830c-4921-8cac-bdfffa00a66a_2018x924.png 848w, https://substackcdn.com/image/fetch/$s_!wyMM!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37b1979f-830c-4921-8cac-bdfffa00a66a_2018x924.png 1272w, https://substackcdn.com/image/fetch/$s_!wyMM!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37b1979f-830c-4921-8cac-bdfffa00a66a_2018x924.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!wyMM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37b1979f-830c-4921-8cac-bdfffa00a66a_2018x924.png" width="1456" height="667" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/37b1979f-830c-4921-8cac-bdfffa00a66a_2018x924.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:667,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:431058,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/167029899?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37b1979f-830c-4921-8cac-bdfffa00a66a_2018x924.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!wyMM!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37b1979f-830c-4921-8cac-bdfffa00a66a_2018x924.png 424w, https://substackcdn.com/image/fetch/$s_!wyMM!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37b1979f-830c-4921-8cac-bdfffa00a66a_2018x924.png 848w, https://substackcdn.com/image/fetch/$s_!wyMM!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37b1979f-830c-4921-8cac-bdfffa00a66a_2018x924.png 1272w, https://substackcdn.com/image/fetch/$s_!wyMM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F37b1979f-830c-4921-8cac-bdfffa00a66a_2018x924.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Notice that you can pass in multiple tools to the model - this is especially useful on iPhone as you can give access to the user&#8217;s Calendar, Reminders, Location, and much more personalized data from your app without risking the user&#8217;s privacy!  </p><p>The model will figure out when to call each tool based on the context of the conversation! And you don&#8217;t even have to manage the back and forth of getting the tool response and sending it back to the model - this is done automatically for you!!! The Foundation Model API is truly impressive!</p><h2>Conclusion</h2><p>I wanted to include a few more things, but this post is already long enough, so I&#8217;ll continue on tomorrow with extra features of the FoundationModels framework as I continue to learn and figure out how to integrate it into apps. </p><p>I know I mentioned a lot of limitations in the beginning of this blog post, so I wanted to end here with a more positive view. We have an incredibly powerful natural language processing model ON DEVICE for FREE!! And the capabilities are on par and probably better than most MLX on-device models. So this is truly a big WIN for us as Apple developers, and I&#8217;m excited to see Apple continue on this path of providing more options and capabilities for us to work with in a beautiful Swift API :) </p><p>Happy Building! </p><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.natashatherobot.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">This Substack is reader-supported. To receive new posts and support my work, consider becoming a free or paid subscriber.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Building a Sanskrit Dictionary App: An AI-Powered Retrospective]]></title><description><![CDATA[My experience building a Sanskrit Dictionary app showed me how LLMs and Python empowered me, a Swift developer, to work with unfamiliar tools, languages, and systems I once thought were out of reach.]]></description><link>https://www.natashatherobot.com/p/building-a-sanskrit-dictionary-app-ai</link><guid isPermaLink="false">https://www.natashatherobot.com/p/building-a-sanskrit-dictionary-app-ai</guid><dc:creator><![CDATA[NatashaTheRobot]]></dc:creator><pubDate>Wed, 18 Jun 2025 09:38:56 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/7f0a04f7-7d5b-4a4a-9c9f-0bc8799947c7_1280x791.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Instead of participating in WWDC this year, I decided to take the &#8220;quiet&#8221; time to power through and release an app I&#8217;ve been working on slowly over the past year, when I graduated the MA Sanskrit Studies program from Manipal University in India. This post won&#8217;t go into the details of Sanskrit dictionary design or user experience (<a href="https://www.gingersunrise.com/p/sanskrit-lexicon-sanskrit-dictionary-iphone-ipad-mac-app">I&#8217;ve covered those here</a>, if you&#8217;re interested). Instead, I&#8217;ll focus on the <strong>technical and AI-specific challenges</strong> behind building the app: what worked, what didn&#8217;t, and what I learned along the way.</p><h2>Python is All You Need</h2><p>So why use Python if I&#8217;m a Swift developer? The answer is simple: most Swift apps need a backend, and in my case, I was using Supabase. To process and prepare that backend data, Python when paired with LLMs, is by far the easiest and most efficient tool. Could it be done in Swift? Probably. But the developer experience would be painful, and LLM support for Swift just isn&#8217;t there yet. Python, on the other hand, works beautifully.</p><p>While there is a ton of hype around AI Agents - if you build fully agentic systems using LLMs for all tasks in the pipeline, you&#8217;ll quickly run into surprisingly unreliable and unpredictable results. While these systems have potential (I&#8217;m sure they&#8217;ll really stand out for certain futuristic use cases I haven&#8217;t thought about), the real strength of LLMs <em>today</em> lies in their ability to write solid, reliable <strong>Python code</strong> that simply gets the job done. </p><p>Most of the work I did for my Sanskrit Dictionary app was writing a ton of Python scripts with the help of LLMs. I pushed as much of the data processing as possible to the backend, so the frontend app could stay lightweight and simply display everything instantly and efficiently.</p><p>Now here&#8217;s the magical part: <strong>I barely know Python.</strong> I only dabbled with it briefly over a decade ago when I first started learning to code. As I was finishing my MA in Sanskrit Studies and beginning to imagine this app, I assumed I&#8217;d need to spend at least six months head-down, learning Python from scratch before I could even get started. But then LLMs came along and suddenly, I could write working Python code <em>without</em> needing to formally study it. It just worked. I&#8217;m convinced that without LLMs + Python - I wouldn&#8217;t have been able to build this app! </p><p>The takeaway? Any Swift developer can now pick up Python on the fly - and that&#8217;s the real superpower of LLMs. Even agentic systems, like OpenAI&#8217;s o models, often rely on generating and executing Python scripts behind the scenes to produce accurate results. Right now, that&#8217;s the most reliable way to get meaningful output from LLMs. So before getting swept up in the agent hype, see if a well-crafted Python script can solve your problem. More often than not, it will.</p><h2>Learning New Tools</h2><p>While building the Sanskrit Dictionary app, I had to dive into two platforms I&#8217;d never used before: Supabase and Railway. Both are relatively easy to get started with, but using their more advanced features would&#8217;ve felt overwhelming if not for LLMs. With AI guiding me, the learning curve became not just easy, but honestly kind of addictive.</p><p>Take Supabase edge functions, for example. I was initially intimidated as I&#8217;ve never written a line of TypeScript, and I had no idea what Deno even was. But with LLMs helping me adapt and generate the right code, it felt like gaining a superpower!!</p><p>And did you know you can deploy a standalone Python script to Railway and call it via API?!!! That&#8217;s the kind of mind-blowing capability I wouldn&#8217;t even have found out about with LLMs guiding me. </p><p>Again - the takeaway here is that even if you&#8217;re a Swift developer, LLMs have opened up a whole new world of powerful tools and platforms - <strong>with almost no traditional learning curve</strong>. You don&#8217;t need to master every new language or framework from scratch anymore. You just need to know what you want to build.</p><h2>Understanding Open Source Libraries</h2><p>Some of the Sanskrit resources I had to use to build my app were written in Python that was just not accessible for me. My hope while I was in academia was always to work with the library creators to try to understand how these libraries work. </p><p>But now there is no need! By using <a href="https://uithub.com/">uithub.com</a> to extract the library into LLM-readable format + the 1M+ token window of Google Gemini Pro, I was able to get Gemini Pro to explain what the library did and write Python scripts exactly for my use case to use this library. Wow!!</p><p>Again - this is a game-changer for working with any open source library in any language! </p><h2>Using LLMs for Swift</h2><p>Unfortunately, LLMs are just not there in the same way when it comes to working with Swift / iOS / macOS apps. My favorite tool was <a href="https://www.alexcodes.app/">Alex Sidebar</a>, which I highly recommend. But just like any AI solution for Xcode, it is limited by the lack of training data in the models it uses. </p><p>For Swift - the best model is Claude Sonnet (Opus uses up all the rate limited tokens in one question, so not going to include it here). And Alex Sidebar does everything in it&#8217;s power to embed it with context, including documentation. But it will still write super verbose duplicate unmanageable code. </p><p>I use Alex Sidebar + Claude Sonnet in two way. First - if I have a very clear idea of a small coding task I need, I give it clear instructions, then I look carefully through the code and refactor it. Make sure to do this!! Claude Sonnet will take shortcuts and provide weird solutions that are very subtle and can go undetected without careful inspection. I really love the Diff viewer in Alex Sidebar to see exactly what changes were made - many times it&#8217;ll change something completely unrelated that you specifically have in your code for a purpose&#8230;</p><p>The other way I love using Alex Sidebar is for prototyping a feature I&#8217;m not exactly sure about. I would commit all my working code, then accept everything Alex Sidebar says (VIBE CODING ALERT!!!) to visually see what it builds. Once I have a better idea of what I want and how to architect properly, I will delete all this code, and go step-by-step as above, slowly and double checking the work as I recode the same feature. </p><p>The takeaway? Don&#8217;t trust the hype! While these code assistant models are amazing. I&#8217;m not going to argue with that! And do increase my productivity 10x, I&#8217;m always skeptical and refactor the code to make sure I understand the code and can work with my own codebase in the future. This is critical!</p><h2>Conclusion</h2><p>As Swift developers, we&#8217;re no longer locked into Swift. And that&#8217;s incredibly empowering! With the help of LLMs, we can now tap into the vast ecosystem of tools, languages, and platforms that were once too time-consuming or intimidating to learn. Whether it&#8217;s writing Python scripts, deploying backend functions, or understanding open source libraries in unfamiliar languages, we now have the ability to move fast and build things that would have taken months or been out of reach entirely! not too long ago.</p><p>What has once been impossible is not possible beyond our wildest imaginations!! My mind was completely blown with every step I took to make the &#8220;impossible&#8221; Sanskrit Dictionary app and this is only the starting point. </p><p>At the same time, we have to stay grounded. AI is a tool, not a shortcut. It can supercharge productivity, but it still requires judgment, refactoring, and a solid understanding of what you&#8217;re building. The real magic happens when you combine your developer intuition with the power of these tools.</p><p>So build boldly, but refactor carefully. Learn just enough, trust selectively, and let LLMs open doors, not create blind spots. </p><p>Happy Building &#128640;</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.natashatherobot.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">This Substack is reader-supported. To receive new posts and support my work, consider becoming a free or paid subscriber.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[How to Work with OpenAI's Batch API (not in Swift!)]]></title><description><![CDATA[Learn how to preprocess your data and save 50% on costs using OpenAI&#8217;s Batch API - with practical tips, Python scripting shortcuts, and a visual workflow to make it all easier.]]></description><link>https://www.natashatherobot.com/p/openai-batch-api</link><guid isPermaLink="false">https://www.natashatherobot.com/p/openai-batch-api</guid><dc:creator><![CDATA[NatashaTheRobot]]></dc:creator><pubDate>Sat, 24 May 2025 13:31:31 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!WE6u!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F573822b8-e56e-4234-8172-ec3015db5500_416x802.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Lately, I&#8217;ve been exploring ways to move beyond the real-time mindset when working with LLMs. Specifically, how we can preprocess existing data at the database level before users ever trigger a request. (If you&#8217;re curious, check out <em><a href="https://www.natashatherobot.com/p/preprocessing-using-llms">The Case for Preprocessing: Using LLMs Before Your Users Do</a></em>.) One of the biggest wins? Using OpenAI&#8217;s Batch API can cut your costs in half (literally 50%!) while letting you scale efficiently.</p><p>So how do you actually use the Batch API? While I love building AI-powered apps in Swift, this is one of those cases where Python really shines, especially when you need to handle file processing like converting between <code>.jsonl</code> and <code>.csv</code>, etc. LLMs are exceptionally good at working with Python for these kinds of tasks. Just open up Cursor, paste in the <a href="https://platform.openai.com/docs/api-reference/batch">Batch API docs</a>  docs (or turn on web search), and have it generate a custom script tailored to your needs.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.natashatherobot.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">This Substack is reader-supported. To receive new posts and support my work, consider becoming a free or paid subscriber.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p>I won&#8217;t dive too deep into writing the Python script - again, this part is incredibly easy with Cursor. What I do want to highlight, though (and this might not be immediately obvious), is that OpenAI provides a visual interface for submitting batch jobs. So really, the only script you need is one that splits your data into chunks of 50,000 or fewer entries and saves them as .jsonl files. From there, you can handle the rest visually, which, personally, I love.</p><p>To get to OpenAI&#8217;s visual interface, select your project and go to your Dashboard, which you can find in the top right menu next to your account: </p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!5ZBa!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c6af6c5-0ba5-431b-9628-e483421d6bac_926x96.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!5ZBa!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c6af6c5-0ba5-431b-9628-e483421d6bac_926x96.png 424w, https://substackcdn.com/image/fetch/$s_!5ZBa!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c6af6c5-0ba5-431b-9628-e483421d6bac_926x96.png 848w, https://substackcdn.com/image/fetch/$s_!5ZBa!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c6af6c5-0ba5-431b-9628-e483421d6bac_926x96.png 1272w, https://substackcdn.com/image/fetch/$s_!5ZBa!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c6af6c5-0ba5-431b-9628-e483421d6bac_926x96.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!5ZBa!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c6af6c5-0ba5-431b-9628-e483421d6bac_926x96.png" width="926" height="96" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1c6af6c5-0ba5-431b-9628-e483421d6bac_926x96.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:96,&quot;width&quot;:926,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:49075,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/164301692?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c6af6c5-0ba5-431b-9628-e483421d6bac_926x96.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!5ZBa!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c6af6c5-0ba5-431b-9628-e483421d6bac_926x96.png 424w, https://substackcdn.com/image/fetch/$s_!5ZBa!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c6af6c5-0ba5-431b-9628-e483421d6bac_926x96.png 848w, https://substackcdn.com/image/fetch/$s_!5ZBa!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c6af6c5-0ba5-431b-9628-e483421d6bac_926x96.png 1272w, https://substackcdn.com/image/fetch/$s_!5ZBa!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1c6af6c5-0ba5-431b-9628-e483421d6bac_926x96.png 1456w" sizes="100vw" fetchpriority="high"></picture><div></div></div></a></figure></div><p>In the right-hand side menu, you&#8217;ll see several options, including the option for &#8220;Batches&#8221;: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!WE6u!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F573822b8-e56e-4234-8172-ec3015db5500_416x802.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!WE6u!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F573822b8-e56e-4234-8172-ec3015db5500_416x802.png 424w, https://substackcdn.com/image/fetch/$s_!WE6u!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F573822b8-e56e-4234-8172-ec3015db5500_416x802.png 848w, https://substackcdn.com/image/fetch/$s_!WE6u!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F573822b8-e56e-4234-8172-ec3015db5500_416x802.png 1272w, https://substackcdn.com/image/fetch/$s_!WE6u!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F573822b8-e56e-4234-8172-ec3015db5500_416x802.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!WE6u!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F573822b8-e56e-4234-8172-ec3015db5500_416x802.png" width="416" height="802" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/573822b8-e56e-4234-8172-ec3015db5500_416x802.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:802,&quot;width&quot;:416,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:130522,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/164301692?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F573822b8-e56e-4234-8172-ec3015db5500_416x802.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!WE6u!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F573822b8-e56e-4234-8172-ec3015db5500_416x802.png 424w, https://substackcdn.com/image/fetch/$s_!WE6u!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F573822b8-e56e-4234-8172-ec3015db5500_416x802.png 848w, https://substackcdn.com/image/fetch/$s_!WE6u!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F573822b8-e56e-4234-8172-ec3015db5500_416x802.png 1272w, https://substackcdn.com/image/fetch/$s_!WE6u!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F573822b8-e56e-4234-8172-ec3015db5500_416x802.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>To create a new Batch job, simply upload your <code>jsonl</code> file and select the endpoint that it&#8217;s for: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!8P8f!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F602ffe55-f6a3-47df-bb30-467d3cbf2bca_868x1182.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!8P8f!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F602ffe55-f6a3-47df-bb30-467d3cbf2bca_868x1182.png 424w, https://substackcdn.com/image/fetch/$s_!8P8f!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F602ffe55-f6a3-47df-bb30-467d3cbf2bca_868x1182.png 848w, https://substackcdn.com/image/fetch/$s_!8P8f!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F602ffe55-f6a3-47df-bb30-467d3cbf2bca_868x1182.png 1272w, https://substackcdn.com/image/fetch/$s_!8P8f!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F602ffe55-f6a3-47df-bb30-467d3cbf2bca_868x1182.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!8P8f!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F602ffe55-f6a3-47df-bb30-467d3cbf2bca_868x1182.png" width="868" height="1182" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/602ffe55-f6a3-47df-bb30-467d3cbf2bca_868x1182.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1182,&quot;width&quot;:868,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:130268,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/164301692?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F602ffe55-f6a3-47df-bb30-467d3cbf2bca_868x1182.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!8P8f!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F602ffe55-f6a3-47df-bb30-467d3cbf2bca_868x1182.png 424w, https://substackcdn.com/image/fetch/$s_!8P8f!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F602ffe55-f6a3-47df-bb30-467d3cbf2bca_868x1182.png 848w, https://substackcdn.com/image/fetch/$s_!8P8f!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F602ffe55-f6a3-47df-bb30-467d3cbf2bca_868x1182.png 1272w, https://substackcdn.com/image/fetch/$s_!8P8f!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F602ffe55-f6a3-47df-bb30-467d3cbf2bca_868x1182.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Once you create the batch, it&#8217;ll first validate that your data is in the correct format. If not, it&#8217;ll give a detailed error message, which you can use to fix your <code>jsonl</code> file. It&#8217;ll then take up to 24 hours to process the data: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ofw1!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F474211d5-63b3-47de-ab45-6369b102f26a_444x492.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ofw1!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F474211d5-63b3-47de-ab45-6369b102f26a_444x492.png 424w, https://substackcdn.com/image/fetch/$s_!ofw1!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F474211d5-63b3-47de-ab45-6369b102f26a_444x492.png 848w, https://substackcdn.com/image/fetch/$s_!ofw1!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F474211d5-63b3-47de-ab45-6369b102f26a_444x492.png 1272w, https://substackcdn.com/image/fetch/$s_!ofw1!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F474211d5-63b3-47de-ab45-6369b102f26a_444x492.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ofw1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F474211d5-63b3-47de-ab45-6369b102f26a_444x492.png" width="444" height="492" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/474211d5-63b3-47de-ab45-6369b102f26a_444x492.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:492,&quot;width&quot;:444,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:92708,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/164301692?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F474211d5-63b3-47de-ab45-6369b102f26a_444x492.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ofw1!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F474211d5-63b3-47de-ab45-6369b102f26a_444x492.png 424w, https://substackcdn.com/image/fetch/$s_!ofw1!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F474211d5-63b3-47de-ab45-6369b102f26a_444x492.png 848w, https://substackcdn.com/image/fetch/$s_!ofw1!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F474211d5-63b3-47de-ab45-6369b102f26a_444x492.png 1272w, https://substackcdn.com/image/fetch/$s_!ofw1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F474211d5-63b3-47de-ab45-6369b102f26a_444x492.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Once it is completed, you&#8217;ll be able to download the output files and a file with errors if there are any - both in <code>jsonl</code> format. For example: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!EcX9!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d864915-9a14-4cb2-9c92-99da5bdf2751_1036x1192.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!EcX9!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d864915-9a14-4cb2-9c92-99da5bdf2751_1036x1192.png 424w, https://substackcdn.com/image/fetch/$s_!EcX9!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d864915-9a14-4cb2-9c92-99da5bdf2751_1036x1192.png 848w, https://substackcdn.com/image/fetch/$s_!EcX9!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d864915-9a14-4cb2-9c92-99da5bdf2751_1036x1192.png 1272w, https://substackcdn.com/image/fetch/$s_!EcX9!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d864915-9a14-4cb2-9c92-99da5bdf2751_1036x1192.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!EcX9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d864915-9a14-4cb2-9c92-99da5bdf2751_1036x1192.png" width="1036" height="1192" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7d864915-9a14-4cb2-9c92-99da5bdf2751_1036x1192.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1192,&quot;width&quot;:1036,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:395491,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/164301692?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d864915-9a14-4cb2-9c92-99da5bdf2751_1036x1192.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!EcX9!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d864915-9a14-4cb2-9c92-99da5bdf2751_1036x1192.png 424w, https://substackcdn.com/image/fetch/$s_!EcX9!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d864915-9a14-4cb2-9c92-99da5bdf2751_1036x1192.png 848w, https://substackcdn.com/image/fetch/$s_!EcX9!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d864915-9a14-4cb2-9c92-99da5bdf2751_1036x1192.png 1272w, https://substackcdn.com/image/fetch/$s_!EcX9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7d864915-9a14-4cb2-9c92-99da5bdf2751_1036x1192.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>I know we&#8217;re all developers and are &#8220;supposed&#8221; to work via API, especially in the age of agents, but having this super nice interface for Batch jobs is super super nice to work with, and something that is unique to OpenAI. </p><p>One last tip - whether you&#8217;re using the API or the UI, be sure to delete all your uploaded files and the batch files once you&#8217;re done processing the batch. OpenAI charges for file storage, so cleaning up afterwards can help you avoid unnecessary costs. You can do that via UI as well just by selecting &#8220;Storage&#8221; in the Dashboard menu. Super convenient! </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!MITV!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6b77819c-f4a0-4d8c-9418-87806b9d2de7_410x814.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!MITV!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6b77819c-f4a0-4d8c-9418-87806b9d2de7_410x814.png 424w, https://substackcdn.com/image/fetch/$s_!MITV!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6b77819c-f4a0-4d8c-9418-87806b9d2de7_410x814.png 848w, https://substackcdn.com/image/fetch/$s_!MITV!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6b77819c-f4a0-4d8c-9418-87806b9d2de7_410x814.png 1272w, https://substackcdn.com/image/fetch/$s_!MITV!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6b77819c-f4a0-4d8c-9418-87806b9d2de7_410x814.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!MITV!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6b77819c-f4a0-4d8c-9418-87806b9d2de7_410x814.png" width="410" height="814" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6b77819c-f4a0-4d8c-9418-87806b9d2de7_410x814.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:814,&quot;width&quot;:410,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:131757,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.natashatherobot.com/i/164301692?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6b77819c-f4a0-4d8c-9418-87806b9d2de7_410x814.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!MITV!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6b77819c-f4a0-4d8c-9418-87806b9d2de7_410x814.png 424w, https://substackcdn.com/image/fetch/$s_!MITV!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6b77819c-f4a0-4d8c-9418-87806b9d2de7_410x814.png 848w, https://substackcdn.com/image/fetch/$s_!MITV!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6b77819c-f4a0-4d8c-9418-87806b9d2de7_410x814.png 1272w, https://substackcdn.com/image/fetch/$s_!MITV!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6b77819c-f4a0-4d8c-9418-87806b9d2de7_410x814.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Happy Batching! </p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.natashatherobot.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">This Substack is reader-supported. To receive new posts and support my work, consider becoming a free or paid subscriber.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item></channel></rss>