<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Esanki Thambawita on Medium]]></title>
        <description><![CDATA[Stories by Esanki Thambawita on Medium]]></description>
        <link>https://medium.com/@esankithambawita?source=rss-8407c63abc27------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*JobTozYmyGbcWVyd</url>
            <title>Stories by Esanki Thambawita on Medium</title>
            <link>https://medium.com/@esankithambawita?source=rss-8407c63abc27------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 08:27:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@esankithambawita/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building Your Own Local Chatbot with Streamlit, LangChain, and Ollama: A Beginner’s Guide]]></title>
            <link>https://medium.com/@esankithambawita/building-your-own-local-chatbot-with-streamlit-langchain-and-ollama-a-beginners-guide-e8e05fa264b7?source=rss-8407c63abc27------2</link>
            <guid isPermaLink="false">https://medium.com/p/e8e05fa264b7</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[streamlit]]></category>
            <category><![CDATA[chatbots]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[langchain]]></category>
            <dc:creator><![CDATA[Esanki Thambawita]]></dc:creator>
            <pubDate>Thu, 24 Jul 2025 10:58:19 GMT</pubDate>
            <atom:updated>2025-07-24T10:58:19.083Z</atom:updated>
            <content:encoded><![CDATA[<p>Artificial Intelligence chatbots are everywhere, but did you know you can build one that runs entirely on your local machine with no cloud, no API keys, and full control? In this article, I’ll show you how I built my own local chatbot using <strong>Streamlit</strong>, <strong>LangChain</strong>, and <strong>Ollama</strong>, and explain how the code works step-by-step.</p><h3>Why Build a Local Chatbot?</h3><ul><li><strong>Privacy &amp; control:</strong> Your data stays on your machine.</li><li><strong>No API keys or cloud costs:</strong> Save money and simplify setup.</li><li><strong>Customization:</strong> Easily tweak behavior and personality.</li></ul><h3>The Tech Stack</h3><ul><li><strong>Streamlit:</strong> A simple Python framework for building interactive web apps quickly. We use it to create the chatbot interface.</li><li><strong>LangChain:</strong> A library that helps manage conversation context and messages clearly. It organizes the chat history and formats messages for language models.</li><li><strong>Ollama:</strong> A local large language model (LLM) runtime. Ollama allows you to run powerful models like llama2 directly on your computer.</li></ul><h3>How the Code Works</h3><h4>1. Setting Up the Chat Interface with Streamlit</h4><p>Streamlit makes it easy to create a chat UI. Here’s the core part:</p><pre>import streamlit as st<br>from langchain_core.messages import HumanMessage, AIMessage<br><br>st.title(&quot;Chatbot&quot;)<br><br>if &quot;messages&quot; not in st.session_state:<br>    st.session_state.messages = []<br><br>for message in st.session_state.messages:<br>    if isinstance(message, HumanMessage):<br>        with st.chat_message(&quot;user&quot;):<br>            st.markdown(message.content)<br>    elif isinstance(message, AIMessage):<br>        with st.chat_message(&quot;assistant&quot;):<br>            st.markdown(message.content)<br><br>prompt = st.chat_input(&quot;Your message&quot;)<br><br>if prompt:<br>    st.session_state.messages.append(HumanMessage(prompt))<br>    # Generate response here<br>    response = f&quot;Echo: {prompt}&quot;<br>    st.session_state.messages.append(AIMessage(response))</pre><ul><li>We initialize a message list in st.session_state to store chat history during the session.</li><li>Display previous messages on the screen.</li><li>Use st.chat_input() to get user input.</li><li>Add user and bot messages to the session state for context.</li></ul><h4>2. Managing Messages with LangChain</h4><p>LangChain uses specific message classes like HumanMessage and AIMessage to help structure conversation data. This structure makes it easy to pass the full chat history to the model and maintain context.</p><h4>3. Running the Model Locally with Ollama</h4><p>Instead of sending requests to an API, Ollama lets us run the model on our own machine:</p><pre>from langchain_community.chat_models import ChatOllama<br><br>llm = ChatOllama(model=&quot;llama2&quot;, temperature=0.7)<br>response = llm.invoke(st.session_state.messages).content<br>st.session_state.messages.append(AIMessage(response))</pre><ul><li>We instantiate a local model llama2.</li><li>Send the full chat history (st.session_state.messages) so the model &quot;remembers&quot; the conversation.</li><li>Append the model’s reply back to the chat history.</li></ul><h3>How the Chatbot Remembers Context</h3><p>The chatbot “remembers” your previous messages because we send <strong>the entire chat history every time</strong> we ask the model for a reply. The model processes all past messages as context, so it can refer back to details like your name or earlier questions , all within the same session.</p><h3>How Chatbot Behavior Works: Customizing Personality with System Prompts</h3><p>One of the coolest parts of building this chatbot is that you can easily change how it behaves by setting a <strong>system prompt, </strong>a special instruction given to the model before the conversation starts.</p><p>For example, in the code, you might see something like this:</p><pre>from langchain_core.messages import SystemMessage<br><br>if &quot;messages&quot; not in st.session_state:<br>    st.session_state.messages = []<br>    st.session_state.messages.append(SystemMessage(&quot;Act like an astronaut&quot;))</pre><p>This tells the chatbot to <strong>take on the persona of an astronaut, </strong>so its replies sound space-themed!</p><p>You can swap out that prompt for anything you like, such as:</p><ul><li>&quot;You are a helpful assistant.&quot; (neutral, professional tone)</li><li>&quot;You are a friendly dinosaur who loves to chat.&quot; 🦖</li><li>&quot;You are a pirate speaking in pirate slang.&quot; 🏴‍☠️</li></ul><p>This system message sets the <strong>behavior and tone</strong> of the chatbot throughout the session, making the AI’s responses fun, quirky, serious, or whatever you want!</p><h3>Why is this important?</h3><p>The system prompt guides the language model to generate responses consistent with a certain style or personality , without changing any other code.</p><h3>What I Learned</h3><ul><li>How to build a clean, interactive chatbot UI with Streamlit in just a few lines of code.</li><li>The power of LangChain to organize and manage conversations.</li><li>Running powerful AI models locally with Ollama, removing cloud dependency and privacy concerns.</li><li>How to customize chatbot personality using system prompts.</li></ul><h3>Final Thoughts</h3><p>Building a local chatbot like this is a great way to learn about modern AI workflows without relying on third-party APIs. Plus, it’s fun to see your chatbot come alive, whether it’s an astronaut, dinosaur, or your own unique character!</p><h3>Try it Yourself!</h3><p>If you’re interested, try building your own chatbot using these tools. You’ll be surprised how quickly you can have a fully working AI assistant on your laptop.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e8e05fa264b7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding MVC Architecture in ASP.NET Core vs Spring Boot]]></title>
            <link>https://medium.com/@esankithambawita/understanding-mvc-architecture-in-asp-net-core-vs-spring-boot-512cff06bd12?source=rss-8407c63abc27------2</link>
            <guid isPermaLink="false">https://medium.com/p/512cff06bd12</guid>
            <category><![CDATA[spring-mvc]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[backend-development]]></category>
            <category><![CDATA[asp-net-mvc]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Esanki Thambawita]]></dc:creator>
            <pubDate>Fri, 11 Jul 2025 17:23:33 GMT</pubDate>
            <atom:updated>2025-07-11T17:23:33.985Z</atom:updated>
            <content:encoded><![CDATA[<p>A beginner-friendly comparison of how the MVC pattern is implemented in two powerful backend frameworks — ASP.NET Core and Spring Boot.</p><h3>Introduction</h3><p>As a Computer Science undergraduate exploring both .NET and Java ecosystems, I was curious about how each platform structures web applications. One architectural pattern stood out in both: <strong>MVC — Model-View-Controller</strong>.</p><p>While both ASP.NET Core and Spring Boot adopt the MVC pattern, the way they implement it differs in design, syntax, and structure. In this article, I compare the two to deepen my understanding and help other learners grasp the core concepts.</p><h3>What is MVC?</h3><p><strong>MVC (Model-View-Controller)</strong> is a software design pattern that separates an application into three main logical components:</p><ul><li><strong>Model</strong>: Represents the data and business logic of the application.</li><li><strong>View</strong>: Represents the UI or presentation layer.</li><li><strong>Controller</strong>: Handles user input, processes requests, and updates models or views accordingly.</li></ul><p>This separation of concerns makes applications more maintainable, testable, and scalable.</p><h3>MVC in ASP.NET Core</h3><p>ASP.NET Core provides built-in support for the MVC pattern through the Microsoft.AspNetCore.Mvc namespace. Here&#39;s how the components are structured:</p><h3>Controller</h3><p>Controllers are C# classes that inherit from the Controller base class and handle HTTP requests.</p><pre>public class ProductController : Controller<br>{<br>    public IActionResult Index()<br>    {<br>        var products = _productService.GetAll();<br>        return View(products);<br>    }<br>}</pre><h3>Model</h3><p>Models are simple C# classes that define the structure of the data.</p><pre>public class Product<br>{<br>    public int Id { get; set; }<br>    public string Name { get; set; }<br>}</pre><h3>View</h3><p>Views are .cshtml files using the Razor templating engine.</p><pre>@model List&lt;Product&gt;<br><br>@foreach (var product in Model)<br>{<br>    &lt;p&gt;@product.Name&lt;/p&gt;<br>}</pre><h3>MVC in Spring Boot (Spring MVC)</h3><p>Spring Boot leverages Spring MVC, part of the larger Spring Framework. It also follows the MVC pattern.</p><h3>Controller</h3><p>Controllers are annotated with @Controller or @RestController.</p><pre>@Controller<br>public class ProductController {<br><br>    @GetMapping(&quot;/products&quot;)<br>    public String getProducts(Model model) {<br>        List&lt;Product&gt; products = productService.getAll();<br>        model.addAttribute(&quot;products&quot;, products);<br>        return &quot;products&quot;; // Refers to a Thymeleaf template<br>    }<br>}</pre><h3>Model</h3><p>Models are plain old Java objects (POJOs).</p><pre>public class Product {<br>    private int id;<br>    private String name;<br><br>    // Getters and setters<br>}</pre><h3>View</h3><p>Views are typically rendered using the Thymeleaf engine.</p><pre>&lt;!-- products.html --&gt;<br>&lt;ul&gt;<br>  &lt;li th:each=&quot;product : ${products}&quot;&gt;<br>    &lt;span th:text=&quot;${product.name}&quot;&gt;&lt;/span&gt;<br>  &lt;/li&gt;<br>&lt;/ul&gt;</pre><p>Key Differences</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3xrP97InyxoL2-0NaTsAWg.png" /></figure><h3>What I Learned</h3><ul><li>Both frameworks enforce <strong>clean separation of concerns</strong>, making code easier to read and maintain.</li><li>ASP.NET Core is more <strong>opinionated</strong> and structured.</li><li>Spring Boot offers <strong>greater flexibility</strong>, but with slightly more configuration.</li><li>Learning both gave me a stronger understanding of modern backend development practices across ecosystems.</li></ul><h3>Final Thoughts</h3><p>Whether you’re working in Java or C#, understanding how MVC works is fundamental for building scalable, maintainable web applications. ASP.NET Core and Spring Boot each offer robust support for MVC with their own strengths and conventions.</p><p><strong>Thanks for reading!</strong><br> Feel free to connect with me on <a href="https://www.linkedin.com/in/esanki-thambawita-350947256/">LinkedIn </a>or explore my <a href="https://github.com/EsankiThambawita">GitHub </a>for more projects.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=512cff06bd12" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>