<?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[Everything Python: Everything LLMs]]></title><description><![CDATA[LLMs, demystified with Python. From transformers to production-ready AI apps - practical guides, code, and concepts for developers at every level.]]></description><link>https://everythingpython.substack.com/s/everything-llms</link><image><url>https://substackcdn.com/image/fetch/$s_!XFIK!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb8b7d669-c5bb-4d0b-8f88-ad71c22aabbb_1024x1024.png</url><title>Everything Python: Everything LLMs</title><link>https://everythingpython.substack.com/s/everything-llms</link></image><generator>Substack</generator><lastBuildDate>Thu, 16 Apr 2026 17:59:33 GMT</lastBuildDate><atom:link href="https://everythingpython.substack.com/feed" rel="self" type="application/rss+xml"/><copyright><![CDATA[Abhiram]]></copyright><language><![CDATA[en]]></language><webMaster><![CDATA[everythingpython@substack.com]]></webMaster><itunes:owner><itunes:email><![CDATA[everythingpython@substack.com]]></itunes:email><itunes:name><![CDATA[Abhiram]]></itunes:name></itunes:owner><itunes:author><![CDATA[Abhiram]]></itunes:author><googleplay:owner><![CDATA[everythingpython@substack.com]]></googleplay:owner><googleplay:email><![CDATA[everythingpython@substack.com]]></googleplay:email><googleplay:author><![CDATA[Abhiram]]></googleplay:author><itunes:block><![CDATA[Yes]]></itunes:block><item><title><![CDATA["Vibe-coding" a status dashboard]]></title><description><![CDATA[I work in the engineering division of a supply chain company and our development process, as most companies do, involves the setting up of our SaaS platform locally.]]></description><link>https://everythingpython.substack.com/p/vibe-coding-a-status-dashboard</link><guid isPermaLink="false">https://everythingpython.substack.com/p/vibe-coding-a-status-dashboard</guid><dc:creator><![CDATA[Abhiram]]></dc:creator><pubDate>Sat, 10 May 2025 08:45:39 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb8b7d669-c5bb-4d0b-8f88-ad71c22aabbb_1024x1024.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I work in the engineering division of  a supply chain company and our development process, as most companies do, involves the setting up of our SaaS platform locally. </p><p>This means that there are a lot of dependent services that need to be run first that support the overall execution of the platform. </p><p>For e.g. - </p><p>Our platform's stack requires SQL Server, Solr, Redis, Postgres, RabbitMQ, MongoDB as core services to be running first. </p><p>Once these are all running and available, a service called WebAPI can be run that makes use of some of the above to run as well. </p><p>Following this, there are a few more microservices that need to run, but that need not be part of this article since the underlying concept will already come through with the above being demonstrated. </p><p>It all started when in practice on a day-to-day basis, whenever I spun up these services, every now and then, at least ONE of them would go down and at best, the error trace was clear enough from the dependent services as to what the issue was. </p><p>But at worst, it's a rabbit hole of errors to wade through before I would land on the root cause and if one of the service's unavailability was the cause, I would feel really sad about having lost all that time. </p><p>So having gone through this time and time again, I thought I could do something about this. </p><p><strong>ITERATION 1 - The first result of this thought was simply - a checklist.</strong></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!jrR-!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e67e736-51ca-4013-a81f-033f5084d014_465x315.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!jrR-!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e67e736-51ca-4013-a81f-033f5084d014_465x315.png 424w, https://substackcdn.com/image/fetch/$s_!jrR-!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e67e736-51ca-4013-a81f-033f5084d014_465x315.png 848w, https://substackcdn.com/image/fetch/$s_!jrR-!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e67e736-51ca-4013-a81f-033f5084d014_465x315.png 1272w, https://substackcdn.com/image/fetch/$s_!jrR-!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e67e736-51ca-4013-a81f-033f5084d014_465x315.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!jrR-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e67e736-51ca-4013-a81f-033f5084d014_465x315.png" width="465" height="315" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9e67e736-51ca-4013-a81f-033f5084d014_465x315.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:315,&quot;width&quot;:465,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:69028,&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://everythingpython.substack.com/i/163261457?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e67e736-51ca-4013-a81f-033f5084d014_465x315.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_!jrR-!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e67e736-51ca-4013-a81f-033f5084d014_465x315.png 424w, https://substackcdn.com/image/fetch/$s_!jrR-!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e67e736-51ca-4013-a81f-033f5084d014_465x315.png 848w, https://substackcdn.com/image/fetch/$s_!jrR-!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e67e736-51ca-4013-a81f-033f5084d014_465x315.png 1272w, https://substackcdn.com/image/fetch/$s_!jrR-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9e67e736-51ca-4013-a81f-033f5084d014_465x315.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 it got the bare minimum accomplished, in that, I now had a ready reckoner of all the services that needed to be up each time, I had no way of tracking when something went Down during operations. Additionally, if any of the services were not started , either at startup or by me, the service would simply be neglected till such time as an error would alert me. </p><blockquote><p><em><strong>Rejected coz</strong> :</em> Tick-boxes fixed my <em>initial</em> <em>forgetfulness</em> but still left me blind to mid-session crashes.</p></blockquote><div><hr></div><p>This was not working out. </p><p>Over time, I tried/considered a few more things - </p><p>a) <strong>writing a script</strong> to start them all at once at startup - this failed miserably more often than not since there were some interfering services running because of other ongoing experiments.</p><p>b) <strong>Creating batch scripts</strong> since aliases were missing in Windows and this is predominantly a Windows based platform</p><p>c) <strong>Docker-izing All the services</strong>. But the amount of RAM that was consumed when I ran all the services (except SQL Server and company-specific-services) was a bit more than I liked - speaks to my lack of knowledge in optimizing Docker, I'm sure.</p><p>d) I was also suggested a Prometheus dashboard that I summarily rejected because of the unnecessary level of complexity I was inviting for myself for a personal setup. (Although, I Will set something up with Prometheus eventually - just for masochism's sake.)</p><p>So after months of this sort of juggling, a few weeks ago, I thought - </p><div class="pullquote"><p><strong>FACT :</strong> I've enjoyed using <a href="https://textual.textualize.io/">Textual</a> for other projects. <br><strong>FACT :</strong> Many of these services can be polled for their status from their ports / Win processes.<br> <strong>INFERENCE :</strong> Why not write a Textual app combining these two facts?</p><p><strong>What is it?</strong> <a href="https://textual.textualize.io/">Textual </a>is a <em>Rapid Application Development</em> framework for Python, built by <strong>Will McGugan </strong>and the team at textualize.io. One can build sleek GUI applications Inside the terminal using Python.</p></div><h4>Actually let's back up - Iteration 2. </h4><p>I did <strong>not</strong> think of Textual right from the start. Because initially all I knew was, I wanted a dashboard that would monitor all the services I have running and I could look at for when something went down. </p><p>So the second iteration&#8217;s end result was something like this -</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!jEVt!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F720b80f1-42bb-4f33-a859-fb16610b9d97_988x172.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!jEVt!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F720b80f1-42bb-4f33-a859-fb16610b9d97_988x172.png 424w, https://substackcdn.com/image/fetch/$s_!jEVt!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F720b80f1-42bb-4f33-a859-fb16610b9d97_988x172.png 848w, https://substackcdn.com/image/fetch/$s_!jEVt!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F720b80f1-42bb-4f33-a859-fb16610b9d97_988x172.png 1272w, https://substackcdn.com/image/fetch/$s_!jEVt!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F720b80f1-42bb-4f33-a859-fb16610b9d97_988x172.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!jEVt!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F720b80f1-42bb-4f33-a859-fb16610b9d97_988x172.png" width="988" height="172" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/720b80f1-42bb-4f33-a859-fb16610b9d97_988x172.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:172,&quot;width&quot;:988,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:17399,&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://everythingpython.substack.com/i/163261457?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F720b80f1-42bb-4f33-a859-fb16610b9d97_988x172.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_!jEVt!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F720b80f1-42bb-4f33-a859-fb16610b9d97_988x172.png 424w, https://substackcdn.com/image/fetch/$s_!jEVt!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F720b80f1-42bb-4f33-a859-fb16610b9d97_988x172.png 848w, https://substackcdn.com/image/fetch/$s_!jEVt!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F720b80f1-42bb-4f33-a859-fb16610b9d97_988x172.png 1272w, https://substackcdn.com/image/fetch/$s_!jEVt!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F720b80f1-42bb-4f33-a859-fb16610b9d97_988x172.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><blockquote><p> <em><strong>Rejected coz</strong> :</em> Curling ports gave me machine-readable <strong>streaming</strong> truth, but looking at raw JSONs is still annoying.</p></blockquote><div><hr></div><h4> Iteration 3 - </h4><p>The improvement on the above was a CLI based table with ASCII &#10004; and &#10006; . <br>Like so -</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!viYR!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05974e76-55c9-48fc-ab07-275798c002ab_280x140.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!viYR!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05974e76-55c9-48fc-ab07-275798c002ab_280x140.png 424w, https://substackcdn.com/image/fetch/$s_!viYR!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05974e76-55c9-48fc-ab07-275798c002ab_280x140.png 848w, https://substackcdn.com/image/fetch/$s_!viYR!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05974e76-55c9-48fc-ab07-275798c002ab_280x140.png 1272w, https://substackcdn.com/image/fetch/$s_!viYR!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05974e76-55c9-48fc-ab07-275798c002ab_280x140.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!viYR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05974e76-55c9-48fc-ab07-275798c002ab_280x140.png" width="280" height="140" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/05974e76-55c9-48fc-ab07-275798c002ab_280x140.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:140,&quot;width&quot;:280,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:4361,&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://everythingpython.substack.com/i/163261457?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05974e76-55c9-48fc-ab07-275798c002ab_280x140.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_!viYR!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05974e76-55c9-48fc-ab07-275798c002ab_280x140.png 424w, https://substackcdn.com/image/fetch/$s_!viYR!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05974e76-55c9-48fc-ab07-275798c002ab_280x140.png 848w, https://substackcdn.com/image/fetch/$s_!viYR!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05974e76-55c9-48fc-ab07-275798c002ab_280x140.png 1272w, https://substackcdn.com/image/fetch/$s_!viYR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F05974e76-55c9-48fc-ab07-275798c002ab_280x140.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><blockquote><p><em><strong>Rejected coz</strong> :</em> A CLI table with &#10004;/&#10006; cut my scan-time, yet wasn&#8217;t appealing enough. It&#8217;s all about the looks now.</p></blockquote><div><hr></div><h4> Iteration 4 - </h4><p><strong>Here</strong> is where I thought of Textual. And I asked for a service monitoring dashboard which did not look as plain as the JSON response above nor the Ascii checks . The result was a little error-ridden but this is where <strong>Knowing</strong> programming <em>while</em> 'vibe-coding' helps. </p><p>The changes I had to make were around providing the right command to obtain the statuses of different services, modifying the ports, fixing the styles etc. </p><p>After the  manual fixes, which admittedly took lesser time than if I'd had to hand-code the whole script, the result was something 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_!Jyae!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe034b0b3-7c9e-414e-8348-6e0834b25a5b_438x386.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Jyae!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe034b0b3-7c9e-414e-8348-6e0834b25a5b_438x386.png 424w, https://substackcdn.com/image/fetch/$s_!Jyae!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe034b0b3-7c9e-414e-8348-6e0834b25a5b_438x386.png 848w, https://substackcdn.com/image/fetch/$s_!Jyae!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe034b0b3-7c9e-414e-8348-6e0834b25a5b_438x386.png 1272w, https://substackcdn.com/image/fetch/$s_!Jyae!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe034b0b3-7c9e-414e-8348-6e0834b25a5b_438x386.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Jyae!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe034b0b3-7c9e-414e-8348-6e0834b25a5b_438x386.png" width="438" height="386" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e034b0b3-7c9e-414e-8348-6e0834b25a5b_438x386.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:386,&quot;width&quot;:438,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:7129,&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://everythingpython.substack.com/i/163261457?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe034b0b3-7c9e-414e-8348-6e0834b25a5b_438x386.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_!Jyae!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe034b0b3-7c9e-414e-8348-6e0834b25a5b_438x386.png 424w, https://substackcdn.com/image/fetch/$s_!Jyae!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe034b0b3-7c9e-414e-8348-6e0834b25a5b_438x386.png 848w, https://substackcdn.com/image/fetch/$s_!Jyae!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe034b0b3-7c9e-414e-8348-6e0834b25a5b_438x386.png 1272w, https://substackcdn.com/image/fetch/$s_!Jyae!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe034b0b3-7c9e-414e-8348-6e0834b25a5b_438x386.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><blockquote><p><em><strong>NOT Rejected</strong> :</em> PROGRESS. Now for the final lap!</p></blockquote><div><hr></div><h4>Final set of iterations and the end result - </h4><p>From here on, it was mostly smooth sailing. </p><p>I got ChatGPT to fix the universal status symbols to be indicators of Success and Failure - green and red dots, tweak the borders etc. </p><p>There were again, obvious AI-slop-ish errors in the code, which again, was fixable trivially.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!KWB9!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F70ad0441-a052-4143-967a-f43050677383_1070x931.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!KWB9!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F70ad0441-a052-4143-967a-f43050677383_1070x931.png 424w, https://substackcdn.com/image/fetch/$s_!KWB9!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F70ad0441-a052-4143-967a-f43050677383_1070x931.png 848w, https://substackcdn.com/image/fetch/$s_!KWB9!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F70ad0441-a052-4143-967a-f43050677383_1070x931.png 1272w, https://substackcdn.com/image/fetch/$s_!KWB9!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F70ad0441-a052-4143-967a-f43050677383_1070x931.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!KWB9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F70ad0441-a052-4143-967a-f43050677383_1070x931.png" width="1070" height="931" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/70ad0441-a052-4143-967a-f43050677383_1070x931.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:931,&quot;width&quot;:1070,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:57786,&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://everythingpython.substack.com/i/163261457?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F70ad0441-a052-4143-967a-f43050677383_1070x931.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_!KWB9!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F70ad0441-a052-4143-967a-f43050677383_1070x931.png 424w, https://substackcdn.com/image/fetch/$s_!KWB9!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F70ad0441-a052-4143-967a-f43050677383_1070x931.png 848w, https://substackcdn.com/image/fetch/$s_!KWB9!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F70ad0441-a052-4143-967a-f43050677383_1070x931.png 1272w, https://substackcdn.com/image/fetch/$s_!KWB9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F70ad0441-a052-4143-967a-f43050677383_1070x931.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>All in all, the exercise took me less than an hour and I was very happy with it!</p><h4>Next steps </h4><p>- I'd like to make this an installer so that it can be easily installed without the dependency installation hassle. </p><p>- Want to implement an exponential retry and backoff when a service goes down</p><p>- ON/OFF controls for the services</p><div><hr></div><h4><strong>References :</strong> </h4><ul><li><p>ChatGippity (to hear Primeagen say it)</p></li><li><p> https://textual.textualize.io/</p></li><li><p>The Internet</p></li></ul><h4><strong>Codebase -</strong></h4><p>All the code for this project, if you&#8217;d like to set it up, can be found <a href="https://github.com/everythingpython/status-dash">here</a>.</p><div><hr></div><p><em>Thanks for reading Everything Python! Subscribe for free to receive new posts and support my work.</em></p><p><em><strong><a href="https://github.com/everythingpython/status-dash">PS - At the time of this article, we&#8217;d just hit 600 readers! Thank you for being one of them!!</a></strong></em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://everythingpython.substack.com/p/vibe-coding-a-status-dashboard?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://everythingpython.substack.com/p/vibe-coding-a-status-dashboard?utm_source=substack&utm_medium=email&utm_content=share&action=share"><span>Share</span></a></p>]]></content:encoded></item><item><title><![CDATA[Streaming Real-Time AI Inference Results into MongoDB]]></title><description><![CDATA[Hello Change Streams!]]></description><link>https://everythingpython.substack.com/p/streaming-real-time-ai-inference</link><guid isPermaLink="false">https://everythingpython.substack.com/p/streaming-real-time-ai-inference</guid><dc:creator><![CDATA[Abhiram]]></dc:creator><pubDate>Sat, 01 Mar 2025 02:32:34 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!mB92!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f7c362b-f5a5-44a3-bd5e-b1bd2c1c3c5d_1024x1024.webp" 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_!mB92!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f7c362b-f5a5-44a3-bd5e-b1bd2c1c3c5d_1024x1024.webp" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!mB92!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f7c362b-f5a5-44a3-bd5e-b1bd2c1c3c5d_1024x1024.webp 424w, https://substackcdn.com/image/fetch/$s_!mB92!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f7c362b-f5a5-44a3-bd5e-b1bd2c1c3c5d_1024x1024.webp 848w, https://substackcdn.com/image/fetch/$s_!mB92!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f7c362b-f5a5-44a3-bd5e-b1bd2c1c3c5d_1024x1024.webp 1272w, https://substackcdn.com/image/fetch/$s_!mB92!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f7c362b-f5a5-44a3-bd5e-b1bd2c1c3c5d_1024x1024.webp 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!mB92!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f7c362b-f5a5-44a3-bd5e-b1bd2c1c3c5d_1024x1024.webp" width="1024" height="1024" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7f7c362b-f5a5-44a3-bd5e-b1bd2c1c3c5d_1024x1024.webp&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;:289878,&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://everythingpython.substack.com/i/158145295?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f7c362b-f5a5-44a3-bd5e-b1bd2c1c3c5d_1024x1024.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_!mB92!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f7c362b-f5a5-44a3-bd5e-b1bd2c1c3c5d_1024x1024.webp 424w, https://substackcdn.com/image/fetch/$s_!mB92!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f7c362b-f5a5-44a3-bd5e-b1bd2c1c3c5d_1024x1024.webp 848w, https://substackcdn.com/image/fetch/$s_!mB92!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f7c362b-f5a5-44a3-bd5e-b1bd2c1c3c5d_1024x1024.webp 1272w, https://substackcdn.com/image/fetch/$s_!mB92!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f7c362b-f5a5-44a3-bd5e-b1bd2c1c3c5d_1024x1024.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>I'm going to be presenting a talk at a <a href="https://www.mongodb.com/community/events/form/t/311109">Mongo DB User group meetup</a> later today and I thought I'd write about it so that it would -</p><ul><li><p>serve as reading material for meetup attendees wanting to go through the content of my talk later</p></li><li><p>let everyone else know what this is all about.</p></li></ul><p>Let me pre-emptively say, I don't know why I chose this to be the "TITLE" of the talk. It is extremely dry. But the topic is actually a lot of fun!</p><p>Effectively, there is this concept called Change Streams in Mongo DB and this talk is an attempt to understand and illustrate its usage.</p><h2>So first off, what is Mongo DB and where is it used?</h2><p>MongoDB is a database that follows a document model to store data. This means that, in comparison to normal relational databases where data is stored using fixed schemas in rows and columns, Mongo DB and its other Document DB brethren store data in a more flexible format - in JSON-like documents.</p><p>Example of a dataset that can be stored in Mongo :</p><pre><code><code>{
  "_id" : ObjectId(),
  "title" : "Anna Karenina",
  "author" : "Leo Tolstoy",
  "content" : "It's a classic of world literature, exploring themes of love, loyalty, family, and social class in 19th-century Russia.",
  "tags" : [ "Russian" , "Serious" ],
  "publishedDate" : ISODate()
},
{
  "_id" : ObjectId(),
  "title" : "War and Peace",
  "author" : "Leo Tolstoy",
  "content" : "Set during the Napoleonic Wars and focusing on several aristocratic families in Russia.",
  "tags" : [ "Russian", "Serious" ],
  "publishedDate" : ISODate()
}</code></code></pre><p>MongoDB can be used where the data to be stored doesn't particularly benefit from being modelled into strict tables. It can be used when the data schema needs to be more flexible.</p><p>For example, the same data above could have potentially been stored in a Relational DB. But as the number of fields increases and as there end up being more and more complicated JOINS, the Relational DB model might suffer from slowdown.</p><div><hr></div><h2>What are <strong><a href="https://www.mongodb.com/resources/products/capabilities/change-streams#:~:text=A%20change%20stream%20is%20a%20real%2Dtime%20stream%2C%20flowing%20from%20your%20MongoDB%20database%20to%20your%20application%2C%20of%20all%20database%20changes.">Change Streams</a></strong>?</h2><p>This is a feature that has been around for a long time now. We're currently on Mongo DB 8.0.4 as of December 2024 but this feature was introduced in <strong>MongoDB 3.6</strong> in 2017.</p><blockquote><p><strong>It is used to let applications access real-time data changes in Mongo DB. Without having to keep polling for it.</strong></p></blockquote><p>Now other DBs also have this in some shape or form but they all vary in difficulty levels of configuration -</p><ul><li><p>Postgres apparently has support for a Debezium connector that can be used for Change Data Capture (CDC). Never tried it but I think I will after this!</p></li><li><p>Amazon's DocumentDB also has Change Streams but it might need additional configuration compared to Mongo DB.</p></li><li><p>Relational DBs can be configured to use Triggers or <a href="https://medium.com/mercedes-benz-techinnovation-blog/change-data-capture-lessons-learnt-7976391cf78d">Log based CDC</a> but it can impact performance or needs some non-trivial know-how.</p></li></ul><p>In that aspect Change Streams are very easy to configure.</p><p><strong>How do Change Streams work?</strong></p><ul><li><p>This whole mechanism hinges on the fact that Mongo DB relies on "op-log" or operations-log based replication. An op-log is basically a record of all operations performed on data in any collection/database in MongoDB.</p></li><li><p>What this means is that <strong>if</strong> Mongo DB is configured to use a replica set, any changes that are made to the DB are written to the op-log by the primary node. Secondary nodes read /tail the oplog and apply changes in the same order.</p></li><li><p>Change Streams can be used by using a "watch" method on a collection, a database or a whole cluster.</p></li><li><p>So now, whenever there's a certain operation-based change on the "system" under watch, the change stream captures it from the corresponding oplog entry.</p></li><li><p>The operations supported are : insert, update, delete, replace , invalidate</p></li></ul><div><hr></div><h2>How can I enable Change Streams?</h2><blockquote><p>This post assumes you have a working MongoDb setup - I'll write a separate post for this.</p></blockquote><ul><li><p>Go to the Mongo Shell and execute <code>rs.status()</code></p></li></ul><p>If there's a replica set configuration like so -</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!VI9U!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65081e2c-d183-470a-ad43-1e3349d182b1_1087x574.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!VI9U!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65081e2c-d183-470a-ad43-1e3349d182b1_1087x574.png 424w, https://substackcdn.com/image/fetch/$s_!VI9U!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65081e2c-d183-470a-ad43-1e3349d182b1_1087x574.png 848w, https://substackcdn.com/image/fetch/$s_!VI9U!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65081e2c-d183-470a-ad43-1e3349d182b1_1087x574.png 1272w, https://substackcdn.com/image/fetch/$s_!VI9U!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65081e2c-d183-470a-ad43-1e3349d182b1_1087x574.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!VI9U!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65081e2c-d183-470a-ad43-1e3349d182b1_1087x574.png" width="1087" height="574" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/65081e2c-d183-470a-ad43-1e3349d182b1_1087x574.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:574,&quot;width&quot;:1087,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Alt Text&quot;,&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="Alt Text" title="Alt Text" srcset="https://substackcdn.com/image/fetch/$s_!VI9U!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65081e2c-d183-470a-ad43-1e3349d182b1_1087x574.png 424w, https://substackcdn.com/image/fetch/$s_!VI9U!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65081e2c-d183-470a-ad43-1e3349d182b1_1087x574.png 848w, https://substackcdn.com/image/fetch/$s_!VI9U!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65081e2c-d183-470a-ad43-1e3349d182b1_1087x574.png 1272w, https://substackcdn.com/image/fetch/$s_!VI9U!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F65081e2c-d183-470a-ad43-1e3349d182b1_1087x574.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're all good. If not, you need to do the following :</p><ul><li><p>Stop the mongo service - Either from Task Manager if you're on Windows. Or using <code>sudo systemctl stop mongod</code> if on Linux.</p></li><li><p>Find the mongod.cfg (Windows) or mongod.conf (Linux) file and add the following line</p></li></ul><pre><code><code>replication:
&#9;  replSetName: "&lt;Whatever name you want&gt;"
</code></code></pre><p>So it looks like -</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!5Kh7!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97bec62e-349c-48df-85bc-fa2f8f2d1655_529x101.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!5Kh7!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97bec62e-349c-48df-85bc-fa2f8f2d1655_529x101.png 424w, https://substackcdn.com/image/fetch/$s_!5Kh7!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97bec62e-349c-48df-85bc-fa2f8f2d1655_529x101.png 848w, https://substackcdn.com/image/fetch/$s_!5Kh7!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97bec62e-349c-48df-85bc-fa2f8f2d1655_529x101.png 1272w, https://substackcdn.com/image/fetch/$s_!5Kh7!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97bec62e-349c-48df-85bc-fa2f8f2d1655_529x101.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!5Kh7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97bec62e-349c-48df-85bc-fa2f8f2d1655_529x101.png" width="529" height="101" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/97bec62e-349c-48df-85bc-fa2f8f2d1655_529x101.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:101,&quot;width&quot;:529,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Alt Text&quot;,&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="Alt Text" title="Alt Text" srcset="https://substackcdn.com/image/fetch/$s_!5Kh7!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97bec62e-349c-48df-85bc-fa2f8f2d1655_529x101.png 424w, https://substackcdn.com/image/fetch/$s_!5Kh7!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97bec62e-349c-48df-85bc-fa2f8f2d1655_529x101.png 848w, https://substackcdn.com/image/fetch/$s_!5Kh7!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97bec62e-349c-48df-85bc-fa2f8f2d1655_529x101.png 1272w, https://substackcdn.com/image/fetch/$s_!5Kh7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97bec62e-349c-48df-85bc-fa2f8f2d1655_529x101.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><ul><li><p>Restart the Mongo service.</p></li><li><p>Reopen the Mongo shell and run <code>rs.initiate()</code></p></li></ul><p>Boom! Change Streams are now enabled!</p><div><hr></div><h2>Great. Now how do I use them?</h2><p>I thought about this a lot as well. My initial thought was to mimic the functioning of an oxymeter in a hospital that keeps reporting the oxygen level of a patient.</p><p>But I thought I'd keep it a little lighter.</p><p>So, my simulated use case is one of segregating News Items into 1 of 4 categories as they keep getting pulled from News Sources.</p><p><strong>Here's a broad architecture diagram -</strong></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!mdT_!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0155fb15-0abb-4d2c-a95f-5641de10ebc6_1694x503.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!mdT_!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0155fb15-0abb-4d2c-a95f-5641de10ebc6_1694x503.png 424w, https://substackcdn.com/image/fetch/$s_!mdT_!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0155fb15-0abb-4d2c-a95f-5641de10ebc6_1694x503.png 848w, https://substackcdn.com/image/fetch/$s_!mdT_!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0155fb15-0abb-4d2c-a95f-5641de10ebc6_1694x503.png 1272w, https://substackcdn.com/image/fetch/$s_!mdT_!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0155fb15-0abb-4d2c-a95f-5641de10ebc6_1694x503.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!mdT_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0155fb15-0abb-4d2c-a95f-5641de10ebc6_1694x503.png" width="1456" height="432" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0155fb15-0abb-4d2c-a95f-5641de10ebc6_1694x503.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:432,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Alt Text&quot;,&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="Alt Text" title="Alt Text" srcset="https://substackcdn.com/image/fetch/$s_!mdT_!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0155fb15-0abb-4d2c-a95f-5641de10ebc6_1694x503.png 424w, https://substackcdn.com/image/fetch/$s_!mdT_!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0155fb15-0abb-4d2c-a95f-5641de10ebc6_1694x503.png 848w, https://substackcdn.com/image/fetch/$s_!mdT_!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0155fb15-0abb-4d2c-a95f-5641de10ebc6_1694x503.png 1272w, https://substackcdn.com/image/fetch/$s_!mdT_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0155fb15-0abb-4d2c-a95f-5641de10ebc6_1694x503.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>Let's consider this piece by piece :</p><h3>News Generator :</h3><ul><li><p>Here we have 5 "news sources", producing news items every, say 10 seconds.</p></li><li><p>The item , which here is a string is sent to an Azure OpenAI LLM instance with a prompt designed to return the "Category" of News it belongs to. We have a preset expectation of news items to fall under 5 categories : "Sports", "Politics", "Entertainment", "Tech", "Misc". </p><blockquote><p>You don&#8217;t have to use Azure OpenAI. You can use any model you have access to!</p></blockquote></li><li><p>I'm using gpt-4o for this example but it's such a trivial activity that most older or any Small Local Model should also suffice for this task.</p></li><li><p>What is not shown in the diagram is that I'm using <a href="https://github.com/comet-ml/opik">Opik</a> (launched locally) to track my LLM calls.</p></li><li><p>Now as soon as this categorization is obtained, the data is pushed into a collection called "articles" under a DB called "newsDB".</p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!x9Yp!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e6a3219-2886-4629-96ff-15eb22213e7e_1361x631.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!x9Yp!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e6a3219-2886-4629-96ff-15eb22213e7e_1361x631.png 424w, https://substackcdn.com/image/fetch/$s_!x9Yp!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e6a3219-2886-4629-96ff-15eb22213e7e_1361x631.png 848w, https://substackcdn.com/image/fetch/$s_!x9Yp!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e6a3219-2886-4629-96ff-15eb22213e7e_1361x631.png 1272w, https://substackcdn.com/image/fetch/$s_!x9Yp!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e6a3219-2886-4629-96ff-15eb22213e7e_1361x631.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!x9Yp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e6a3219-2886-4629-96ff-15eb22213e7e_1361x631.png" width="1361" height="631" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5e6a3219-2886-4629-96ff-15eb22213e7e_1361x631.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:631,&quot;width&quot;:1361,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Alt Text&quot;,&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="Alt Text" title="Alt Text" srcset="https://substackcdn.com/image/fetch/$s_!x9Yp!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e6a3219-2886-4629-96ff-15eb22213e7e_1361x631.png 424w, https://substackcdn.com/image/fetch/$s_!x9Yp!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e6a3219-2886-4629-96ff-15eb22213e7e_1361x631.png 848w, https://substackcdn.com/image/fetch/$s_!x9Yp!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e6a3219-2886-4629-96ff-15eb22213e7e_1361x631.png 1272w, https://substackcdn.com/image/fetch/$s_!x9Yp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e6a3219-2886-4629-96ff-15eb22213e7e_1361x631.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>The Flask App</h3><ul><li><p>This doesn't necessarily have to be a Flask app. Pick your web server of choice - FastAPI, Django, Bottle, whatever you want. But yes, in this example, it is a flask app.</p></li><li><p>Here, I do a few things : </p><ul><li><p> Make sure the Mongo DB is connected to on port 27017 (default) and that the UI reflects the number of pre-existing records for each category in the DB. For a fresh start, that number is 0 for all categories. </p></li><li><p> Set up a <code>collection.watch()</code> on the <code>articles</code> collection so that the change stream can be captured. </p></li><li><p>Start the flask server using websockets (via flask-socketio) so that a steady, bidirectional connection is established between server and client. This way, the browser is always watching for any changes that the DB is ready to communicate back without needing a refresh of the screen.</p></li></ul></li></ul><h3>The Client/ UI/ Browser</h3><ul><li><p>If the server is started on say, port 5002, I navigate to http://localhost:5002</p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!hPn9!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3dc7853b-4ca9-446e-88cc-36d3469964d2_1920x1080.gif" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!hPn9!,w_424,c_limit,f_webp,q_auto:good,fl_lossy/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3dc7853b-4ca9-446e-88cc-36d3469964d2_1920x1080.gif 424w, https://substackcdn.com/image/fetch/$s_!hPn9!,w_848,c_limit,f_webp,q_auto:good,fl_lossy/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3dc7853b-4ca9-446e-88cc-36d3469964d2_1920x1080.gif 848w, https://substackcdn.com/image/fetch/$s_!hPn9!,w_1272,c_limit,f_webp,q_auto:good,fl_lossy/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3dc7853b-4ca9-446e-88cc-36d3469964d2_1920x1080.gif 1272w, https://substackcdn.com/image/fetch/$s_!hPn9!,w_1456,c_limit,f_webp,q_auto:good,fl_lossy/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3dc7853b-4ca9-446e-88cc-36d3469964d2_1920x1080.gif 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!hPn9!,w_1456,c_limit,f_auto,q_auto:good,fl_lossy/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3dc7853b-4ca9-446e-88cc-36d3469964d2_1920x1080.gif" width="1456" height="819" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3dc7853b-4ca9-446e-88cc-36d3469964d2_1920x1080.gif&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:819,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Alt Text&quot;,&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="Alt Text" title="Alt Text" srcset="https://substackcdn.com/image/fetch/$s_!hPn9!,w_424,c_limit,f_auto,q_auto:good,fl_lossy/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3dc7853b-4ca9-446e-88cc-36d3469964d2_1920x1080.gif 424w, https://substackcdn.com/image/fetch/$s_!hPn9!,w_848,c_limit,f_auto,q_auto:good,fl_lossy/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3dc7853b-4ca9-446e-88cc-36d3469964d2_1920x1080.gif 848w, https://substackcdn.com/image/fetch/$s_!hPn9!,w_1272,c_limit,f_auto,q_auto:good,fl_lossy/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3dc7853b-4ca9-446e-88cc-36d3469964d2_1920x1080.gif 1272w, https://substackcdn.com/image/fetch/$s_!hPn9!,w_1456,c_limit,f_auto,q_auto:good,fl_lossy/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3dc7853b-4ca9-446e-88cc-36d3469964d2_1920x1080.gif 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 changes automatically every 20 seconds (since that&#8217;s what I&#8217;ve configured underneath. You can set your own value.)</p><p>Because of Change Streams, with each article being produced and categorized, the DB&#8217;s state is Almost Immediately informed to the application. </p><p>This is something we'd have had to poll the DB regularly for, if this feature weren't there. And because we use websockets, the updated state of the DB can directly go from server to client I.e UI/the browser as well. </p><p>Now, are there any disadvantages to using Change streams? Absolutely. Since the op log is continuously, automatically being watched and tailed, there is a bit of a compute impact. But if the application demands near-realtime updates, that additional compute is the price to pay for the feature! </p><p>Hopefully this gave you an idea of how Change Streams can be used!</p><div><hr></div><h3>Codebase -</h3><p>All the code for this project can be found <a href="https://github.com/everythingpython/everythingpython.github.io/tree/main/_notes/Public/Talks/MongoDB/real-time-inference-change-streams/src/NewsMon">here</a>.</p><p></p><div><hr></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://everythingpython.substack.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"><em>Thanks for reading Everything Python! Subscribe for free to receive new posts and support my work.</em></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[I want to run LLM Models locally. What do I do?]]></title><description><![CDATA[One of the most sought after things to learn right now is about how to set up your own local LLM server and how to use LLM models locally.]]></description><link>https://everythingpython.substack.com/p/i-want-to-run-llm-models-locally</link><guid isPermaLink="false">https://everythingpython.substack.com/p/i-want-to-run-llm-models-locally</guid><dc:creator><![CDATA[Abhiram]]></dc:creator><pubDate>Mon, 06 Jan 2025 08:55:22 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F04b8ebf6-a585-44a0-b365-1b0b0e822739_1280x1280.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>One of the most sought after things to learn right now is about how to set up your own local LLM server and how to use LLM models locally. With the arrival of some things like Ollama and LM Studio etc, it has become very easy. Ollama is an orchestrator that lets you serve up models locally, models like Llama 3.1, Qwen-2.5, Phi, whatever models you have on HuggingFace. These are available to be served up and many more.</p><h3>Why would I want to do this?</h3><p>Fair question to ask in the face of so many ubiquitous LLM offerings present like ChatGPT, Claude, Gemini etc. Why do I even want to set up an LLM locally? I asked ChatGPT this and it told me a lot of what I was thinking along the lines of - like privacy, to prevent reliance on possibly unreliable internet and it kept going for a while, so I asked it to -</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!PJlo!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a10de64-64a5-4327-980b-d50e89b10fd0_1061x315.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!PJlo!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a10de64-64a5-4327-980b-d50e89b10fd0_1061x315.png 424w, https://substackcdn.com/image/fetch/$s_!PJlo!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a10de64-64a5-4327-980b-d50e89b10fd0_1061x315.png 848w, https://substackcdn.com/image/fetch/$s_!PJlo!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a10de64-64a5-4327-980b-d50e89b10fd0_1061x315.png 1272w, https://substackcdn.com/image/fetch/$s_!PJlo!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a10de64-64a5-4327-980b-d50e89b10fd0_1061x315.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!PJlo!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a10de64-64a5-4327-980b-d50e89b10fd0_1061x315.png" width="1061" height="315" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2a10de64-64a5-4327-980b-d50e89b10fd0_1061x315.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:315,&quot;width&quot;:1061,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;image&quot;,&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="image" title="image" srcset="https://substackcdn.com/image/fetch/$s_!PJlo!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a10de64-64a5-4327-980b-d50e89b10fd0_1061x315.png 424w, https://substackcdn.com/image/fetch/$s_!PJlo!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a10de64-64a5-4327-980b-d50e89b10fd0_1061x315.png 848w, https://substackcdn.com/image/fetch/$s_!PJlo!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a10de64-64a5-4327-980b-d50e89b10fd0_1061x315.png 1272w, https://substackcdn.com/image/fetch/$s_!PJlo!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2a10de64-64a5-4327-980b-d50e89b10fd0_1061x315.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><hr></div><h3>Setting up Ollama -</h3><ul><li><p>Depending on your operating system, download the corresponding Ollama executable from the official <a href="https://ollama.com/download">website</a>.</p></li><li><p>Once you download and run it, it should be running as a small service in the background of your operating system. For example, if you're on Windows, you should be able to see it running on the tray on your screen's bottom right corner.</p><p>If you&#8217;re on a Mac, it should show up on your Menu bar like so - </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!LemJ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e398e5c-da38-4d6e-ba98-c92a0086e0c8_932x388.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!LemJ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e398e5c-da38-4d6e-ba98-c92a0086e0c8_932x388.png 424w, https://substackcdn.com/image/fetch/$s_!LemJ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e398e5c-da38-4d6e-ba98-c92a0086e0c8_932x388.png 848w, https://substackcdn.com/image/fetch/$s_!LemJ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e398e5c-da38-4d6e-ba98-c92a0086e0c8_932x388.png 1272w, https://substackcdn.com/image/fetch/$s_!LemJ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e398e5c-da38-4d6e-ba98-c92a0086e0c8_932x388.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!LemJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e398e5c-da38-4d6e-ba98-c92a0086e0c8_932x388.png" width="932" height="388" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5e398e5c-da38-4d6e-ba98-c92a0086e0c8_932x388.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:388,&quot;width&quot;:932,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:46718,&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://everythingpython.substack.com/i/154254870?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e398e5c-da38-4d6e-ba98-c92a0086e0c8_932x388.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_!LemJ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e398e5c-da38-4d6e-ba98-c92a0086e0c8_932x388.png 424w, https://substackcdn.com/image/fetch/$s_!LemJ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e398e5c-da38-4d6e-ba98-c92a0086e0c8_932x388.png 848w, https://substackcdn.com/image/fetch/$s_!LemJ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e398e5c-da38-4d6e-ba98-c92a0086e0c8_932x388.png 1272w, https://substackcdn.com/image/fetch/$s_!LemJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e398e5c-da38-4d6e-ba98-c92a0086e0c8_932x388.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><ul><li><p>To test that it&#8217;s working, open up a CMD or a Terminal instance and type : </p><ul><li><p><code>ollama -h</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_!FEri!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4bca9fd9-c6fb-4211-98b3-afe35a01e056_863x672.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!FEri!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4bca9fd9-c6fb-4211-98b3-afe35a01e056_863x672.png 424w, https://substackcdn.com/image/fetch/$s_!FEri!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4bca9fd9-c6fb-4211-98b3-afe35a01e056_863x672.png 848w, https://substackcdn.com/image/fetch/$s_!FEri!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4bca9fd9-c6fb-4211-98b3-afe35a01e056_863x672.png 1272w, https://substackcdn.com/image/fetch/$s_!FEri!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4bca9fd9-c6fb-4211-98b3-afe35a01e056_863x672.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!FEri!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4bca9fd9-c6fb-4211-98b3-afe35a01e056_863x672.png" width="863" height="672" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4bca9fd9-c6fb-4211-98b3-afe35a01e056_863x672.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:672,&quot;width&quot;:863,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:66598,&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://everythingpython.substack.com/i/154254870?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4bca9fd9-c6fb-4211-98b3-afe35a01e056_863x672.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_!FEri!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4bca9fd9-c6fb-4211-98b3-afe35a01e056_863x672.png 424w, https://substackcdn.com/image/fetch/$s_!FEri!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4bca9fd9-c6fb-4211-98b3-afe35a01e056_863x672.png 848w, https://substackcdn.com/image/fetch/$s_!FEri!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4bca9fd9-c6fb-4211-98b3-afe35a01e056_863x672.png 1272w, https://substackcdn.com/image/fetch/$s_!FEri!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4bca9fd9-c6fb-4211-98b3-afe35a01e056_863x672.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></li></ul></li></ul></li><li><p>To download any existing models, fetch them from the <a href="https://ollama.com/search">Ollama Models page</a> and pull them locally using <code>ollama run</code></p></li><li><p>For example, I want to run one of the latest models - olmo2</p><div class="native-video-embed" data-component-name="VideoPlaceholder" data-attrs="{&quot;mediaUploadId&quot;:&quot;463fa592-fd91-4591-b5e9-4cbcba245bbb&quot;,&quot;duration&quot;:null}"></div><p>Once that model is pulled, the prompt looks a little 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_!nPZh!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc3745523-5b41-4ffa-9830-e577b2a88caa_775x300.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!nPZh!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc3745523-5b41-4ffa-9830-e577b2a88caa_775x300.png 424w, https://substackcdn.com/image/fetch/$s_!nPZh!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc3745523-5b41-4ffa-9830-e577b2a88caa_775x300.png 848w, https://substackcdn.com/image/fetch/$s_!nPZh!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc3745523-5b41-4ffa-9830-e577b2a88caa_775x300.png 1272w, https://substackcdn.com/image/fetch/$s_!nPZh!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc3745523-5b41-4ffa-9830-e577b2a88caa_775x300.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!nPZh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc3745523-5b41-4ffa-9830-e577b2a88caa_775x300.png" width="775" height="300" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c3745523-5b41-4ffa-9830-e577b2a88caa_775x300.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:300,&quot;width&quot;:775,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:11800,&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://everythingpython.substack.com/i/154254870?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc3745523-5b41-4ffa-9830-e577b2a88caa_775x300.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_!nPZh!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc3745523-5b41-4ffa-9830-e577b2a88caa_775x300.png 424w, https://substackcdn.com/image/fetch/$s_!nPZh!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc3745523-5b41-4ffa-9830-e577b2a88caa_775x300.png 848w, https://substackcdn.com/image/fetch/$s_!nPZh!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc3745523-5b41-4ffa-9830-e577b2a88caa_775x300.png 1272w, https://substackcdn.com/image/fetch/$s_!nPZh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc3745523-5b41-4ffa-9830-e577b2a88caa_775x300.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></p></li><li><p>Smaller models are better for lower config laptops/desktops.</p></li></ul><p></p><div><hr></div><blockquote><p>This section is optional. </p></blockquote><p>The next thing to do to mimic a local Chat-GPT-ish experience is to hook this backend Ollama server to a front-end web interface. This is where <a href="https://openwebui.com/">https://openwebui.com/</a> comes in.</p><div><hr></div><h3>Setting up OpenWebUI -</h3><p>The Github README for OpenWebUI is extremely helpful. A few months ago when I tried it out, they only had the Docker based offering but now it seems that all that is to be done to set it up is -</p><ul><li><p><a href="https://everythingpython.substack.com/p/virtual-environments-using-uv">Create and activate a virtual environment</a></p></li><li><p><code>uv pip install open-webui</code></p></li><li><p><code>open-webui serve</code></p></li></ul><p>So when you visit localhost:8000 on your browser you should be able to see a chatgpt-ish interface and the list of models you downloaded on Ollama on a top-left corner dropdown.</p><div><hr></div><h3>Performance</h3><ul><li><p>"How fast is it?", a friend asked. It's not going to be comparable to OpenAI/Claude/Gemini server speeds given that it is limited by your local laptop's CPU/GPU. But on a Mac M1 or a Windows i5 with 32 GB RAM, it's able to run and engage in processing and conversations at fairly decent, tolerable speeds.</p></li></ul><p></p><div><hr></div><h3>What are my other options?</h3><p>There's a couple of other options like LMStudio and Msty, but those are "left as an exercise to the reader" to try out. :D</p><p>Happy local chatting!</p><div><hr></div><p>If you found this useful, please share it with your friends and ask them to subscribe to EverythingPython as well!</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://everythingpython.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://everythingpython.substack.com/subscribe?"><span>Subscribe now</span></a></p><p></p>]]></content:encoded></item></channel></rss>