<?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[Rok's Blog]]></title><description><![CDATA[The personal blog of Dr Rok Strniša.]]></description><link>https://blog.strnisa.com</link><image><url>https://substackcdn.com/image/fetch/$s_!L9dJ!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F73a04a0f-f826-4e95-9783-614441d53f01_1280x1280.png</url><title>Rok&apos;s Blog</title><link>https://blog.strnisa.com</link></image><generator>Substack</generator><lastBuildDate>Fri, 10 Apr 2026 07:36:24 GMT</lastBuildDate><atom:link href="https://blog.strnisa.com/feed" rel="self" type="application/rss+xml"/><copyright><![CDATA[Rok Strniša]]></copyright><language><![CDATA[en]]></language><webMaster><![CDATA[rok.strnisa@gmail.com]]></webMaster><itunes:owner><itunes:email><![CDATA[rok.strnisa@gmail.com]]></itunes:email><itunes:name><![CDATA[Rok Strniša]]></itunes:name></itunes:owner><itunes:author><![CDATA[Rok Strniša]]></itunes:author><googleplay:owner><![CDATA[rok.strnisa@gmail.com]]></googleplay:owner><googleplay:email><![CDATA[rok.strnisa@gmail.com]]></googleplay:email><googleplay:author><![CDATA[Rok Strniša]]></googleplay:author><itunes:block><![CDATA[Yes]]></itunes:block><item><title><![CDATA[AI-calls-Editor]]></title><description><![CDATA[IDE-native refactoring for AI coding assistants]]></description><link>https://blog.strnisa.com/p/ai-calls-editor</link><guid isPermaLink="false">https://blog.strnisa.com/p/ai-calls-editor</guid><dc:creator><![CDATA[Rok Strniša]]></dc:creator><pubDate>Thu, 20 Nov 2025 14:06:31 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/ea1feefa-fac1-49dc-9145-27edcd01da77_2132x1406.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>AI coding assistants are getting good at generating code. However, there are some refactoring operations, such as renaming a symbol across a codebase or moving a definition and updating its references/imports, which should be instant (and free), but instead often take a substantial amount of both time and tokens.</p><p>The problem is that most coding assistants approach refactoring with the usual:</p><ol><li><p>Search for occurrences. This is often unreliable, especially in large projects, due to language features like scoped namespaces.</p></li><li><p>Read file sections.</p></li><li><p>Generate text patches.</p></li></ol><p>Both (2) and (3) are expensive in terms of tokens.</p><p>A good AI assistant will often perform the above approach correctly through a multi-shot loop that involves linting, type-checking, and running tests (assuming it received good instructions), all of which add to token usage and time.</p><p>There&#8217;s a much better approach: <em>use the IDE&#8217;s built-in refactoring engine</em>. It&#8217;s correct, fast, and uses almost no tokens. Here&#8217;s the outline of the &#8220;AI-calls-Editor&#8221; approach for Claude Code and Visual Studio Code.</p><p><strong>Create the MCP Extension.</strong> Open your project in Visual Studio Code, which has an Extension that runs a mini local MCP server. The MCP server can receive a file path, a line number, a column number, and the new name, and then rename a symbol with:</p><pre><code>vscode.commands.executeCommand(&#8221;vscode.executeDocumentRenameProvider&#8221;, path, position, name)</code></pre><p><strong>Register the MCP Server.</strong> Claude Code is informed about this capability with:</p><pre><code>claude mcp add --transport http ai-calls-editor http://localhost:7272/mcp</code></pre><p><strong>Using the Capability.</strong> When Claude needs to rename a symbol, it only needs to figure out the parameters and make the call. It works.</p><p>Prototype:<a href="https://github.com/rokstrnisa/ai-calls-editor"> https://github.com/rokstrnisa/ai-calls-editor</a> &#8212; contributions welcome!</p><p>Let&#8217;s save our tokens and our time.</p><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://blog.strnisa.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">Thanks for reading my blog! Subscribe for free to receive new posts and support my work.</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[Investing for Anyone]]></title><description><![CDATA[A low-stress and effective way to invest your savings.]]></description><link>https://blog.strnisa.com/p/investing-for-anyone</link><guid isPermaLink="false">https://blog.strnisa.com/p/investing-for-anyone</guid><dc:creator><![CDATA[Rok Strniša]]></dc:creator><pubDate>Sat, 24 Aug 2024 12:07:37 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!tCeH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb393d6cc-0219-483f-b542-f2e2f20ec7e6_6532x4238.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!tCeH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb393d6cc-0219-483f-b542-f2e2f20ec7e6_6532x4238.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!tCeH!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb393d6cc-0219-483f-b542-f2e2f20ec7e6_6532x4238.jpeg 424w, https://substackcdn.com/image/fetch/$s_!tCeH!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb393d6cc-0219-483f-b542-f2e2f20ec7e6_6532x4238.jpeg 848w, https://substackcdn.com/image/fetch/$s_!tCeH!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb393d6cc-0219-483f-b542-f2e2f20ec7e6_6532x4238.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!tCeH!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb393d6cc-0219-483f-b542-f2e2f20ec7e6_6532x4238.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!tCeH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb393d6cc-0219-483f-b542-f2e2f20ec7e6_6532x4238.jpeg" width="6532" height="4238" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b393d6cc-0219-483f-b542-f2e2f20ec7e6_6532x4238.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:4238,&quot;width&quot;:6532,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:4873488,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&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_!tCeH!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb393d6cc-0219-483f-b542-f2e2f20ec7e6_6532x4238.jpeg 424w, https://substackcdn.com/image/fetch/$s_!tCeH!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb393d6cc-0219-483f-b542-f2e2f20ec7e6_6532x4238.jpeg 848w, https://substackcdn.com/image/fetch/$s_!tCeH!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb393d6cc-0219-483f-b542-f2e2f20ec7e6_6532x4238.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!tCeH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb393d6cc-0219-483f-b542-f2e2f20ec7e6_6532x4238.jpeg 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="pullquote"><p>Disclaimer: This post is for informational purposes only and not financial advice. Consult a financial advisor before making investment decisions. Investing involves risks.</p></div><h1>How should I invest my savings?</h1><p>In this blog post, I outline a popular approach to achieve an expected yearly growth of ~7% (before inflation) over the long term.</p><h1>Why should I listen to you?</h1><p>After completing my PhD in computer science at the University of Cambridge, I worked at various software companies, as well as a London hedge fund. This article is based on my research and personal experience with investments. That said, I don&#8217;t think you should trust anyone with your investment strategy: <em>do your own research</em>.</p><p>I now believe that most people only need to read one book on the topic: <a href="https://www.amazon.com/dp/0273785370">Smarter Investing by Tim Hale</a>. (Note that I didn&#8217;t share an affiliate link - I have no financial gain from recommending this book and no connection to the author.)</p><p>In the following sections, I try to effectively summarize the main ideas in the book, and show how I put these ideas into practice.</p><h1><strong>Main ideas</strong></h1><p>Through analyses of historical data, the book shows that:</p><ol><li><p>It&#8217;s generally impossible to <em>beat the market</em> in the long term (20+ years), where &#8220;beating the market&#8221; means outperforming the stock market as a whole.</p></li><li><p>Human psychology tends to work against us: we tend to buy when the prices are high (fear of missing out), and sell when they are low (fear of losing more).</p></li></ol><p>Based on this, the book shows that it&#8217;s best to:</p><ol><li><p><em>Match the market</em>, rather than try to beat it.</p></li><li><p>Create a system that prevents our emotions from hurting our investments.</p></li></ol><h1><strong>Investment plan</strong></h1><p><em>(For definitions of various terms used below, see <a href="https://blog.strnisa.com/i/145635821/appendix-terminology">Terminology</a>.)</em></p><p>To &#8220;match the market&#8221;, the book recommends investing in ETFs that:</p><ol><li><p>Together roughly represent the world&#8217;s economy. Good candidates are ETFs that track <a href="https://www.msci.com/www/fact-sheet/msci-world-index/05830501">MSCI World Index</a>, or <a href="https://research.ftserussell.com/Analytics/Factsheets/Home/DownloadSingleIssue?issueName=AWD&amp;IsManual=False">FTSE Developed</a> and <a href="https://research.ftserussell.com/Analytics/Factsheets/Home/DownloadSingleIssue?issueName=AWALLE&amp;IsManual=false">FTSE Emerging</a>.</p></li><li><p>Have a low management fee, e.g. below 0.25% / year.</p></li><li><p>Are from a reputable fund manager (e.g. Vanguard, SPDR, iShares/BlackRock).</p></li><li><p>Have various other properties, like suitable <a href="https://pearler.com/help/8799887-what-is-a-fund-domicile-and-why-does-it-matter">domicile</a> (for your taxes), size ($100M+), age (5+ years), <a href="https://www.vanguard.co.uk/professional/vanguard-365/investment-knowledge/etf-knowledge/etf-basics">physical tracking</a>, trading in your local currency, and are <a href="https://www.justetf.com/en/news/etf/distributing-or-accumulating-etfs-how-to-handle-investment-income.html">accumulating</a> (depending on the tax laws in your country).</p></li></ol><p>In addition, the book recommends investing in reliable bonds to increase your portfolio&#8217;s stability by sacrificing some long-term growth:</p><ol><li><p>This part normally represents between 10% and 50% of your portfolio, where lower values are recommended if you&#8217;re younger or have other stable assets.</p></li><li><p>The recommended bonds are short-term government bonds and global inflation-linked government bonds.</p></li><li><p>The bonds, too, should normally be bought through ETFs rather than directly.</p></li></ol><p>Using the above, you can create an investment portfolio where each ETF represents some target percentage of the total portfolio value.</p><p>Such a portfolio, where the stocks represent around 75%, is statistically expected to return around 7% per year over the long run (20+ years). Therefore, the portfolio is expected to roughly double every 10 years (not accounting for inflation).</p><h1><strong>Dealing with human psychology</strong></h1><p>The book recommends the following system:</p><ol><li><p>Do not follow any financial news. If you hear something good/bad, doing nothing to your portfolio is statistically the best thing to do.</p></li><li><p>Invest your monthly savings. Always buy the ETFs that are currently below their target percentage in your portfolio.</p></li><li><p>Rebalance every 6-12 months. Sell ETFs that are above their target percentage, and buy those that are below, to get them to roughly the target percentages.</p></li></ol><p>With the above approach, you will often buy an ETF when its price is low and sell it when its price is high.</p><h1><strong>How I put this into practice</strong></h1><p>I live in the European Union, so I bought Euro-based ETFs domiciled in Ireland.</p><p>The stocks represent 75% of my portfolio, and include the following ETFs:</p><ul><li><p><a href="https://www.justetf.com/en/etf-profile.html?isin=IE00BK5BQV03">Vanguard FTSE Developed World UCITS ETF</a>. 75% of the stocks.</p></li><li><p><a href="https://www.justetf.com/en/etf-profile.html?isin=IE00BK5BR733">Vanguard FTSE Emerging Markets UCITS ETF</a>. 15% of the stocks.</p></li><li><p><a href="https://www.justetf.com/en/etf-profile.html?isin=IE00B8GF1M35#overview">SPDR Dow Jones Global Real Estate UCITS ETF</a>. 10% of the stocks.</p></li></ul><p>The bonds represent 25% of my portfolio, and include the following ETFs:</p><ul><li><p><a href="https://lt.morningstar.com/1c6qh1t6k9/etfreport/default.aspx?1=1&amp;tab=1&amp;SecurityToken=0P0001CR3E%5D22%5D0%5DETEXG%24XLON&amp;Id=0P0001CR3E&amp;ClientFund=0&amp;CurrencyId=EUR">JPM BetaBuilders EUR Govt Bond 1-3 yr UCITS ETF</a>. 25% of the bonds.</p></li><li><p><a href="https://www.morningstar.co.uk/uk/etf/snapshot/snapshot.aspx?id=0P0000I0HZ">iShares $ Treasury Bond 1-3yr UCITS ETF</a>. 25% of the bonds.</p></li><li><p><a href="https://www.morningstar.co.uk/uk/etf/snapshot/snapshot.aspx?id=0P0000M2YA">iShares Global Inflation Linked Govt Bond UCITS ETF</a>. 50% of the bonds.</p></li></ul><p>To manage my portfolio, I use an investment platform called <a href="https://www.interactivebrokers.ie/en/home.php">Interactive Brokers</a>, since it allows me to buy almost any ETF, is reliable, and has low transaction fees. There are many other investment platforms - please do your own research.</p><p>Interactive Brokers has <a href="https://www.interactivebrokers.com/en/trading/referral-member-to-member.php">a referral program</a>, which matches your initial investment up to $1000. You can use <a href="https://ibkr.com/referral/luka644">my referral link</a>, but please don&#8217;t feel like you need to.</p><h1><strong>FAQ</strong></h1><ul><li><p><strong>Should I buy crypto?</strong> Crypto is generally not linked to an underlying asset, and its markets are relatively unregulated, which invites a substantial amount of fraud. In addition, the crypto market is too new for there to be a proven long-term passive investment strategy.</p></li><li><p><strong>Should I buy gold?</strong> In the long term, the price of gold is fairly stable after adjusting for inflation, which means that holding gold is, in the long term, worse than investing as described in this blog post, assuming the average inflation is lower than 7%.</p></li><li><p><strong>Should I buy individual stocks/smaller ETFs?</strong> By doing this, you&#8217;re trying to beat the market as a whole, so you will, statistically speaking, likely do worse in the long term than following the described investment strategy.</p></li></ul><h1><strong>Conclusion</strong></h1><p>I hope this post has given you a better understanding on how you can invest your savings, and helps you find an effective and stress-free way to grow your portfolio.</p><p>If you found this post helpful, feel free to share it with your friends and subscribe to my blog below. You can also follow me on <a href="https://x.com/RokStrnisa">X</a> or <a href="https://linkedin.com/in/strnisa/">LinkedIn</a>. If you have any thoughts or questions, leave a comment.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://blog.strnisa.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">Thank you for reading my blog! Subscribe for free to be notified of new posts.</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><h1><strong>Appendix: Terminology</strong></h1><ul><li><p><strong>Share/Stock.</strong> A share in the ownership of a company.</p></li><li><p><strong>Dividends.</strong> Distribution of a company&#8217;s profits to its shareholders.</p></li><li><p><strong>Bond.</strong> A loan to the issuing company/country for some period that results in interest at the end of the period (maturity date).</p></li><li><p><strong>Stock Exchange.</strong> A market where stocks are bought and sold, e.g. New York Stock Exchange (NYSE).</p></li><li><p><strong>Publicly Traded Company.</strong> A company whose stocks can be bought and sold by the general public.</p></li><li><p><strong>[Market] Index.</strong> A weighted list of companies whose stocks are publicly traded at stock exchanges. The list is normally updated according to a predefined formula, e.g. S&amp;P 500 is an index that tracks the largest 500 US exchange-traded companies.</p></li><li><p><strong>ETF</strong> <strong>(Exchange Traded Fund).</strong> ETF is a fund that normally tracks an index and is traded at a stock exchange. There can be many ETFs for a single index.</p></li><li><p><strong>Bond ETF.</strong> An ETF composed of bonds where bonds of a certain type are continually bought (early in their lifetime) and sold (late in their lifetime) to achieve an equivalent result of doing so manually yourself.</p></li><li><p><strong>Fund Manager.</strong> A company that creates and manages funds, including ETFs.</p></li><li><p><strong>Management Fee.</strong> A percentage fee that the fund manager charges annually to manage a fund.</p></li><li><p><strong>Investment Platform.</strong> A company that holds cash, stocks, bonds, etc. on your behalf, and normally allows you to quickly and easily trade.</p></li></ul>]]></content:encoded></item><item><title><![CDATA[The Birth of AI Operating Systems]]></title><description><![CDATA[macOS, Ubuntu and Windows are popular operating systems (OS) for desktop users.]]></description><link>https://blog.strnisa.com/p/the-birth-of-ai-operating-systems</link><guid isPermaLink="false">https://blog.strnisa.com/p/the-birth-of-ai-operating-systems</guid><dc:creator><![CDATA[Rok Strniša]]></dc:creator><pubDate>Wed, 05 Apr 2023 18:28:00 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/c46cfa17-ddda-43d2-8134-00ae4b41f48c_1600x1600.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!1Mf5!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13bbaa38-cc63-43a0-95c5-52086180a719_1600x1600.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!1Mf5!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13bbaa38-cc63-43a0-95c5-52086180a719_1600x1600.jpeg 424w, https://substackcdn.com/image/fetch/$s_!1Mf5!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13bbaa38-cc63-43a0-95c5-52086180a719_1600x1600.jpeg 848w, https://substackcdn.com/image/fetch/$s_!1Mf5!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13bbaa38-cc63-43a0-95c5-52086180a719_1600x1600.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!1Mf5!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13bbaa38-cc63-43a0-95c5-52086180a719_1600x1600.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!1Mf5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13bbaa38-cc63-43a0-95c5-52086180a719_1600x1600.jpeg" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/13bbaa38-cc63-43a0-95c5-52086180a719_1600x1600.jpeg&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;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&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_!1Mf5!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13bbaa38-cc63-43a0-95c5-52086180a719_1600x1600.jpeg 424w, https://substackcdn.com/image/fetch/$s_!1Mf5!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13bbaa38-cc63-43a0-95c5-52086180a719_1600x1600.jpeg 848w, https://substackcdn.com/image/fetch/$s_!1Mf5!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13bbaa38-cc63-43a0-95c5-52086180a719_1600x1600.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!1Mf5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13bbaa38-cc63-43a0-95c5-52086180a719_1600x1600.jpeg 1456w" sizes="100vw" fetchpriority="high"></picture><div></div></div></a><figcaption class="image-caption">A thinking humanoid robot. (Generated with Midjourney.)</figcaption></figure></div><p>macOS, Ubuntu and Windows are popular operating systems (OS) for desktop users. There are also OSes for mobile phones, cloud servers, etc. Let&#8217;s refer to these as &#8220;standard OSes&#8221;.</p><p>With the advent of large language models, such as GPT-4 used by ChatGPT, &#8220;AI operating systems&#8221; (AI OSes) become possible. In this post, I explain what I mean by this, what an architecture of an AI OS could look like, and where I think the next steps are.</p><h1>Background</h1><p>GPT (Generative Pre-trained Transformer) is a large language model (LLM) that is very good at doing one specific task: &#8220;finding relevant word sequences (tokens) that follow a particular piece of text.&#8221; It is based on the work by Vaswani et al, e.g. <a href="https://arxiv.org/abs/1706.03762">Attention Is All You Need</a>. The models are trained on vast amounts of data from many sources and are then fine-tuned to work even better for certain types of tasks, e.g. summarization, translation and answering questions.</p><p>While the models are massive (tens of GB), their &#8220;context window&#8221;, i.e. short-term memory, is comparatively very small. For example, GPT-4 has the maximum context window of 8K &#8220;tokens&#8221;, which corresponds to ~32K characters or ~6K words in English. This may seem like a lot, but it quickly becomes the limiting factor when doing more complex tasks, e.g. summarizing/generating long text.</p><p>LLMs can also be "fine-tuned" (i.e., trained on custom data) to increase their knowledge base. This "fine-tuning" is a handy way to attenuate the previously mentioned token burden by pre-specialising the LLM to perform specific tasks. Unfortunately, at the time of writing, OpenAI does not support fine-tuning GPT-4.</p><p>It&#8217;s also worth noting that the text generation of these models is still quite slow. For example, a request to the GPT-4 API currently takes on the order of seconds or tens of seconds (depending on the length of its response). This is a very long time compared to the milliseconds or even microseconds it often takes to complete a task on a local machine.</p><h1>Giving It Wings</h1><p>By itself, an LLM &#8220;only&#8221; generates text. However, we can use this ability to:</p><ol><li><p>Give it a goal to perform some high-level tasks.</p></li><li><p>Tell it that it can use some predefined set of actions to achieve these tasks.</p></li><li><p>Repeat until the goal is complete:</p><ol><li><p>Ask it to create a plan to achieve the tasks and create a list of actions to run.</p></li><li><p>Execute the actions on its behalf.</p></li><li><p>Tell it the results of the actions.</p></li></ol></li></ol><p>I wrote a proof of concept of the above approach: <a href="https://blog.rok.strnisa.com/2023/04/how-i-got-chatgpt-to-write-complete.html">How I Got ChatGPT to Write Complete Programs</a>. At the same time, similar proofs of concepts were created (e.g. <a href="https://github.com/Torantulino/Auto-GPT">AutoGPT</a>, <a href="https://github.com/yoheinakajima/babyagi">BabyAGI</a> and my own <a href="https://github.com/rokstrnisa/Robo-GPT">RoboGPT</a>). These are still experimental and not very reliable attempts at creating (semi-)Autonomous AI Agents (A3), but they show promise in the general approach.</p><p>I view these experiments as precursors of well-designed, robust, and extensible AI operating systems that can reliably perform a wide variety of complex tasks.</p><h1>The AI Operating System</h1><p>The architecture of the systems built so far is in some ways quite similar to the architecture of the standard OSes.</p><p>There are still many unknowns, but the main components of an AI Operating System appear to be:</p><ol><li><p><strong>Kernel.</strong> Manages short-term and long-term storage, AI and non-AI processes, inter-process communication.</p></li><li><p><strong>Plug-in System.</strong> A system that allows the user to add/remove the capabilities that the system as a whole can do. For example, one could have a &#8220;file system&#8221; plug-in, which allows the system to perform <em>actions</em> such as &#8220;list a directory&#8221;, &#8220;read a file&#8221; and &#8220;write a file&#8221;.</p></li><li><p><strong>[Task] Planner(s).</strong> This is an AI process that is responsible for evaluating the current goal(s), task(s) and the intermediate results, generating new tasks (if any), and prioritizing the remaining tasks. The key here is to divide and conquer, e.g. a single user-provided goal is continually split into smaller and smaller tasks until all of them can be performed by the available actions.</p></li><li><p><strong>[Action] Runner(s).</strong> Once a task has been reduced to specific actions that the system knows how to execute, the task runner runs these actions and returns their result (which could be a failure).</p></li><li><p><strong>User Interface (UI).</strong> A way for the user to enter the initial goal, to see the intermediate and final result, and (optionally) to interact with the system as it is doing the work &#8212; this could include updating the goal, suggesting alternative tasks, confirming proposed actions before they are executed, etc.</p></li></ol><p>A few things to note about the above items:</p><ol><li><p>The plug-in system mentioned in (2) is used to add capabilities to the AI Operating System directly, allowing it to execute different types of actions. The plug-in ecosystem lives outside of any LLM. In comparison, the ChatGPT plug-in system lives within the OpenAI ecosystem and is used to augment the capabilities of ChatGPT itself.</p></li><li><p>Each plug-in defines the name of each action, what syntax it has (these are instructions for the LLM for how to write the text for the action to run), the parser (this is a small program that converts text written by the LLM to a logical action to run), and the runner spec (this defines what to do when running the action). There is probably a way to use a standard parser generator, in which case the syntax and the parser are replaced with a grammar definition.</p></li><li><p>The action can itself run an AI process, e.g. to summarize some text. However, this is irrelevant to the overall architecture, since these AI processes should be completely isolated from the Planner(s).</p></li></ol><p>Here is what the high-level AI Operating System architecture could look like:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!8AdB!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F776441b4-6f20-484a-bb67-0c1699eaf650_640x480.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!8AdB!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F776441b4-6f20-484a-bb67-0c1699eaf650_640x480.png 424w, https://substackcdn.com/image/fetch/$s_!8AdB!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F776441b4-6f20-484a-bb67-0c1699eaf650_640x480.png 848w, https://substackcdn.com/image/fetch/$s_!8AdB!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F776441b4-6f20-484a-bb67-0c1699eaf650_640x480.png 1272w, https://substackcdn.com/image/fetch/$s_!8AdB!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F776441b4-6f20-484a-bb67-0c1699eaf650_640x480.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!8AdB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F776441b4-6f20-484a-bb67-0c1699eaf650_640x480.png" width="640" height="480" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/776441b4-6f20-484a-bb67-0c1699eaf650_640x480.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:480,&quot;width&quot;:640,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;A diagram showing various components of a possible AI Operating System.&quot;,&quot;title&quot;:&quot;A possible architecture for an AI Operating System.&quot;,&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="A diagram showing various components of a possible AI Operating System." title="A possible architecture for an AI Operating System." srcset="https://substackcdn.com/image/fetch/$s_!8AdB!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F776441b4-6f20-484a-bb67-0c1699eaf650_640x480.png 424w, https://substackcdn.com/image/fetch/$s_!8AdB!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F776441b4-6f20-484a-bb67-0c1699eaf650_640x480.png 848w, https://substackcdn.com/image/fetch/$s_!8AdB!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F776441b4-6f20-484a-bb67-0c1699eaf650_640x480.png 1272w, https://substackcdn.com/image/fetch/$s_!8AdB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F776441b4-6f20-484a-bb67-0c1699eaf650_640x480.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><figcaption class="image-caption">A high-level diagram of the AI Operating System architecture.</figcaption></figure></div><h1>Key Challenges</h1><p>There are still many challenges and uncertainties in developing AI Operating Systems.</p><p>For example, for the Planner(s) to be able to have sufficient context to make effective decisions, the context window of the LLM(s) used must contain the relevant goal, tasks, available actions and the results so far. This can be particularly challenging when dealing with complex goals.</p><p>Another challenge for the Planner(s) is to reliably parse the text of the suggested actions. While LLM(s) have become very good at following specific syntax guidelines, mistakes can still occur. For example, GPT-4 sometimes still has difficulty escaping characters correctly, which is why using JSON to convey code is not ideal.</p><p>Most of the actions run by the Runner(s) should be pretty simple. However, some may require expressing both the request and the result in an efficient manner that still conveys sufficient information back to the Planner(s). This may be difficult in some cases.</p><h1>Final Thoughts</h1><p>The field of (semi-)Autonomous AI Agents (A3) is evolving fast. In this post, we propose a general architecture for AI Operating Systems that could be used to run these agents. A future post may cover the plug-in system in more detail.</p><p>I am currently working on improving <a href="https://github.com/rokstrnisa/Robo-GPT">RoboGPT</a> based on the architecture proposed in this blog post.</p><p>If you have any suggestions on what to try next, or would simply like to stay up to date with my work, follow/DM me on <a href="https://x.com/RokStrnisa">X (Twitter)</a> or <a href="https://linkedin.com/in/strnisa">LinkedIn</a>.</p><p>Thank you for your support and interest in my work!</p>]]></content:encoded></item><item><title><![CDATA[How I Got ChatGPT to Write Complete Programs]]></title><description><![CDATA[Large language models (LLMs) have recently taken the world by storm.]]></description><link>https://blog.strnisa.com/p/how-i-got-chatgpt-to-write-complete</link><guid isPermaLink="false">https://blog.strnisa.com/p/how-i-got-chatgpt-to-write-complete</guid><dc:creator><![CDATA[Rok Strniša]]></dc:creator><pubDate>Sun, 02 Apr 2023 21:48:00 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/cfb6857f-6c8d-4503-80f5-194bea08b772_640x640.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!voFZ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fea28aa06-5ab4-44d3-812d-39ad69332177_640x640.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!voFZ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fea28aa06-5ab4-44d3-812d-39ad69332177_640x640.jpeg 424w, https://substackcdn.com/image/fetch/$s_!voFZ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fea28aa06-5ab4-44d3-812d-39ad69332177_640x640.jpeg 848w, https://substackcdn.com/image/fetch/$s_!voFZ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fea28aa06-5ab4-44d3-812d-39ad69332177_640x640.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!voFZ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fea28aa06-5ab4-44d3-812d-39ad69332177_640x640.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!voFZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fea28aa06-5ab4-44d3-812d-39ad69332177_640x640.jpeg" width="640" height="640" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ea28aa06-5ab4-44d3-812d-39ad69332177_640x640.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:&quot;normal&quot;,&quot;height&quot;:640,&quot;width&quot;:640,&quot;resizeWidth&quot;:640,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&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_!voFZ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fea28aa06-5ab4-44d3-812d-39ad69332177_640x640.jpeg 424w, https://substackcdn.com/image/fetch/$s_!voFZ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fea28aa06-5ab4-44d3-812d-39ad69332177_640x640.jpeg 848w, https://substackcdn.com/image/fetch/$s_!voFZ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fea28aa06-5ab4-44d3-812d-39ad69332177_640x640.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!voFZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fea28aa06-5ab4-44d3-812d-39ad69332177_640x640.jpeg 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><figcaption class="image-caption">A humanoid robot writing with a pen and paper. (Generated with Midjourney.)</figcaption></figure></div><p>Large language models (LLMs) have recently taken the world by storm. You are probably most familiar with ChatGPT, an artificial-intelligence (AI) chatbot developed by OpenAI, which uses the language models also developed by OpenAI. These models are called GPT and the latest version is GPT-4.</p><p>With every new version, the language models are able to accomplish more complex tasks. For example, they can summarize large texts, create new ones based on complex requirements, write code, give suggestions about anything and now even do your taxes.</p><p>It&#8217;s worth noting that these language models can and do make mistakes. First, they are trained on imperfect data, the model itself may have remembered some details incorrectly (similar to JPEG encoding artifacts), and the instructions given by the user may be ambiguous or misleading. Each of these can lead to incorrect output; however, based on my experience, if the user specifies the task well, mistakes are already quite rare.</p><h1>The Idea: Empowering ChatGPT</h1><p>In a recent release of GPT-4, <a href="https://www.youtube.com/live/outcGtbnMuQ?feature=share&amp;t=225">the official launch video</a> included a demo of writing code, and suggesting changes to the code or the development environment in order to make something work. This is where I got an idea.</p><blockquote><p><strong>&#8220;What if ChatGPT was given the power to make these changes automatically?&#8221;</strong></p></blockquote><p>If ChatGPT had indirect access to the developer&#8217;s computer, it would be able to perform these tasks by itself, without the user having to execute the tasks suggested by ChatGPT. But how can it do so, if it&#8217;s &#8220;just a large language model&#8221;?</p><p>We could write a small program that makes requests to ChatGPT, reads what ChatGPT says, and does that. The same program can tell ChatGPT what happened as a result.</p><h1>The Experiment: Creating a Proof Of Concept</h1><p>I wrote detailed instructions to GPT-4 about the syntax for the following actions:</p><ul><li><p><strong>Terminal</strong> - run a specific command in the command-line prompt (e.g. Terminal). This action is very powerful, e.g. install dependencies.</p></li><li><p><strong>CreateFile</strong> - create a new file with specific contents. This action could be simulated through the Terminal action, but doing so requires further escaping, which makes the task unnecessarily more difficult for GPT.</p></li><li><p><strong>ReplaceFile</strong> - update the contents of an existing file.</p></li><li><p><strong>ReplaceLine</strong> - replace the contents of a specific line in an existing file.</p></li><li><p><strong>EndOfActions</strong> - signify that all actions are complete.</p></li></ul><p>Then, I implemented a command-line tool that can parse these actions according to the specified syntax, and is able to execute them on the developer&#8217;s machine.</p><h1>The Demo: A HackerNews Story Summarizer</h1><p>Here is a quick demonstration:</p><div id="youtube2-Gwg43Jbr8zs" class="youtube-wrap" data-attrs="{&quot;videoId&quot;:&quot;Gwg43Jbr8zs&quot;,&quot;startTime&quot;:null,&quot;endTime&quot;:null}" data-component-name="Youtube2ToDOM"><div class="youtube-inner"><iframe src="https://www.youtube-nocookie.com/embed/Gwg43Jbr8zs?rel=0&amp;autoplay=0&amp;showinfo=0&amp;enablejsapi=0" frameborder="0" loading="lazy" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true" width="728" height="409"></iframe></div></div><p>The above video shows how I describe a relatively simple program to the tool, giving the following description:</p><blockquote><p><em>Write a command line program called HackerNews Summarizer, which fetches the contents of the top 3 stories on HackerNews, and summarizes the contents. When the program gets the URL of a story through HackerNews API, it should fetch the HTML from the URL, convert it to text only, and then summarize the first 5000 characters of this text into a single paragraph using OpenAI's text completion with model "text-davinci-003". Quote the text that you pass to OpenAI using the triple backticks (```) syntax. For each story, the program prints its headline, its URL and its summary. Assume that the OpenAI API key is already available through the environment variable OPENAI_API_KEY.</em></p></blockquote><p>This tool then sets up the environment, installs appropriate dependencies, writes files containing source code for the target program, runs the program and checks that the output looks reasonable. Here is the source code it wrote:</p><pre><code>import os
import requests
from bs4 import BeautifulSoup
import openai

OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
HN_API_BASE = "https://hacker-news.firebaseio.com/v0"

def get_top_stories():
    response = requests.get(f"{HN_API_BASE}/topstories.json")
    return response.json()

def get_story_details(story_id):
    response = requests.get(f"{HN_API_BASE}/item/{story_id}.json")
    return response.json()

def fetch_content(url):
    response = requests.get(url)
    soup = BeautifulSoup(response.content, "html.parser")
    return soup.get_text()

def summarize_content(content):
    openai.api_key = OPENAI_API_KEY
    response = openai.Completion.create(
        engine="text-davinci-003",
        prompt=f"Summarize the following content in a single paragraph:\n```{content[:5000]}```\n",
        max_tokens=100,
        n=1,
        temperature=0.5,
    )
    return response.choices[0].text.strip()

def main():
    story_ids = get_top_stories()[:3]

    for story_id in story_ids:
        story = get_story_details(story_id)
        if "url" in story:
            content = fetch_content(story["url"])
            summary = summarize_content(content)
            print(f"Title: {story['title']}\nURL: {story['url']}\nSummary: {summary}\n")

if __name__ == "__main__":
    main()</code></pre><p>It does all of this in roughly 1m30s (parts of the video where the facilitator is waiting for ChatGPT are cut out).</p><h1>Conclusion</h1><p>Currently, when tools like GitHub Copilot (which also uses GPT) suggest a few lines of code, the developer checks if those lines look reasonable. This can already greatly increase developer productivity.</p><p>With the approach described in this post, the idea is for a large language model to iterate on a larger task itself; the developer ideally only needs to check the final result. The proof of concept shown above is still quite limited, but it shows potential.</p><p>If you have any suggestions on what to try next, or would simply like to stay up to date with my work, follow/DM me on <a href="https://x.com/RokStrnisa">X (Twitter)</a> or <a href="https://linkedin.com/in/strnisa">LinkedIn</a>.</p>]]></content:encoded></item></channel></rss>