<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: AME - English for Tech People</title>
    <description>The latest articles on DEV Community by AME - English for Tech People (@allmightenglishtech).</description>
    <link>https://dev.to/allmightenglishtech</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Forganization%2Fprofile_image%2F9501%2F771fa44a-8530-4cfa-8cd5-2202b7deffee.png</url>
      <title>DEV Community: AME - English for Tech People</title>
      <link>https://dev.to/allmightenglishtech</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/allmightenglishtech"/>
    <language>en</language>
    <item>
      <title>What I learned while putting together my IDP (Individual Development Plan)</title>
      <dc:creator>Karina Pereira</dc:creator>
      <pubDate>Thu, 18 Dec 2025 10:38:04 +0000</pubDate>
      <link>https://dev.to/allmightenglishtech/what-i-learned-while-putting-together-my-idp-individual-development-plan-3i2o</link>
      <guid>https://dev.to/allmightenglishtech/what-i-learned-while-putting-together-my-idp-individual-development-plan-3i2o</guid>
      <description>&lt;p&gt;When I saw for the first time the acronym IDP (Individual Development Plan), I didn’t know what it was or how to create one. In the talk with my Tech Leader, we agreed that a topic could involve areas for improvement that I myself identified. However, Looking at my list of knowledge that I wanted to develop, I felt lost where to start and which area I should focus on first.&lt;/p&gt;

&lt;h2&gt;
  
  
  Definition
&lt;/h2&gt;

&lt;p&gt;Based on these reflection, I defined my initial objectives:&lt;/p&gt;

&lt;p&gt;1 - To improve my technical skills&lt;/p&gt;

&lt;p&gt;2 - To document the entire project in English&lt;/p&gt;

&lt;p&gt;Defining the subject wasn’t simple, because I tried not only considering my development, but how the IDP could add value to the company. It would be something useful, something I could apply in my daily life, and something that would help me making more informed architectural decisions in the future.&lt;/p&gt;

&lt;p&gt;I thought: working as Full-Stack is impossible to know everything, but dominating principles of architecture makes all the difference, independently of the technology stack used.&lt;/p&gt;

&lt;p&gt;So, I chose to study and apply SOLID (Single Responsibility, Open–Closed, Liskov Substitution, Interface Segregation, and Dependency Inversion principles) in practice.&lt;/p&gt;

&lt;p&gt;Based on these motivations I identified one more objective:&lt;/p&gt;

&lt;p&gt;3 - To be a developer capable of applying best practices from the idealization step of a project.&lt;/p&gt;

&lt;p&gt;My main motivation for choosing this subject came from my own experience. Many projects that I worked, I didn't have a mentor and learned by making mistakes, delivering the best I could in the shortest time possible.&lt;/p&gt;

&lt;p&gt;Understanding SOLID better, would help me developing more organized and scalable systems, this directly impacts the quality of my work.&lt;/p&gt;

&lt;h2&gt;
  
  
  Planning
&lt;/h2&gt;

&lt;p&gt;I organized a list of stacks and practices that I would love to apply:&lt;/p&gt;

&lt;p&gt;1 - Laravel, using Eloquent, which is already part of my routine. To focus only on the concept and architecture rather than reinventing already established functionalities.&lt;br&gt;
2 - Vue.js with Composition API &lt;br&gt;
3 - ESLint and Prettier, ensuring that the code follows the standards without triggering errors in the IDE extensions.&lt;br&gt;
4 - I was unsure whether to use Service Layer or Repository Pattern, I chose Service Layer, better explained in the details below.&lt;/p&gt;

&lt;p&gt;Not everything I defined at the beginning was delivered, such as authentication, CORS (Cross-Origin Resource Sharing), deployment, and git hooks. I plan to do this level of implementation at another time. I focused only on best practices and architecture.&lt;/p&gt;

&lt;p&gt;With that, I had the subject of the project: A map of urban legends, where I apply best practices, refine my skills in Laravel and Vue.js, and learn more about SOLID principles.&lt;/p&gt;
&lt;h2&gt;
  
  
  Practice
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Why the Composition API?
&lt;/h3&gt;

&lt;p&gt;I started with Vue.js using the Options API, but in some projects, I realized that the complexity grew along with the file size. I started working with the Composition API on ongoing projects and really enjoyed the experience, as it facilitates reusage and organization.&lt;/p&gt;

&lt;p&gt;Applying SOLID principles to the front-end isn't so obvious, but I focused on separating responsibilities and making the code reusable.&lt;/p&gt;
&lt;h3&gt;
  
  
  I understood that the components should only handle UI
&lt;/h3&gt;

&lt;p&gt;I created a &lt;code&gt;src/api/&lt;/code&gt; folder containing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;connect.js&lt;/code&gt; → responsible for configuring the connection to the API&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;legend.js&lt;/code&gt; → responsible for querying the API endpoints&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each file has a single responsibility.&lt;/p&gt;

&lt;p&gt;The components do not depend on Axios, but only on the functions implemented inside &lt;code&gt;legend.js&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For example, if I replace Axios for GraphQL, nothing in the component needs to be changed.&lt;/p&gt;

&lt;p&gt;With this structure, the &lt;code&gt;UrbanLegendMap.vue&lt;/code&gt; component only needs to handle UI (Leaflet), only consumes domain functions, and does not load HTTP logic inside of it.&lt;/p&gt;
&lt;h3&gt;
  
  
  Why the Service Layer?
&lt;/h3&gt;

&lt;p&gt;In projects, it's very difficult to change the ORM, so implementing the Repository Pattern would only add an unnecessary layer and reproduce old habits. I understood that Repositories would perform a role that Eloquent already does. There would be no gain.&lt;/p&gt;

&lt;p&gt;Therefore, the Service Layer makes business decisions, handles approaches, and deals with any reusable logic, becoming responsible for the business rules.&lt;/p&gt;
&lt;h3&gt;
  
  
  I understood that each class only needs one reason to be changed
&lt;/h3&gt;

&lt;p&gt;The controller of the project was only responsible for receiving the request, calling the service interface, and returning an HTTP response, for example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kr"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;store&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;StoreUrbanLegendRequest&lt;/span&gt; &lt;span class="nx"&gt;$request&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;$legend&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;service&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;$request&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;validated&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
    &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;UrbanLegendResource&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;$legend&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;response&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;setStatusCode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nx"&gt;HTTP_CREATED&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No validation logic or business rules should exist in the Controller.&lt;/p&gt;

&lt;p&gt;Inside the project, each time a new legend is created, a slug is generated to be accessed via URL.&lt;/p&gt;

&lt;p&gt;This responsibility was assigned to the Model.&lt;/p&gt;

&lt;p&gt;Therefore:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Validations are handled by Form Requests.&lt;/li&gt;
&lt;li&gt;Business rules are handled by the Service.&lt;/li&gt;
&lt;li&gt;Slug generation, UUIDs, and relationships are handled by the Model.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This kept each part of the system with well-defined responsibilities.&lt;/p&gt;

&lt;h3&gt;
  
  
  I understood that a structure doesn't need to be altered, but it should always be open for extension.
&lt;/h3&gt;

&lt;p&gt;The controller only knows the service's interface, it doesn't depend on the service's implementation. If it's necessary to migrate the service's implementation to an external API, for example, then you just need to create another service that implements the same interface.&lt;/p&gt;

&lt;p&gt;Nothing in the controller needs to change, and the service and controller depend on the same logical interface.&lt;/p&gt;

&lt;h3&gt;
  
  
  I understood that testing features can be beneficial
&lt;/h3&gt;

&lt;p&gt;I usually only test the service or use the case of the application, but since I was dealing with a very well-structured project, I opted to create tests in two ways: feature tests and unit tests.&lt;/p&gt;

&lt;p&gt;With feature tests, I can test the complete flow: route + middleware + request + service + model + resource, for example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kr"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;test_validates_required_fields_and_returns_422&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;User&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;factory&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

        &lt;span class="nx"&gt;$res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;withHeaders&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
            &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Authorization&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Bearer &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="nx"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;postJson&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/api/legend&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
            &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;title&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
        &lt;span class="p"&gt;]));&lt;/span&gt;

        &lt;span class="nx"&gt;$res&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;assertStatus&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;422&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;assertJsonValidationErrors&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;title&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This doesn't mean I'll always test features, but since my front-end depends exclusively on the external API, I thought it was important to have this test to verify if the response was in accordance with HTTP principles, and it also helped me writing the documentation.&lt;/p&gt;

&lt;p&gt;Unit tests validated the business rule in isolation, for example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kr"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;test_list_returns_filtered_legends&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;service&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
        &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;title&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Lenda - Brasília&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;city&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;  &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Brasília&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;]));&lt;/span&gt;

    &lt;span class="nx"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;service&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
        &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;title&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Lenda - Florianópolis&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;city&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;  &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Florianópolis&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;]));&lt;/span&gt;

    &lt;span class="nx"&gt;$results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;service&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;list&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;city&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Brasília&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;

    &lt;span class="nx"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;assertCount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;$results&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;assertEquals&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Brasília&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;$results&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;first&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;city&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  I understood that this IDP changed my way of thinking
&lt;/h3&gt;

&lt;p&gt;Throughout this IDP, my first and main objective was to improve my technical knowledge. I sought to understand each step and each implementation and to understand the reasoning behind each line. I consulted many articles to understand not only the theory but also to have practical examples.&lt;/p&gt;

&lt;p&gt;By creating a project applying SOLID principles in practice, I understood that each architectural decision impacts the rest of the system. It's much better to have code that does what it's supposed to with an easily maintainable architecture.&lt;/p&gt;

&lt;p&gt;This study wasn't just technical; it also changed my way of thinking. Currently, before writing code, I reflect on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Who is responsible for this?&lt;/li&gt;
&lt;li&gt;Does this class have a single reason to change?&lt;/li&gt;
&lt;li&gt;Are there any unnecessary methods or functions?&lt;/li&gt;
&lt;li&gt;Can it be extended without breaking?&lt;/li&gt;
&lt;li&gt;Will I have a headache if I need to perform maintenance?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These questions have become part of my daily routine. That's exactly what I was looking for when I chose SOLID as my main topic: to learn something that wasn't just applicable to the IDP, but that could accompany my professional life from now on.&lt;/p&gt;

&lt;p&gt;Although not all planned items were completed (authentication), I consider the IDP successful. The process brought me technical maturity and a much more solid understanding of how to structure a project, from idealization onwards, because I didn't just learn a technology, but I learned to think about architecture intentionally.&lt;/p&gt;

&lt;h2&gt;
  
  
  I learned that good practices don't depend on the stack, but on conscious decisions
&lt;/h2&gt;

&lt;p&gt;And this evolution doesn't end here.&lt;/p&gt;

&lt;p&gt;Link of project: &lt;a href="https://github.com/kapcruz/urbanlegendmaps" rel="noopener noreferrer"&gt;https://github.com/kapcruz/urbanlegendmaps&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Referencies:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/danielhe4rt/SOLID4Noobs" rel="noopener noreferrer"&gt;SOLID4Noobs&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/desenvolvendo-com-paixao/o-que-%C3%A9-solid-o-guia-completo-para-voc%C3%AA-entender-os-5-princ%C3%ADpios-da-poo-2b937b3fc530" rel="noopener noreferrer"&gt;O que é SOLID: O guia completo para você entender os 5 princípios da POO&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/@sliusarchyn/service-layer-in-laravel-use-it-ae861fb0f124" rel="noopener noreferrer"&gt;Service Layer in Laravel — use it!&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gist.github.com/azagniotov/a4b16faf0febd12efbc6c3d7370383a6" rel="noopener noreferrer"&gt;Create beautiful REST API docs authored in Markdown&lt;/a&gt;&lt;/p&gt;

</description>
      <category>career</category>
      <category>devjournal</category>
      <category>learning</category>
    </item>
    <item>
      <title>From Front-end to Back-end: Understanding Databases Step</title>
      <dc:creator>Larissa Dantier</dc:creator>
      <pubDate>Fri, 21 Feb 2025 11:30:00 +0000</pubDate>
      <link>https://dev.to/allmightenglishtech/starting-my-back-end-journey-2-14gg</link>
      <guid>https://dev.to/allmightenglishtech/starting-my-back-end-journey-2-14gg</guid>
      <description>&lt;p&gt;Hello everyone! I'm here again for continue with an articles :), it's been a while since the last post, I ended up getting a bit busy but we came back. Let's go talk about &lt;strong&gt;&lt;code&gt;Databases&lt;/code&gt;&lt;/strong&gt; (The beginning of everything).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk4txxdqar4jarltrrkpp.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk4txxdqar4jarltrrkpp.gif" alt="Bart dancing" width="480" height="360"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Understanding database
&lt;/h2&gt;

&lt;p&gt;Basically, &lt;strong&gt;&lt;code&gt;Database&lt;/code&gt;&lt;/strong&gt; is an organized &lt;strong&gt;collection&lt;/strong&gt; that help us a manage a large volum of data.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Helps manage the volum of data and information;&lt;/li&gt;
&lt;li&gt;Allow quickly access to data;&lt;/li&gt;
&lt;li&gt;Easy data recovery;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;Collection&lt;/code&gt;: grouping of data organized and managed together.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5oop4hrsrqz432bu2d4o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5oop4hrsrqz432bu2d4o.png" alt="database" width="797" height="448"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  Why use &lt;code&gt;databases&lt;/code&gt;?
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;Databases&lt;/code&gt; play a crucial role in the efficient management of information in various sections. It offer a range of benefits. &lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Benefit&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Organization&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;Data&lt;/code&gt; is stored in a logical way, structure and allows for more efficient management and reduces redundancy&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Easy Acces&lt;/td&gt;
&lt;td&gt;With an efficient query it's possible to retrieve specific information in miliseconds, optimizing time and resources&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Escability&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;Database&lt;/code&gt; are designed for handle with crescent volum of information, support from small operations to millions of users simultaneously&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;In addition to these benefits, they also promote data integrity and security. In increasingly data-driven world, a more efficient information management capacity is essential for the success of any organization.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6lkybm9zt0t3vj9pr8ai.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6lkybm9zt0t3vj9pr8ai.gif" alt="Homer nervous" width="498" height="362"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;📝 &lt;strong&gt;Example:&lt;/strong&gt; &lt;br&gt;
Hospitals use databases for patients' medical records, follow-ups, histories, notes and invoices.&lt;/p&gt;

&lt;p&gt;Store use databases for products, invoices, amount, categories and others. &lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Key components of a &lt;code&gt;database&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;We have some components for some fundamental elements that work in collections to store, organize and manage data, let's continue!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgtm5157npfw1luxlhsgn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgtm5157npfw1luxlhsgn.png" alt="Example Table with Columns and Rows" width="508" height="311"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Name&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Table&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;Tables&lt;/code&gt; are the main units in a &lt;code&gt;database&lt;/code&gt;, work in a similar way to spreadsheets. They are made up for &lt;code&gt;rows&lt;/code&gt; and &lt;code&gt;columns&lt;/code&gt;, which organize the data in a structured way&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Rows&lt;/td&gt;
&lt;td&gt;Each &lt;code&gt;row&lt;/code&gt; represents a unit of log data. Contain specific information about an entity or item.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Column&lt;/td&gt;
&lt;td&gt;The &lt;code&gt;columns&lt;/code&gt; defines an attribute or property of stored data. Each &lt;code&gt;column&lt;/code&gt; in a &lt;code&gt;table&lt;/code&gt; represents a specific category of information, such as name, age or address&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;p&gt;We've seen some very important points about &lt;code&gt;Databases&lt;/code&gt; and how they work. The next article let's continue talking about &lt;code&gt;databases&lt;/code&gt; yet :D.&lt;/p&gt;

&lt;h4&gt;
  
  
  Next Topics
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;Databases&lt;/code&gt; Types

&lt;ul&gt;
&lt;li&gt;Relational&lt;/li&gt;
&lt;li&gt;Non-Relational&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Differences of Relational vs Non-Relational&lt;/li&gt;

&lt;li&gt;Primary Keys 🔑&lt;/li&gt;

&lt;li&gt;Foreign Keys 😶‍🌫️&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;Thank you for reading this far!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F73itris14mfe66ido1v4.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F73itris14mfe66ido1v4.gif" alt="Tom and Jerry" width="498" height="341"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Feel free to recommend articles, channels and so on of &lt;code&gt;Back-end&lt;/code&gt;, I appreciate it 😎.&lt;/p&gt;

</description>
      <category>backend</category>
      <category>database</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Starting my Back-end Journey (1/?)</title>
      <dc:creator>Larissa Dantier</dc:creator>
      <pubDate>Wed, 05 Feb 2025 02:07:23 +0000</pubDate>
      <link>https://dev.to/allmightenglishtech/starting-my-back-end-journey-1-367n</link>
      <guid>https://dev.to/allmightenglishtech/starting-my-back-end-journey-1-367n</guid>
      <description>&lt;p&gt;Hello, everyone! I'm Larissa and Front-end Developer, I have 5-6 years of professional experience and I started to see the need for learn back-end concepts in order to evolve my hard skills (Back-end is my achilles heel 😅).&lt;/p&gt;

&lt;p&gt;The purpose of this post is tell you my steps of what I doing and also practicing my writing in English. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.pinimg.com%2Foriginals%2F50%2F15%2F64%2F5015645c64e83a37449320676356dea9.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.pinimg.com%2Foriginals%2F50%2F15%2F64%2F5015645c64e83a37449320676356dea9.gif" width="498" height="268"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  My expections and objectives
&lt;/h2&gt;

&lt;p&gt;Last month, I started studying on &lt;strong&gt;&lt;a href="http://uphop.ai" rel="noopener noreferrer"&gt;uphop.ai&lt;/a&gt;&lt;/strong&gt;. Uphop is a plataform with any courses free, I search video or other plataforms, but I didn't understand it very well and all video I found used ORM (&lt;strong&gt;Object Relational Mapping&lt;/strong&gt;) like Prisma, TypeORM and others.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxvcsa94oy5u4u3cx7pxz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxvcsa94oy5u4u3cx7pxz.png" alt="Website Uphop" width="800" height="405"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I began to feel that I was just copying and pasting, just creating tables without really knowing why or how it works and their rules. I ended up finding on &lt;strong&gt;&lt;a href="https://www.reddit.com" rel="noopener noreferrer"&gt;Reddit&lt;/a&gt;&lt;/strong&gt; in community called &lt;strong&gt;&lt;a href="https://www.reddit.com/r/SQL/" rel="noopener noreferrer"&gt;r/SQL&lt;/a&gt;&lt;/strong&gt; and I found the &lt;strong&gt;Uphop&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;I thought why not start at the bottom, My Front-end Journey started the same way!&lt;/p&gt;

&lt;p&gt;So, that's why I explored the course &lt;strong&gt;&lt;a href="https://www.uphop.ai/app/c/sql_for_beginners" rel="noopener noreferrer"&gt;SQL for Beginners&lt;/a&gt;&lt;/strong&gt; which also has AI to help with any doubts and has some very nice practical examples.&lt;/p&gt;

&lt;p&gt;I using &lt;strong&gt;&lt;a href="https://obsidian.md" rel="noopener noreferrer"&gt;Obsidian&lt;/a&gt;&lt;/strong&gt; for my studies and probably I will use some notes I writed, themes like &lt;code&gt;Databases&lt;/code&gt;, &lt;code&gt;SQL&lt;/code&gt;, &lt;code&gt;Syntax with your commands and how use&lt;/code&gt; and more!&lt;/p&gt;




&lt;h3&gt;
  
  
  Initial Steps
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Learn &lt;code&gt;SQL&lt;/code&gt;, &lt;code&gt;Database&lt;/code&gt;, &lt;code&gt;PostgreSQL&lt;/code&gt;, &lt;code&gt;ORM&lt;/code&gt; (At some point) and others;

&lt;ul&gt;
&lt;li&gt;Introduction to Databases and SQL&lt;/li&gt;
&lt;li&gt;Basic Data Retrieval with SQL&lt;/li&gt;
&lt;li&gt;Data Manipulation with SQL&lt;/li&gt;
&lt;li&gt;Joining Tables and Basic SQL Data Types&lt;/li&gt;
&lt;li&gt;Data Manipulation with SQL&lt;/li&gt;
&lt;li&gt;Database Structure and Views&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  Next steps
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Learn NodeJS, Fastify, NestJS, Prisma and others

&lt;ul&gt;
&lt;li&gt;Start a basic project using all concepts learn of &lt;code&gt;Databases&lt;/code&gt; without &lt;code&gt;ORM&lt;/code&gt; yet&lt;/li&gt;
&lt;li&gt;Read the &lt;code&gt;Prisma&lt;/code&gt; Documentation - &lt;code&gt;ORM&lt;/code&gt;(I'm going to write an article just about the Prisma`) and make a new project with it.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;




&lt;p&gt;This initial article is more for you understand my objectives, how I'm going to study and to get to know myself a bit.&lt;/p&gt;

&lt;p&gt;Thank you for reading this far! And I hope to write more about this new journey for me!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmedia0.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExMzA3Z3h3N293bTcxdGI4NHU3aWd0YTAzdDE3enN2dTJzem50ZWd0YyZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2FjUwpNzg9IcyrK%2Fgiphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmedia0.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExMzA3Z3h3N293bTcxdGI4NHU3aWd0YTAzdDE3enN2dTJzem50ZWd0YyZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2FjUwpNzg9IcyrK%2Fgiphy.gif" width="500" height="375"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Feel free to recommend articles, channels and so on of &lt;code&gt;Back-end&lt;/code&gt;, I appreciate it 😎.&lt;/p&gt;

</description>
      <category>backend</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Building an Article Generator with LangChain and Llama3: An AI Developer's Journey</title>
      <dc:creator>Jorge Gomes</dc:creator>
      <pubDate>Mon, 09 Dec 2024 21:08:22 +0000</pubDate>
      <link>https://dev.to/allmightenglishtech/building-an-article-generator-with-langchain-and-llama3-an-ai-developers-journey-2l16</link>
      <guid>https://dev.to/allmightenglishtech/building-an-article-generator-with-langchain-and-llama3-an-ai-developers-journey-2l16</guid>
      <description>&lt;h1&gt;
  
  
  Building an Article Generator with LangChain and Llama3: An AI Developer's Journey
&lt;/h1&gt;

&lt;p&gt;As an AI developer, I often find myself looking for ways to make complex Large Language Model (LLM) interactions more manageable. LangChain caught my attention not only because of its growing popularity in the AI development community, but also because of its practical approach to solving common LLM integration challenges. The framework's reputation for transforming complex LLM operations into streamlined workflows intrigued me enough to put it to the test. I decided to build an article generation system that would combine LangChain's capabilities with the Llama3 model to create a tool with real-world applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why LangChain Makes Sense
&lt;/h2&gt;

&lt;p&gt;LangChain changes the way we interact with LLMs by providing a structured, intuitive approach to handling complex operations. Think of it as a well-designed development kit, with each component serving a specific purpose. Instead of juggling raw API calls and manually managing prompts, the framework provides a clean interface that feels natural from a developer's perspective. It's not just about simplifying the process, it's about making LLM applications more reliable and maintainable. &lt;/p&gt;

&lt;h2&gt;
  
  
  Key Components of LangChain
&lt;/h2&gt;

&lt;p&gt;At its core, LangChain uses chains, sequences of operations that link together to create more complex behaviors. These chains do everything from formatting prompts to processing model responses. While the framework includes sophisticated systems for managing prompts and maintaining context across interactions, I'll focus mainly on the chain and prompt aspects for our article generator. &lt;/p&gt;

&lt;h2&gt;
  
  
  The Article Generator
&lt;/h2&gt;

&lt;p&gt;For this project, I wanted to build something practical, a system that could generate customized articles based on specific parameters such as topic, length, tone, and target audience. The Llama3 model, accessed through Ollama, provided the right balance of performance and flexibility for this task.&lt;/p&gt;

&lt;h3&gt;
  
  
  Getting Started
&lt;/h3&gt;

&lt;p&gt;The setup is straightforward:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;First, I installed the necessary packages:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;langchain langchain-ollama requests
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Then, I set up Ollama:

&lt;ol&gt;
&lt;li&gt;I downloaded and installed Ollama from &lt;a href="https://ollama.com/blog/llama3" rel="noopener noreferrer"&gt;https://ollama.com/blog/llama3&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;In a new terminal, I started the Ollama server:
&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ollama serve
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;I pulled the Llama3 model:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ollama pull llama3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Ollama server must be running in its terminal while using the article generator. If it is closed, the generator won't be able to connect to the model.&lt;/p&gt;

&lt;h2&gt;
  
  
  Building the Core Components
&lt;/h2&gt;

&lt;p&gt;Let's break down how each part of the system works:&lt;/p&gt;

&lt;h3&gt;
  
  
  Connection Managment
&lt;/h3&gt;

&lt;p&gt;This simple check helps to avoid runtime errors by catching connection problems early. It is a reliable way to check the connection to the Ollama server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;check_ollama_connection&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
    Check if Ollama server is running
    &lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;http://localhost:11434/api/tags&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;
    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exceptions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;ConnectionError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Model Configuration
&lt;/h3&gt;

&lt;p&gt;Model setup is critical for getting the right balance in our generated content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;llm&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;OllamaLLM&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;llama3&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;temperature&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="c1"&gt;# Balances creativity and consistency
&lt;/span&gt;    &lt;span class="n"&gt;top_p&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.9&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;       &lt;span class="c1"&gt;# Helps with text diversity
&lt;/span&gt;    &lt;span class="n"&gt;num_ctx&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;4096&lt;/span&gt;     &lt;span class="c1"&gt;# Sets the context window
&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These parameters represent the sweet spot I found after testing various combinations for article generation. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Temperature (0.7):&lt;/strong&gt; Controls the randomness of the output. A lower value (like 0.3) would make the text more predictable, while a higher value (like 0.9) would make it more creative. 0.7 is a good balance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Top_p (0.9):&lt;/strong&gt; This parameter, also known as nucleus sampling, tells the model how many word options to consider. At 0.9, it looks at enough options to keep the text interesting while staying focused on the topic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;num_ctx(4096):&lt;/strong&gt; The context window size, or how much text the model can work with at once. This gives enough room for both the input and a substantial article output, as it can handle roughly 3000-3500 words. &lt;/p&gt;

&lt;h3&gt;
  
  
  Prompt Engineering
&lt;/h3&gt;

&lt;p&gt;The prompt template is where we define what we want from the model:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;article_template&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
You are a professional content writer tasked with creating a comprehensive article.

Topic: {topic}

Writing Requirements:
1. Length: Approximately {word_count} words
2. Style: {tone} tone
3. Target Audience: {audience}
4. Format: Plain text without any markdown notation
5. Additional Details/Requirements: {extra_details}

Content Structure Guidelines:
- Start with an engaging introduction that hooks the reader
- Organize content into clear sections with descriptive headings (not numbered)
- Include relevant examples, statistics, or case studies when appropriate
- Provide practical insights and actionable takeaways
- End with a compelling conclusion that summarizes key points
- Ensure smooth transitions between paragraphs and sections

Writing Style Guidelines:
- Use clear, concise language appropriate for the target audience
- Avoid jargon unless necessary for the target audience
- Incorporate relevant examples and real-world applications
- Maintain an engaging and natural flow throughout the article
- Use active voice predominantly
- Include specific details and evidence to support main points
- Ensure proper paragraph breaks for readability

Additional Notes:
- Do not use any markdown formatting
- Keep paragraphs concise and focused
- Use proper spacing between sections
- If technical terms are used, provide brief explanations
- Include a brief overview of what will be covered at the start

Please write the article now:
&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Generation Pipeline
&lt;/h3&gt;

&lt;p&gt;One of the most elegant features of LangChain is its simple chain composition:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;chain&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;prompt&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;llm&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This single line creates a complete generation pipeline that handles prompt formatting, model interaction, and response processing.&lt;/p&gt;

&lt;h3&gt;
  
  
  Command Line Interface
&lt;/h3&gt;

&lt;p&gt;To make the tool user-friendly, I implemented a command line interface:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;parse_arguments&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
    Parse command line arguments
    &lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="n"&gt;parser&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;argparse&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ArgumentParser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Generate an article using AI&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;parser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_argument&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;--topic&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
                       &lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
                       &lt;span class="n"&gt;required&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                       &lt;span class="n"&gt;help&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;The topic of the article&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;parser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_argument&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;--word-count&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
                       &lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
                       &lt;span class="n"&gt;default&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;800&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                       &lt;span class="n"&gt;help&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Target word count (default: 800)&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;parser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_argument&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;--tone&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
                       &lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
                       &lt;span class="n"&gt;default&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;professional&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                       &lt;span class="n"&gt;choices&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;professional&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;casual&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;academic&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;informative&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;technical&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                       &lt;span class="n"&gt;help&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Writing tone (default: professional)&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;parser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_argument&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;--audience&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
                       &lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
                       &lt;span class="n"&gt;default&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;general&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                       &lt;span class="n"&gt;help&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Target audience (default: general)&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;parser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_argument&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;--extra-details&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
                       &lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
                       &lt;span class="n"&gt;default&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                       &lt;span class="n"&gt;help&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Additional requirements or details for the article&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;parser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse_args&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Practical Usage
&lt;/h2&gt;

&lt;p&gt;The use of the generator is very simple: you run the code and pass the parameters.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example #1
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python main.py &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--topic&lt;/span&gt; &lt;span class="s2"&gt;"Benefits of playing board games with friends"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--word-count&lt;/span&gt; 200 &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--tone&lt;/span&gt; casual &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--audience&lt;/span&gt; &lt;span class="s2"&gt;"Board games lovers"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--extra-details&lt;/span&gt; &lt;span class="s2"&gt;"Avoid markdown notation"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The generated article:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Article generated in 12.39 seconds:

The Joy of Board Games: Why Playing with Friends is a Game-Changer

As we navigate the ups and downs of life, it's easy to get caught up in our individual pursuits and lose sight of the importance of social connections. But what if I told you that playing board games with friends can be a powerful way to strengthen those bonds, boost your mood, and even improve your mental health?

Benefits for Your Brain

Playing board games requires strategy, problem-solving, and critical thinking – all valuable skills that can help keep our brains sharp as we age. In fact, studies have shown that engaging in mentally stimulating activities like playing board games can delay the onset of age-related cognitive decline by up to five years.

Social Benefits Galore

But it's not just about individual brain benefits – playing board games with friends can also have a profound impact on our social lives. For one, it provides a unique opportunity for social interaction and bonding. When we laugh, joke, and share in the excitement of competition or cooperation, we're building memories and strengthening relationships that will last a lifetime.

Reducing Stress and Anxiety

In today's fast-paced world, stress and anxiety can be overwhelming. And while there are many ways to manage these feelings, playing board games with friends can be a particularly effective way to unwind and de-stress. The simple act of focusing on the game, away from our daily worries, can provide a much-needed break and help us approach life's challenges with a clearer head.

Conclusion

So the next time you're looking for a fun and fulfilling way to spend time with friends, consider breaking out the board games! Not only will you be exercising your brain and building relationships, but you'll also be reducing stress and anxiety. And who knows – you might just discover a new favorite game or hobby along the way.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Example #2
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python main.py &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--topic&lt;/span&gt; &lt;span class="s2"&gt;"Building an AI Article Generator with LangChain"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--word-count&lt;/span&gt; 200 &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--tone&lt;/span&gt; informative &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--audience&lt;/span&gt; &lt;span class="s2"&gt;"Python developers"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--extra-details&lt;/span&gt; &lt;span class="s2"&gt;"It's for beginners."&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The generated article:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Article generated in 20.99 seconds:

Building an AI Article Generator with LangChain: A Beginner's Guide

As a Python developer, you're likely familiar with the challenges of generating high-quality content quickly and efficiently. With the rise of artificial intelligence (AI) and natural language processing (NLP), it's become possible to create intelligent article generators that can produce engaging and informative content in no time. In this article, we'll explore how to build an AI article generator using LangChain, a popular open-source library for generating text.

What is LangChain?
LangChain is a Python library designed specifically for building language models and text generation applications. It's built on top of the powerful transformer architecture and provides a range of tools and features for creating custom language models and generators. With LangChain, you can train your own language model using a dataset of your choice and use it to generate high-quality text.

Getting Started with LangChain
To get started with LangChain, you'll need to install the library and import it into your Python environment. You can do this by running pip install langchain in your terminal or command prompt. Once installed, you can start building your AI article generator by defining a few key components:

* A dataset of text data that you want to use for training your language model
* A custom language model architecture that you want to train using the dataset
* A set of parameters and hyperparameters that you'll use to fine-tune your model

Training Your Language Model
To train your language model, you'll need to define a custom trainer class that will handle the training process. This class should include methods for loading your dataset, defining your model architecture, and optimizing your model's performance using a chosen loss function.

Using Your Trained Model to Generate Text
Once your language model is trained, you can use it to generate text by passing in some input prompts or text data. LangChain provides a range of pre-trained models that you can use for this purpose, including the popular T5 and BERT models.

Conclusion
Building an AI article generator with LangChain requires some programming expertise and knowledge of NLP concepts. However, with these skills and the right tools, you can create powerful language models that can generate high-quality text in no time. Whether you're a beginner or an experienced developer, LangChain provides a range of features and capabilities that make it easy to get started with building your own AI article generator.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Key Learnings
&lt;/h2&gt;

&lt;p&gt;Throughout this project, I discovered several important insights about working with LangChain: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Performance Patterns: The first generation takes longer due to model loading, but subsequent runs are significantly faster.&lt;/li&gt;
&lt;li&gt;Context Management: A 4096-token context window provides ample space for most articles while maintaining good performance.&lt;/li&gt;
&lt;li&gt;Generation Parameters: Temperature (0.7) and top_p (0.9) settings provide an optimal balance between creativity and coherence.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Building this article generator demonstrated LangChain's practical value in AI development. It handles the complexities of LLM interactions while giving developers the freedom to focus on building useful features. The framework strikes a balance between abstraction and control, making it easier to create reliable AI-powered applications.&lt;/p&gt;

&lt;p&gt;For dear colleagues in the area or sole enthusiasts, I’m confident that LangChain provides all the necessary meaning for development, and the best part is: it’s not a trade-off with flexibility. Thinking that the field of AI tools is exponentially growing, frameworks like LangChain will become more valuable for building practical, production-ready applications.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvvuxyacabk2at0omdzp1.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvvuxyacabk2at0omdzp1.gif" alt="image.png" width="212" height="168"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The LangChain logo of a parrot and a chain has a clever meaning behind it. The parrot refers to how LLMs are sometimes called “stochastic parrots” because they repeat and rework human language. The chain part is a playful reference to how the framework helps to “chain” language model "parrots" into useful applications.&lt;/p&gt;

</description>
      <category>langchain</category>
      <category>ai</category>
      <category>python</category>
      <category>llm</category>
    </item>
    <item>
      <title>Regex in VSCode: My favorite hacks</title>
      <dc:creator>Karina Pereira</dc:creator>
      <pubDate>Fri, 29 Nov 2024 04:00:06 +0000</pubDate>
      <link>https://dev.to/allmightenglishtech/regex-in-vscode-my-favorite-hacks-2ea6</link>
      <guid>https://dev.to/allmightenglishtech/regex-in-vscode-my-favorite-hacks-2ea6</guid>
      <description>&lt;p&gt;Recently, I needed to implement a gradual feature rollout. I had a spreadsheet with a list of 300 company IDs in the first column, which would be part of this phased release. &lt;/p&gt;

&lt;p&gt;My task was to take each ID individually and insert it into an update query to execute directly in the database.&lt;/p&gt;

&lt;p&gt;At first, I considered multiple different methods to make it. Then I remembered of VSCode combination with Regular Expressions, a technique I had heard about but never actually tried. This situation was the perfect opportunity to test it out.&lt;/p&gt;

&lt;p&gt;My idea with this article is to show you how combining VSCode with regular expressions can assist you.&lt;/p&gt;

&lt;h3&gt;
  
  
  Reasons To Use
&lt;/h3&gt;

&lt;p&gt;One of the most common uses is finding and replacing text, removing duplicates, and making adjustments across multiple files. You can see other applications in the following documentation: &lt;a href="https://learn.microsoft.com/en-us/visualstudio/ide/using-regular-expressions-in-visual-studio?view=vs-2022" rel="noopener noreferrer"&gt;https://learn.microsoft.com/en-us/visualstudio/ide/using-regular-expressions-in-visual-studio?view=vs-2022&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I will focus on the methods I have used that have helped me.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to use?
&lt;/h3&gt;

&lt;p&gt;To Enable the regular expressions in the function finding, press:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Command + F (MacOS) or Ctrl + F (Windows, Linux)&lt;/li&gt;
&lt;li&gt;Option + Command + F (⌥⌘F) or Ctrl + H (Windows, Linux)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This command will open the dialog box with &lt;strong&gt;Toggle Replace&lt;/strong&gt; enabled:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fenoyw6emw8ssdrsfeyl8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fenoyw6emw8ssdrsfeyl8.png" alt="image dialog box" width="800" height="161"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After this, you can check the option to "Use the Regular Expression”, usually represented by a &lt;strong&gt;.&lt;/strong&gt;* icon, with the command:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Option + Command + R (⌥⌘R) or Alt+E (Windows, Linux)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa7ufdrisrhzgy2sbuyvn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa7ufdrisrhzgy2sbuyvn.png" alt="image icon" width="800" height="176"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  My Favorite Cheats
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Find and Replace
&lt;/h4&gt;

&lt;p&gt;My first favorite cheats is to separate numbers with commas and quotes:&lt;/p&gt;

&lt;p&gt;Search: &lt;code&gt;(\d+)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Replace: &lt;code&gt;"$1”,&lt;/code&gt; (or no quotes &lt;code&gt;$1,&lt;/code&gt;)&lt;/p&gt;

&lt;p&gt;This will wrap the number in quotes and add a comma after it.&lt;/p&gt;

&lt;h4&gt;
  
  
  Transform multiples line into one:
&lt;/h4&gt;

&lt;p&gt;Search: &lt;code&gt;\n&lt;/code&gt;&lt;br&gt;
Replace: Use a space or nothing (depending on your preference).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgj2ut2w0svvqhxsstx70.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgj2ut2w0svvqhxsstx70.gif" alt="first cheat" width="480" height="350"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Comment specific search across multiple files
&lt;/h4&gt;

&lt;p&gt;Replace: &lt;code&gt;// $0&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5b7rmrqrdlhaox2fpgc1.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5b7rmrqrdlhaox2fpgc1.gif" alt="image specific search" width="480" height="290"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Find instances for classes
&lt;/h4&gt;

&lt;p&gt;To find instances where a class is being instantiated, use the following pattern:&lt;/p&gt;

&lt;p&gt;Search: &lt;code&gt;new\s+User\s*\(&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj8udx69an3bs139f18wt.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj8udx69an3bs139f18wt.gif" alt="find instance" width="480" height="322"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;
  
  
  How did I find these regular expressions?
&lt;/h5&gt;

&lt;p&gt;I usually search for them after testing on regex101.com or by Googling examples.&lt;br&gt;
Try exploring and adapting these techniques to your workflow.&lt;/p&gt;

&lt;p&gt;Regex can work like magic!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to Run FLUX1 for Free: A Step-by-Step Guide</title>
      <dc:creator>Felippe Chemello</dc:creator>
      <pubDate>Mon, 09 Sep 2024 17:22:18 +0000</pubDate>
      <link>https://dev.to/allmightenglishtech/how-to-run-flux1-for-free-a-step-by-step-guide-3h51</link>
      <guid>https://dev.to/allmightenglishtech/how-to-run-flux1-for-free-a-step-by-step-guide-3h51</guid>
      <description>&lt;p&gt;Flux.1 is the newest text-to-image model in the market, brought to us by Black Forest Labs. It is a state-of-the-art model that can generate high-quality images from text descriptions handling complex descriptions and generating high-quality images with fine details.&lt;/p&gt;

&lt;h2&gt;
  
  
  Who is behind Flux.1?
&lt;/h2&gt;

&lt;p&gt;Flux.1 is developed by Black Forest Labs, a company created by a &lt;a href="https://blackforestlabs.ai/our-team/" rel="noopener noreferrer"&gt;group of ex employees&lt;/a&gt; from Stability AI.&lt;/p&gt;

&lt;h2&gt;
  
  
  How does it work?
&lt;/h2&gt;

&lt;p&gt;Unlike other diffusion models, like Stable Diffusion that create images by gradually removing noise from a random start point, Flux.1 generates images using a technique called "flow matching" that takes a more direct approach, learning the exact transformations needed to convert noise into a realistic image. This allows to generate high-quality images faster and with less steps than common diffusion models.&lt;/p&gt;

&lt;p&gt;Also, with this different approach, Flux.1 can handle images with text inside it, like the one below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx3rcvpssas9waq36ht91.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx3rcvpssas9waq36ht91.png" alt="A photorealistic image of a modern, sleek laptop with a webpage open displaying the text " width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A photorealistic image of a modern, sleek laptop with a webpage open displaying the text "codestackme" in a clean, minimalist design. The laptop should be positioned on a white desk with soft lighting, highlighting the screen's glow and the subtle reflections on the metallic casing. The overall atmosphere should be professional and inviting, conveying a sense of innovation and technological advancement.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to write a good prompt for Flux.1?
&lt;/h2&gt;

&lt;p&gt;One of Flux.1’s standout features is its user-friendly prompting mechanism. The integration of CLIP (from OpenAI) and T5 (from GoogleAI) text encoders allows the model to interpret descriptions with a high degree of nuance. CLIP excels in aligning text with visual content, while T5 enhances the model's ability to process structured text inputs. Together, they enable Flux.1 to generate images that closely match the detailed prompts provided by users.&lt;/p&gt;

&lt;h2&gt;
  
  
  What types of models are there for Flux.1?
&lt;/h2&gt;

&lt;p&gt;Flux.1 comes in three distinct versions: Schnell, Dev and Pro.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Schnell&lt;/strong&gt; is the fastest model, optimized for speed and efficiency. It is allowed for commercial use, since was released under the Apache 2.0 license.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dev&lt;/strong&gt; provides a more flexible and experimental framework, it’s focused for developers and researches who want to fine-tune or customize certain features of the model. It was released with a non-commercial license.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pro&lt;/strong&gt; is the most advanced and resource-intensive version. It offers higher resolution outputs and can generate more complex images, however it is only available though the Black Forest Labs API.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How to use Flux.1 for free?
&lt;/h2&gt;

&lt;p&gt;For those interested in exploring the capabilities of Flux.1 without financial commitment, using modal.com as a resource provider is a viable option. &lt;a href="https://modal.com/" rel="noopener noreferrer"&gt;Modal.com&lt;/a&gt; offers a monthly compute power allowance of $30, which can support the generation of numerous images each month. You can learn more about their pricing and offerings at &lt;a href="https://modal.com/pricing" rel="noopener noreferrer"&gt;Modal.com Pricing&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This recommendation is not sponsored or endorsed by the platform.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To begin, you'll first need to &lt;a href="https://modal.com/signup" rel="noopener noreferrer"&gt;create an account on modal.com&lt;/a&gt; by logging in using your GitHub credentials.&lt;/p&gt;

&lt;p&gt;Next, you'll need to install the Modal CLI. Ensure that Python is installed on your computer. Once Python is set up, open your terminal and execute the command &lt;code&gt;pip install modal&lt;/code&gt;. After the installation is complete, run &lt;code&gt;modal setup&lt;/code&gt; to link the CLI with your Modal account.&lt;/p&gt;

&lt;p&gt;Proceed by cloning &lt;a href="https://github.com/FelippeChemello/modal_flux.1" rel="noopener noreferrer"&gt;this GitHub repository&lt;/a&gt; to your computer and navigate to the cloned directory.&lt;/p&gt;

&lt;p&gt;For security, create a secret called &lt;code&gt;flux.1-secret&lt;/code&gt; in your &lt;a href="https://modal.com/secrets/" rel="noopener noreferrer"&gt;modal dashboard&lt;/a&gt; with an environment variable named &lt;code&gt;API_KEY&lt;/code&gt; and assign it a random string.&lt;/p&gt;

&lt;p&gt;Finally, deploy your service by running &lt;code&gt;modal deploy app.py --name flux1&lt;/code&gt; in your terminal. Upon successful deployment, modal will provide a URL for accessing the web service:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;✓ Created objects.
├── 🔨 Created mount PythonPackage:app
├── 🔨 Created &lt;span class="k"&gt;function &lt;/span&gt;Model.build.
├── 🔨 Created &lt;span class="k"&gt;function &lt;/span&gt;Model.&lt;span class="k"&gt;*&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt;
├── 🔨 Created &lt;span class="k"&gt;function &lt;/span&gt;Model._inference.
└── 🔨 Created web &lt;span class="k"&gt;function &lt;/span&gt;Model.web_inference &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &amp;lt;PUBLIC_URL&amp;gt;
✓ App deployed &lt;span class="k"&gt;in &lt;/span&gt;3.206s! 🎉
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To use the service, make a GET request to the provided PUBLIC URL. Include the &lt;code&gt;x-api-key&lt;/code&gt; you set earlier in the headers, and encode your prompt in the query parameters. You can also specify desired image dimensions through query parameters. Here’s an example of how to structure your request:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"x-api-key: &amp;lt;API_KEY&amp;gt;"&lt;/span&gt; &amp;lt;PUBLIC_URL&amp;gt;?width&lt;span class="o"&gt;=&lt;/span&gt;&amp;lt;WIDTH&amp;gt;&amp;amp;height&lt;span class="o"&gt;=&lt;/span&gt;&amp;lt;HEIGHT&amp;gt;&amp;amp;prompt&lt;span class="o"&gt;=&lt;/span&gt;&amp;lt;PROMPT&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Understanding the Code
&lt;/h3&gt;

&lt;p&gt;Let's dissect the &lt;code&gt;app.py&lt;/code&gt; file, which is crucial for running our Flux.1 image generation service using modal's platform. Here's a breakdown of the setup and functionality:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;modal&lt;/span&gt;

&lt;span class="n"&gt;image&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;modal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Image&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;debian_slim&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;python_version&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;3.10&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;apt_install&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;libglib2.0-0&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;libsm6&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;libxrender1&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;libxext6&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ffmpeg&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;libgl1&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;git&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;pip_install&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;git+https://github.com/huggingface/diffusers.git&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;invisible_watermark&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;transformers&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;accelerate&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;safetensors&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;sentencepiece&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This block defines the Docker image for our application, specifying the OS, necessary libraries, and Python packages. This environment supports the execution of the Flux.1 model and associated utilities.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;modal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;App&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;flux1&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;image&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;imports&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;
    &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;io&lt;/span&gt;
    &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;torch&lt;/span&gt;
    &lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;diffusers&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;FluxPipeline&lt;/span&gt;
    &lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;fastapi&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Header&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, we initialize our app and import necessary Python libraries within the context of our previously defined Docker image. These imports are essential for image processing and handling web requests.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nd"&gt;@app.cls&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;gpu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;modal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;gpu&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;A100&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;container_idle_timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;image&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;image&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;120&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;secrets&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;modal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Secret&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;from_name&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;flux.1-secret&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)])&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nd"&gt;@modal.build&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;build&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;huggingface_hub&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;snapshot_download&lt;/span&gt;

        &lt;span class="nf"&gt;snapshot_download&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;black-forest-labs/FLUX.1-schnell&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="nd"&gt;@modal.enter&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;enter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Loading model...&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pipeline&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;FluxPipeline&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;from_pretrained&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;black-forest-labs/FLUX.1-schnell&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;torch_dtype&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;bfloat16&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;to&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;cuda&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Model loaded!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;inference&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1440&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1440&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Generating image...&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;image&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pipeline&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
            &lt;span class="n"&gt;output_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;pil&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
            &lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
            &lt;span class="n"&gt;height&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;height&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
            &lt;span class="n"&gt;num_inference_steps&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;generator&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Generator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;cpu&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;manual_seed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                &lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;randint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1000000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,)).&lt;/span&gt;&lt;span class="nf"&gt;item&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
            &lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;images&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Image generated!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="n"&gt;byte_stream&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;io&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;BytesIO&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;image&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;save&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;byte_stream&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;format&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;PNG&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;byte_stream&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getvalue&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="nd"&gt;@modal.web_endpoint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;docs&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;web_inference&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1440&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1440&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;x_api_key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Header&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;)):&lt;/span&gt;
        &lt;span class="n"&gt;api_key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getenv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;API_KEY&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;x_api_key&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;api_key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Unauthorized&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;status_code&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;401&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="n"&gt;image&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;inference&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;height&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;image&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;media_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;image/png&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This section defines the main functionality of our service:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;@modal.build()&lt;/code&gt;: Downloads the model when the application builds.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@modal.enter()&lt;/code&gt;: Loads the model into GPU memory the first time the service is invoked.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@modal.web_endpoint()&lt;/code&gt;: Serves as the web endpoint for our service using FastAPI.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you just want to run it as a local service, you can add &lt;code&gt;@modal.method()&lt;/code&gt; and define it as following inside the class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;        &lt;span class="nd"&gt;@modal.method&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;_inference&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1440&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1440&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;inference&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;height&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And outside it, define a local entry point&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nd"&gt;@app.local_entrypoint&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;A beautiful sunset over the mountains&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;image_bytes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Model&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;_inference&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;remote&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;output.png&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;wb&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;image_bytes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Local entry point will run locally on your machine calling the &lt;code&gt;_inference&lt;/code&gt; method remotely, so you still using the modal’s service, without exposing it to the internet.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Flux.1 is not just another tech breakthrough - it's a game-changer for anyone who's ever dreamed of bringing their ideas to life visually. Imagine being able to describe a scene in words and watch as it materializes into a stunning, detailed image right before your eyes. That's the magic of Flux.1. It's like having a super-talented artist at your fingertips, ready to paint your thoughts with incredible precision. Whether you're an artist looking to speed up your creative process, a designer in need of quick visual concepts, or just someone who loves playing with new tech, Flux.1 opens up a world of possibilities. It's not about replacing human creativity - it's about enhancing it, making the journey from imagination to reality smoother and more exciting than ever before.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>tutorial</category>
      <category>python</category>
      <category>fastapi</category>
    </item>
  </channel>
</rss>
