<?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 Adurinti Ashok on Medium]]></title>
        <description><![CDATA[Stories by Adurinti Ashok on Medium]]></description>
        <link>https://medium.com/@codewithadurintiashok?source=rss-2f80c64e21f5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*whELq_RpoOuIc5L-PbGWOQ.png</url>
            <title>Stories by Adurinti Ashok on Medium</title>
            <link>https://medium.com/@codewithadurintiashok?source=rss-2f80c64e21f5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 07:27:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@codewithadurintiashok/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[Managing API Traffic and Handling Failures: Rate Limiting, Throttling, and Circuit Breaker]]></title>
            <link>https://medium.com/@codewithadurintiashok/managing-api-traffic-and-handling-failures-rate-limiting-throttling-and-circuit-breaker-9766ccda512e?source=rss-2f80c64e21f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/9766ccda512e</guid>
            <dc:creator><![CDATA[Adurinti Ashok]]></dc:creator>
            <pubDate>Fri, 20 Nov 2026 14:41:37 GMT</pubDate>
            <atom:updated>2026-11-20T14:49:38.636Z</atom:updated>
            <content:encoded><![CDATA[<p>When building backend applications, handling incoming API requests efficiently is important. As the number of users increases, our APIs may receive hundreds or thousands of requests within a short period.</p><p>If we don’t manage these requests properly, the server can become overloaded, response times can increase, and the application may become unavailable.</p><p>Similarly, backend applications often depend on external services. If one of those services becomes unavailable, repeatedly sending requests to it can affect the entire application.</p><p>To handle these situations, we use techniques such as <strong>Rate Limiting, Throttling, and Circuit Breaker</strong>.</p><p>Let’s understand each of them with simple examples.</p><h3>1. What is Rate Limiting?</h3><p>Rate Limiting is a technique used to control how many requests a user can make to an API within a specific time period.</p><p>For example, imagine that we configure our login API to allow a maximum of 5 requests per minute.</p><ul><li>First request: Allowed.</li><li>Second request: Allowed.</li><li>Third request: Allowed.</li><li>Fourth request: Allowed.</li><li>Fifth request: Allowed.</li><li>Sixth request: Rejected.</li></ul><p>The server rejects the sixth request because the user has already reached the configured limit.</p><h3>Why do we need Rate Limiting?</h3><ul><li>To prevent users from sending too many requests.</li><li>To protect APIs from excessive traffic and abuse.</li><li>To reduce unnecessary server load.</li><li>To protect sensitive endpoints.</li><li>To ensure fair usage of APIs.</li></ul><h3>2. Fixed Window Counter Algorithm</h3><p>There are different algorithms used to implement Rate Limiting. Some commonly used approaches are:</p><ul><li>Fixed Window Counter</li><li>Sliding Window Log</li><li>Sliding Window Counter</li><li>Token Bucket</li><li>Leaky Bucket</li></ul><p>Let’s understand the Fixed Window Counter algorithm.</p><h3>How does Fixed Window Counter work?</h3><p>The Fixed Window Counter divides time into fixed intervals and maintains a separate request counter for each interval.</p><p>For example, assume our API allows 100 requests per minute.</p><p>The system divides time into one-minute windows:</p><ul><li>First window: 10:00:00–10:00:59</li><li>Second window: 10:01:00–10:01:59</li><li>Third window: 10:02:00–10:02:59</li></ul><p>For every incoming request, the counter for the current window increases by one.</p><p>Let’s consider the first window:</p><ul><li>Request 1: Counter = 1</li><li>Request 2: Counter = 2</li><li>Request 50: Counter = 50</li><li>Request 100: Counter = 100</li><li>Request 101: Rejected</li></ul><p>Once the counter reaches 100, additional requests are rejected until the next window starts.</p><p>When the next minute begins, the counter resets to zero, and the user can make another 100 requests.</p><h3>Why did we choose Fixed Window Counter?</h3><p>We chose this algorithm because it is simple and efficient to implement.</p><ul><li><strong>Simple implementation:</strong> It only needs a counter and a time window.</li><li><strong>Low memory usage:</strong> It doesn’t need to store individual request timestamps.</li><li><strong>Good performance:</strong> Checking and updating a counter is inexpensive.</li><li><strong>Easy configuration:</strong> We can define different request limits for different APIs.</li></ul><p>One limitation is that it can allow a sudden burst of requests around the window boundary.</p><p>For example, a user could send 100 requests at 10:00:59 and another 100 requests at 10:01:00.</p><p>This means 200 requests could arrive within just two seconds, even though the configured limit is 100 requests per minute.</p><p>Despite this limitation, Fixed Window Counter is a practical choice when simplicity and performance are the main priorities.</p><h3>3. What is Throttling?</h3><p>Throttling is a technique used to control the speed at which requests are processed by a system.</p><p>Imagine a user sends 10 requests to an API within one second. Processing all these requests at once may put unnecessary pressure on the server.</p><p>Throttling helps manage this traffic by controlling how quickly requests are handled.</p><p>Depending on the implementation, the system can:</p><ul><li><strong>Delay requests:</strong> Process requests at a controlled speed instead of handling them all at once.</li><li><strong>Queue requests:</strong> Temporarily hold incoming requests and process them one by one.</li><li><strong>Reject excess requests:</strong> Reject requests when the configured processing limit is exceeded.</li></ul><h3>Rate Limiting vs Throttling</h3><p>Although both techniques help control API traffic, they focus on different aspects.</p><ul><li><strong>Rate Limiting:</strong> Defines the maximum number of requests allowed within a specific time period.</li><li><strong>Throttling:</strong> Controls the rate at which requests are accepted or processed.</li></ul><p>For example, Rate Limiting might allow a maximum of 100 requests per minute, while a throttling mechanism might process requests at a controlled rate of 2 requests per second.</p><p>Both techniques help prevent excessive traffic and protect backend resources</p><h3>4. What is a Circuit Breaker?</h3><p>So far, we have discussed how to control incoming API requests.</p><p>But what happens when our application depends on another service and that service becomes unavailable?</p><p>For example, imagine an application that communicates with an external payment service.</p><p>Suddenly, the payment service starts failing.</p><p>Our application may continue sending requests to that service. Those requests repeatedly fail, consume resources, and increase response times.</p><p>If this continues, it can affect other parts of our application as well.</p><p>This is where the <strong>Circuit Breaker pattern</strong> becomes useful.</p><p>A Circuit Breaker monitors failures when communicating with an external service. When failures reach a configured threshold, it temporarily stops sending requests to that service.</p><p>Instead of repeatedly calling an unhealthy service, the application fails fast and gives that service some time to recover.</p><h3>Why do we need a Circuit Breaker?</h3><ul><li>To prevent repeated calls to unavailable services.</li><li>To reduce unnecessary network requests.</li><li>To avoid cascading failures between services.</li><li>To give external services time to recover.</li><li>To improve overall application reliability.</li></ul><h3>5. Three States of a Circuit Breaker</h3><p>A Circuit Breaker generally has three states.</p><h3>1. Closed State</h3><p>This is the normal operating state.</p><p>The application sends requests to the external service as usual.</p><p>If the requests succeed, the circuit remains closed.</p><p>However, if failures reach the configured threshold, the circuit moves to the Open state.</p><p>For example, assume the failure threshold is 5. If the configured failure condition is met after 5 failed requests, the Circuit Breaker opens.</p><h3>2. Open State</h3><p>In this state, the Circuit Breaker stops sending requests to the external service.</p><p>Instead of making another network call, the application immediately returns an error or a fallback response.</p><p>This prevents unnecessary requests to an unhealthy service.</p><p>The circuit remains open for a configured period, such as 30 seconds.</p><p>After that period, it moves to the Half-Open state.</p><h3>3. Half-Open State</h3><p>In this state, the Circuit Breaker allows a limited number of test requests to check whether the external service has recovered.</p><p>There are two possible outcomes:</p><ul><li><strong>If the test requests succeed:</strong> The circuit moves back to the Closed state.</li><li><strong>If the test requests fail:</strong> The circuit moves back to the Open state.</li></ul><p>This allows the application to check whether the service is healthy again without immediately sending a large number of requests.</p><h3>6. How These Techniques Work Together</h3><p>Let’s take an example of an application that has a login API and depends on an external authentication service.</p><p>Consider the following flow:</p><ol><li>A user sends multiple login requests.</li><li>Rate Limiting checks whether the user has exceeded the configured request limit.</li><li>If the limit is exceeded, additional requests are rejected.</li><li>Throttling controls how quickly accepted requests are handled.</li><li>When a request needs the external authentication service, the Circuit Breaker checks whether calls to that service are allowed.</li><li>If the circuit is Open, the application avoids calling the unavailable service and returns an appropriate error or fallback response.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9766ccda512e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is TLS Handshake : How Browsers and Servers Establish a Secure Connection]]></title>
            <link>https://medium.com/@codewithadurintiashok/what-is-tls-handshake-how-browsers-and-servers-establish-a-secure-connection-7d8547361b96?source=rss-2f80c64e21f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/7d8547361b96</guid>
            <category><![CDATA[secuity]]></category>
            <category><![CDATA[tls]]></category>
            <category><![CDATA[netowkr]]></category>
            <category><![CDATA[tls-handshake]]></category>
            <dc:creator><![CDATA[Adurinti Ashok]]></dc:creator>
            <pubDate>Fri, 13 Nov 2026 15:21:44 GMT</pubDate>
            <atom:updated>2026-11-13T15:28:54.473Z</atom:updated>
            <content:encoded><![CDATA[<p>Whenever we open a website using https://, our browser needs to establish a secure connection with the server before exchanging application data.</p><p>But have you ever wondered what happens behind the scenes?</p><ul><li>How does the browser know it is communicating with the correct server?</li></ul><p>The answer lies in <strong>TLS (Transport Layer Security)</strong>.</p><p>In this article, let’s understand how the TLS handshake works step by step using a simple example.</p><h3>1. What is TLS?</h3><p>TLS stands for Transport Layer Security.</p><p>It is a security protocol that establishes an encrypted connection between a client and a server over a network.</p><p>It provides three important security features:</p><p><strong>1. Encryption:</strong> Prevents unauthorized people from reading the data being transmitted.</p><p><strong>2. Authentication:</strong> Helps verify the identity of the server.</p><p><strong>3. Integrity:</strong> Helps ensure that data has not been modified during transmission without detection.</p><p>For example, when we log in to an application using our username and password, TLS helps protect that information while it travels between our browser and the server.</p><h3>2. What is a TLS Handshake?</h3><p>Before exchanging HTTP application data, the client and server need to establish a secure connection.</p><p>The process of establishing this secure connection is called the <strong>TLS Handshake</strong>.</p><p>During this process, the client and server:</p><ul><li>Agree on the TLS version and cryptographic algorithms.</li><li>Verify the server’s identity.</li><li>Establish a shared secret.</li><li>Derive encryption keys.</li></ul><p>Let’s understand how this happens.</p><h3>3. Step 1: Client Sends ClientHello</h3><p>Suppose we open the following website:</p><p><a href="https://example.com/">https://myapplication.com</a></p><p>Our browser acts as the client and sends a message called ClientHello to the server.</p><p>This message contains information such as:</p><ul><li><strong>Supported TLS versions:</strong> For example, TLS 1.3.</li><li><strong>Supported cipher suites:</strong> Cryptographic algorithms the client supports.</li><li><strong>Key share:</strong> The client’s temporary public key share used for key exchange.</li><li><strong>Other parameters:</strong> Additional information required to establish the connection.</li></ul><p>In simple words, the client tells the server:</p><p>“These are the security options I support. Here is my public key share.”</p><p>The client is essentially providing the options available for establishing a secure connection.</p><h3>4. Step 2: Server Responds with ServerHello</h3><p>The server receives the ClientHello message and responds with a message called ServerHello.</p><p>It contains:</p><ul><li>The selected TLS version.</li><li>The selected cipher suite.</li><li>The server’s key share.</li></ul><p>The server also sends its digital certificate in a separate handshake message.</p><p>The certificate helps the client verify the server’s identity.</p><p>In simple words, the server says:</p><p>“Let’s use TLS 1.3 and this cipher suite. Here is my key share, and I will also provide my digital certificate to prove my identity.”</p><p>At this point, both parties have exchanged their public key shares.</p><h3>5. Step 3: Verify the Digital Certificate</h3><p>Why does the server send a digital certificate?</p><p>Imagine you are accessing your banking website. Someone creates a fake website that looks exactly like the original one.</p><p>How does your browser know whether it is communicating with the legitimate banking server or a fake server?</p><p>This is where digital certificates help.</p><p>A digital certificate is issued by a trusted Certificate Authority (CA) and helps establish the identity of the server.</p><p>The browser checks:</p><ul><li>Whether the certificate was issued by a trusted Certificate Authority.</li><li>Whether the certificate is valid.</li><li>Whether the certificate matches the requested domain name.</li><li>Whether the certificate has been revoked, where applicable.</li></ul><p>If verification succeeds, the browser can trust the server’s authenticated identity.</p><p><strong>Important:</strong> In TLS 1.3 using ECDHE, the certificate’s public key is primarily used for authentication, not for generating the shared secret.</p><h3>6. Step 4: Client and Server Generate a Shared Secret</h3><p>This is one of the most interesting parts of the TLS handshake.</p><p>How can two systems generate the same secret without directly sharing that secret over the network?</p><p>TLS 1.3 commonly uses a key exchange mechanism called <strong>ECDHE (Elliptic Curve Diffie-Hellman Ephemeral)</strong>.</p><p>Let’s understand it step by step.</p><h3>On the client side:</h3><ol><li>The client generates a temporary private key.</li><li>It generates a corresponding public key share.</li><li>It sends its public key share to the server.</li></ol><h3>On the server side:</h3><ol><li>The server generates its own temporary private key.</li><li>It generates a corresponding public key share.</li><li>It sends its public key share to the client.</li></ol><p>Now both parties have the other party’s public key share.</p><p>They independently calculate the same shared secret.</p><ul><li>The client uses its private key and the server’s public key share.</li><li>The server uses its private key and the client’s public key share.</li></ul><p>Both arrive at the same shared secret.</p><h3>Let’s understand with a simple representation:</h3><p><strong>Client:</strong></p><p>Client Private Key + Server Public Key Share = Shared Secret</p><p><strong>Server:</strong></p><p>Server Private Key + Client Public Key Share = Shared Secret</p><p>Both generate the same secret independently.</p><p>The important thing to remember is:</p><ul><li>Private keys are never shared over the network.</li><li>The shared secret is never directly transmitted over the network.</li><li>Both parties independently calculate the same secret.</li></ul><p>This is how two systems establish a common secret over an insecure network.</p><h3>7. Step 5: Generate Encryption Keys</h3><p>Now both the client and server have the same shared secret.</p><p>But do they directly use this shared secret as the encryption key?</p><p>No.</p><p>TLS uses a key derivation function called <strong>HKDF (HMAC-based Key Derivation Function)</strong> to derive cryptographic keys from the shared secret and other handshake information.</p><p>These keys are used to encrypt and decrypt the data exchanged between the client and server.</p><p>Both parties independently derive the corresponding keys, so they are ready to encrypt and decrypt communication.</p><p>After generating the encryption keys:</p><ol><li>The server sends a CertificateVerify message to prove its identity.</li><li>The server sends a Finished message to verify the handshake.</li><li>The client verifies it and sends its own Finished message.</li><li>The server verifies the client’s message.</li></ol><p>Once both sides verify the Finished messages, the TLS handshake is complete!</p><p>Both are now ready for secure communication.</p><p>The TLS handshake is now complete! Congratulations, you’ve successfully established a secure connection with this article. No more handshakes needed😂</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*-DanDFnJ468rrLXUN5JubA.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7d8547361b96" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What Does a Tool Mean in LangChain?]]></title>
            <link>https://medium.com/@codewithadurintiashok/what-does-a-tool-mean-in-langchain-2260546d9f4b?source=rss-2f80c64e21f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/2260546d9f4b</guid>
            <category><![CDATA[generative-ai]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[langchain]]></category>
            <dc:creator><![CDATA[Adurinti Ashok]]></dc:creator>
            <pubDate>Fri, 21 Aug 2026 13:19:36 GMT</pubDate>
            <atom:updated>2026-08-21T13:19:36.201Z</atom:updated>
            <content:encoded><![CDATA[<p>When we build a normal chatbot, the flow is pretty simple:</p><p><strong>User → LLM → Answer</strong></p><p>For example, you ask:</p><blockquote><strong>“What is LangChain?”</strong></blockquote><p>The LLM already has enough knowledge to answer the question.</p><p>But what if you ask:</p><blockquote><strong>“What’s the weather in Hyderabad right now?”</strong></blockquote><p>The LLM doesn’t have access to live weather information. It needs to <strong>check an external source</strong> to get the latest information. This is where <strong>Tools</strong> come into the picture.</p><h3>Think of the AI Like a Person</h3><p>Imagine you ask a person:</p><blockquote><strong>“What’s the weather in Hyderabad?”</strong></blockquote><p>They probably can’t answer accurately just by thinking. They would open a weather app or website and check.</p><p>An AI works in a similar way.</p><p>You can think of it like this:</p><pre>LLM   = Brain 🧠<br>Tool  = Ability to perform a task 🔧<br>API   = External source of information 🌐</pre><p>We give the LLM access to a tool, and that tool can interact with an external API or source.</p><h3>So, What Exactly Is a Tool?</h3><p>In LangChain, a <strong>Tool is basically a function that the LLM can request your application to execute</strong>.</p><p>For example:</p><pre>from langchain_core.tools import tool</pre><pre>@tool<br>def get_weather(city: str):<br>    &quot;&quot;&quot;Get the current weather for a city.&quot;&quot;&quot;</pre><pre>    # Call weather API</pre><pre>    return weather_data</pre><p>The important part here is:</p><pre>@tool</pre><p>This tells LangChain:</p><blockquote><strong>“This function is available as a tool that the LLM can use.”</strong></blockquote><h3>Let’s Take a Real Example</h3><p>Suppose we’re building a chatbot that uses <strong>WeatherAPI</strong> to get live weather information.</p><p>The user asks:</p><blockquote><strong>“What’s the weather in Bangalore?”</strong></blockquote><p>The flow would look something like this:</p><pre>User<br>  ↓<br>&quot;What’s the weather in Bangalore?&quot;<br>  ↓<br>LLM<br>  ↓<br>&quot;I need current weather information.&quot;<br>  ↓<br>get_weather(&quot;Bangalore&quot;)<br>  ↓<br>WeatherAPI<br>  ↓<br>Live weather data<br>  ↓<br>LLM<br>  ↓<br>&quot;Bangalore is currently 27°C and cloudy.&quot;</pre><p>One important thing to understand:</p><p><strong>The LLM itself isn’t directly calling WeatherAPI.</strong></p><p>The LLM tells our application:</p><blockquote><strong>“I want to use the </strong><strong>get_weather tool with Bangalore.”</strong></blockquote><p>Our application executes the function and gives the result back to the LLM.</p><h3>Understanding the Tool Calling Flow</h3><p>The complete process looks like this:</p><pre>User<br>                           │<br>                           ▼<br>                          LLM<br>                           │<br>                  Does it need a tool?<br>                    /             \<br>                  No               Yes<br>                  │                 │<br>                  ▼                 ▼<br>               Answer           Tool Call<br>                                    │<br>                                    ▼<br>                              Your Function<br>                                    │<br>                                    ▼<br>                              External API<br>                                    │<br>                                    ▼<br>                               Tool Result<br>                                    │<br>                                    ▼<br>                                   LLM<br>                                    │<br>                                    ▼<br>                              Final Answer</pre><p>So the LLM first <strong>decides what it needs</strong>, and your application actually <strong>executes the tool</strong>.</p><h3>Creating a Simple Tool</h3><p>Let’s create a basic weather tool:</p><pre>from langchain_core.tools import tool</pre><pre><a href="http://twitter.com/tool">@tool</a><br>def get_weather(city: str):<br>    &quot;&quot;&quot;Get the current weather for a city.&quot;&quot;&quot;</pre><pre># Call weather API</pre><pre>return weather_data</pre><p>From this function, LangChain can understand:</p><pre>Tool:<br>    get_weather</pre><pre>Input:<br>    city</pre><pre>Purpose:<br>    Get the current weather for a city</pre><p>The description is important because it helps the LLM understand <strong>when the tool should be used</strong>.</p><h3>Connecting the Tool to the LLM</h3><p>Creating the tool isn’t enough.</p><p>We also need to tell the model that the tool is available.</p><p>We can do that using:</p><pre>model_with_tools = model.bind_tools(<br>    [get_weather]<br>)</pre><p>You can think of bind_tools() as telling the model:</p><blockquote><strong>“Here are the functions you are allowed to use.”</strong></blockquote><p>Now the model knows that it has access to get_weather.</p><h3>What Happens When the User Asks a Question?</h3><p>Suppose the user asks:</p><blockquote><strong>“What’s the weather in Hyderabad?”</strong></blockquote><p>The LLM understands that it needs current weather information.</p><p>It may generate a tool call like:</p><pre>{<br>  &quot;name&quot;: &quot;get_weather&quot;,<br>  &quot;args&quot;: {<br>    &quot;city&quot;: &quot;Hyderabad&quot;<br>  }<br>}</pre><p>This means:</p><blockquote><strong>“Call </strong><strong>get_weather and pass Hyderabad as the city.”</strong></blockquote><p>Your backend then executes:</p><pre>get_weather(&quot;Hyderabad&quot;)</pre><p>Suppose the WeatherAPI returns:</p><pre>{<br>  &quot;temperature&quot;: 30,<br>  &quot;condition&quot;: &quot;Sunny&quot;<br>}</pre><p>The result is passed back to the LLM.</p><p>The LLM can then generate a natural response:</p><blockquote><strong>“The current temperature in Hyderabad is 30°C and it’s sunny.”</strong></blockquote><h3>Tools Are Not Just for Weather</h3><p>Weather is just a simple example.</p><p>In a real application, you can create tools for many different tasks.</p><p>For example, imagine you’re building an e-commerce application.</p><p>You could create a database tool:</p><pre>from langchain_core.tools import tool<br><br>@tool<br>def get_user(user_id: int):<br>    &quot;&quot;&quot;Get user information from the database.&quot;&quot;&quot;</pre><pre>    return database.get_user(user_id)</pre><p>Now a user could ask:</p><blockquote><strong>“Show me my profile.”</strong></blockquote><p>The LLM could request:</p><pre>get_user(123)</pre><p>Your backend gets the information from the database and sends it back to the LLM.</p><h3>You Can Also Create a Product Search Tool</h3><pre>from langchain_core.tools import tool<br><br>@tool<br>def search_products(query: str):<br>    &quot;&quot;&quot;Search products in the product catalog.&quot;&quot;&quot;</pre><pre>    return product_service.search(query)</pre><p>The user could ask:</p><blockquote><strong>“Find me a wireless keyboard.”</strong></blockquote><p>The LLM could call:</p><pre>search_products(&quot;wireless keyboard&quot;)</pre><p>Your application searches the product catalog and returns the results.</p><p>The LLM can then turn those results into a human-friendly response.</p><h3>The Simple Way to Remember Tools</h3><blockquote><strong>A Tool gives an LLM the ability to interact with something outside of the LLM itself.</strong></blockquote><p>For example:</p><pre>LLM<br>                          │<br>            ┌─────────────┼─────────────┐<br>            │             │             │<br>            ▼             ▼             ▼<br>      Weather Tool   Database Tool   Search Tool<br>            │             │             │<br>            ▼             ▼             ▼<br>       Weather API     Database      Product API</pre><p>Without tools:</p><pre>User → LLM → Answer</pre><p>With tools:</p><pre>User<br> ↓<br>LLM<br> ↓<br>Decides what it needs<br> ↓<br>Tool<br> ↓<br>API / Database / Service<br> ↓<br>Result<br> ↓<br>LLM<br> ↓<br>Final Answer</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ehhZhDD-STxgzR5PlMwHNw.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2260546d9f4b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI, Machine Learning, Deep Learning, and LLMs]]></title>
            <link>https://medium.com/@codewithadurintiashok/ai-machine-learning-deep-learning-and-llms-c0c516cd0fd3?source=rss-2f80c64e21f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/c0c516cd0fd3</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[generative-ai-solution]]></category>
            <dc:creator><![CDATA[Adurinti Ashok]]></dc:creator>
            <pubDate>Wed, 12 Aug 2026 08:20:06 GMT</pubDate>
            <atom:updated>2026-08-13T08:40:17.311Z</atom:updated>
            <content:encoded><![CDATA[<p>AI, ML, Deep Learning and LLMs are often used together, which makes them confusing.</p><p>Let’s understand them in the simplest way possible.</p><h3>What Is <strong>Artificial Intelligence</strong>?</h3><p><strong>Artificial Intelligence(AI)</strong> is the broad idea of making computers behave intelligently.</p><p>For example:</p><ul><li>ChatGPT answering questions</li><li>Computer playing chess</li><li>Voice assistant understanding your request</li></ul><blockquote><strong><em>AI -&gt; Making machines behave intelligently.</em></strong></blockquote><h3>What is Machine Learning?</h3><p><strong>Machine Learning (ML)</strong> is one way of building AI.</p><p>Instead of programming every rule manually, we give the computer data and let it <strong>learn patterns</strong> from that data.</p><p>Imagine building a spam detector.</p><p>Instead of writing:</p><pre>IF email contains &quot;lottery&quot;<br>THEN spam</pre><p>we give the model many examples:</p><pre>Email → Spam<br>Email → Not Spam<br>Email → Spam<br>Email → Not Spam</pre><p>The model learns patterns from these examples and uses them to predict new emails.</p><blockquote><strong><em>ML -&gt; Learning patterns from data.</em></strong></blockquote><h3>Supervised vs Unsupervised Learning</h3><p>Now ML has different ways of learning.</p><h3>Supervised Learning</h3><p>The model learns from data that already has labels or known answers.</p><p>For example:</p><pre>Email → Spam<br>Email → Not Spam</pre><p>The model learns from these answers.</p><blockquote><strong><em>Supervised → Learn with answers.</em></strong></blockquote><h3>Unsupervised Learning</h3><p>Here, we don’t provide answers.</p><p>We simply give the model data and let it <strong>find patterns or groups</strong> by itself.</p><p>For example, an online store could give customer purchase data to an ML model. The model might discover groups of customers who behave similarly.</p><blockquote><strong><em>Unsupervised -&gt; Find patterns and groups.</em></strong></blockquote><h3>Classification vs Regression</h3><p>Both are types of <strong>Supervised Learning</strong>.</p><p><strong>Classification</strong> means predicting a <strong>category</strong>.</p><pre>Email → Spam / Not Spam<br>Image → Cat / Dog<br>Transaction → Fraud / Not Fraud</pre><p><strong>Regression</strong> means predicting a <strong>number</strong>.</p><pre>House → ₹50 Lakhs<br>Temperature → 32°C<br>Sales → ₹10 Lakhs</pre><h3>Where Does Deep Learning Come In?</h3><p><strong>Deep Learning</strong> is a type of Machine Learning that uses <strong>neural networks with many layers</strong>.</p><p>It is especially useful for complex things like:</p><ul><li>Images</li><li>Speech</li><li>Video</li><li>Text</li></ul><h3>What Is an LLM?</h3><p>You may have heard about <strong>LLMs (Large Language Models)</strong> because of ChatGPT, Claude, and Gemini.</p><p>An LLM is a deep-learning model trained on large amounts of text data to learn patterns in language.</p><p>It learns patterns in language and uses those patterns to generate text.</p><p>For example:</p><pre>The capital of India is → Delhi</pre><p>At its core, an LLM predicts the next likely <strong>token (piece of text)</strong> based on what it has learned.</p><blockquote><strong><em>LLM -&gt; </em></strong>Deep Learning model that learns patterns in language and generates text<strong><em>.</em></strong></blockquote><h3>The Big Picture</h3><p>Here’s the simplest way to connect everything:</p><pre>AI<br>│<br>└── Machine Learning<br>    │<br>    ├── Supervised Learning<br>    │   ├── Classification → Category<br>    │   └── Regression → Number<br>    │<br>    └── Unsupervised Learning<br>        └── Find patterns / groups</pre><pre>Deep Learning<br>│<br>└── Neural Networks<br>    │<br>    ├── Images → Computer Vision<br>    ├── Speech → Voice Recognition<br>    └── Language → Language Models<br>                     └── LLMs</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*DSUQsujOuesj6RUpMxZedQ.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c0c516cd0fd3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Git Reset Explained: Understanding --soft, --mixed, and --hard]]></title>
            <link>https://medium.com/@codewithadurintiashok/git-reset-explained-understanding-soft-mixed-and-hard-a16954ef1bc9?source=rss-2f80c64e21f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/a16954ef1bc9</guid>
            <category><![CDATA[git-reset-hard]]></category>
            <category><![CDATA[git-reset-mixed]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[git-reset]]></category>
            <dc:creator><![CDATA[Adurinti Ashok]]></dc:creator>
            <pubDate>Wed, 29 Jul 2026 12:37:12 GMT</pubDate>
            <atom:updated>2026-07-29T12:37:12.135Z</atom:updated>
            <content:encoded><![CDATA[<p>If you’re learning Git, you’ve probably seen these commands:</p><pre>git reset --soft<br>git reset --mixed<br>git reset --hard</pre><p>At first glance, git reset --soft, --mixed, and --hard can seem almost identical. The real difference lies in what each command resets—and once you understand that, Git reset becomes much easier to use.</p><p>Let’s break it down.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*hOxVZE7ytjiviDQptKve1w.png" /></figure><h3>First, understand how Git stores your changes</h3><p>Whenever you work with Git, your changes go through three stages:</p><ul><li><strong>Working Directory</strong> — The files you’re currently editing.</li><li><strong>Staging Area</strong> — The files you’ve added using git add .</li><li><strong>Repository</strong> — The commits you’ve saved using git commit .</li></ul><p>Think of it like this:</p><pre>Working Directory<br>        ↓<br>Staging Area<br>        ↓<br>Git Repository</pre><p>Every git reset command affects one or more of these stages.</p><h3>Let’s use an example</h3><p>Imagine your commit history looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*CROl3ASDrwItr_JyGm4tuA.png" /></figure><p>Now you run:</p><pre>git reset HEAD~1</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*5Yucpsm1bpBxKKDjpGqCvA.png" /></figure><p>Git moves from commit <strong>4d65e81</strong> back to <strong>cbd9efa</strong> (one commit back).</p><p>The only question is: <strong>What happens to your changes?</strong></p><p>That’s where --soft, --mixed, and --hard come in.</p><h3>1. git reset --soft</h3><pre>git reset --soft HEAD~1</pre><p>This is the safest reset.</p><p>It removes the last commit, <strong>but keeps all your changes staged</strong>.</p><p>That means you can make a few more changes and commit again without running git add.</p><h3>Example</h3><p>Before reset:</p><pre>Commit 4d65e81<br>✓ Changes committed</pre><p>After reset:</p><pre>Commit cbd9efa<br>✓ Changes are still staged</pre><p>Nothing is lost.</p><h3>When should you use it?</h3><p>Use it when you committed too early and want to make one better commit.</p><p>For example:</p><ul><li>You forgot to add one file.</li><li>You want to change the commit message.</li><li>You want to combine multiple commits into one.</li></ul><h3>2. git reset --mixed</h3><pre>git reset --mixed HEAD~1</pre><p>This is Git’s <strong>default</strong> reset mode.</p><p>If you simply run:</p><pre>git reset HEAD~1</pre><p>Git automatically uses --mixed.</p><p>It removes the last commit and <strong>unstages your changes</strong>, but your files stay exactly as they are.</p><h3>Example</h3><p>Before reset:</p><pre>Commit 4d65e81<br>✓ Changes staged</pre><p>After reset:</p><pre>Commit cbd9efa<br>✗ Nothing is staged<br>✓ Files are still there</pre><p>You’ll need to stage your files again using:</p><pre>git add .</pre><h3>When should you use it?</h3><p>Use it when you want to review your changes before committing again.</p><h3>3. git reset --hard</h3><pre>git reset --hard HEAD~1</pre><p>This command is very powerful.</p><p>It removes the last commit, clears the staging area, <strong>and deletes your local changes</strong>.</p><h3>Example</h3><p>Before reset:</p><pre>Commit 4d65e81<br>✓ Local changes</pre><p>After reset:</p><pre>Commit cbd9efa<br>✗ Local changes removed</pre><p>Your project goes back to exactly how it looked at commit <strong>B</strong>.</p><p>⚠️ Be careful with this command because uncommitted changes are usually difficult to recover.</p><h3>When should you use it?</h3><p>Use it only when you’re completely sure you don’t need your local changes anymore.</p><h3>Final thoughts</h3><p>git reset isn&#39;t something to be afraid of.</p><p>The key is remembering what each option keeps:</p><ul><li><strong>Soft</strong> → Keeps your changes staged.</li><li><strong>Mixed</strong> → Keeps your changes but unstages them.</li><li><strong>Hard</strong> → Removes everything after the selected commit.</li></ul><p>If you’re ever unsure, start with <strong>--soft</strong> or <strong>--mixed</strong>. Save <strong>--hard</strong> for situations where you&#39;re absolutely sure you want to discard your local work.</p><p>Once you understand these three commands, fixing Git mistakes becomes much less stressful.</p><p>Thanks for reading! Follow me for more articles on software development, Git, and programming.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a16954ef1bc9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What Is the Event Loop in Node.js?]]></title>
            <link>https://medium.com/@codewithadurintiashok/what-is-the-event-loop-in-node-js-fea423788d6f?source=rss-2f80c64e21f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/fea423788d6f</guid>
            <category><![CDATA[events]]></category>
            <category><![CDATA[servers]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[event-loop]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Adurinti Ashok]]></dc:creator>
            <pubDate>Fri, 06 Jun 2025 15:44:46 GMT</pubDate>
            <atom:updated>2025-06-07T09:34:00.443Z</atom:updated>
            <content:encoded><![CDATA[<h3>What Is Event Loop in Node.js?</h3><p>The <strong>event loop</strong> is the brain behind how Node.js handles tasks, especially tasks that take time — like reading a file, calling an API, or talking to a database.</p><p>Node.js runs JavaScript using a single thread. That means it can only do <strong>one thing at a time</strong>. But thanks to the event loop, Node.js <em>feels</em> like it’s doing many things at once</p><p>When Node.js runs a script, here’s what happens:</p><ol><li><strong>Call Stack</strong>: JavaScript code is executed line by line. Each task is added to the <strong>call stack</strong>.</li><li><strong>Offloading to kernel</strong>: If a task is async (like a setTimeout, file read, or HTTP call), Node.js hands it off to the system kernel.</li><li><strong>Callback Queue</strong>: Once the async task is done, its <strong>callback</strong> (a function) is placed in the <strong>callback queue</strong>.</li><li><strong>Event Loop</strong>: The event loop keeps checking — if the call stack is empty, it picks the next task from the callback queue and runs it.</li></ol><p>This is how Node.js continues doing other work while waiting for a long task to finish.</p><p>I made a small app using Bolt.ai to show how the event loop works in Node.js. You can see it in the image</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jwBDLHE2UCoepw-jIv5-UQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fea423788d6f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Streams and Buffers Work in Node.js]]></title>
            <link>https://medium.com/@codewithadurintiashok/how-streams-and-buffers-work-in-node-js-477eb4126f85?source=rss-2f80c64e21f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/477eb4126f85</guid>
            <category><![CDATA[node]]></category>
            <category><![CDATA[servers]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Adurinti Ashok]]></dc:creator>
            <pubDate>Fri, 23 May 2025 15:37:26 GMT</pubDate>
            <atom:updated>2025-05-24T00:26:17.359Z</atom:updated>
            <content:encoded><![CDATA[<h3>How Streams Work in Node.js?</h3><p>If you’re new to Node.js or don’t yet understand streams this article is for you.</p><p>Streams let you transfer data in small pieces from one place to another without running into memory issues. For example, when you watch a YouTube video, your browser asks the server for the file and then plays each chunk as it arrives — rather than waiting for the entire video to download.</p><p><strong>Types of Streams in Node.js</strong></p><p><strong>Readable Streams</strong><br> Readable streams are used to read data in chunks rather than loading the entire content at once.</p><p>Example:</p><pre><br>import fs from &#39;fs&#39;;<br><br>const reader = fs.createReadStream(&#39;testfile.txt&#39;, { encoding: &#39;utf8&#39; });<br><br>reader.on(&#39;data&#39;, (chunk) =&gt; {<br>  console.log(&#39;Received chunk:&#39;, chunk.length, &#39;characters&#39;);<br>});<br><br>reader.on(&#39;end&#39;, () =&gt; {<br>  console.log(&#39;Finished reading file&#39;);<br>});</pre><p><strong>Writable Streams</strong><br> Writable streams are used to write data in chunks rather than writing the entire content to disk in one go.</p><p>Example:</p><pre><br>import fs from &#39;fs&#39;;<br><br>const writer = fs.createWriteStream(&#39;testfile.txt&#39;);<br><br>writer.write(&#39;Hello, &#39;);<br>writer.write(&#39;this is streamed in chunks.\n&#39;);<br>writer.end(() =&gt; {<br>  console.log(&#39;Finished writing to file&#39;);<br>});</pre><p><strong>Duplex Streams </strong><br> Duplex streams can both read and write data in chunks.</p><pre><br>import net from &#39;net&#39;;<br><br>const server = net.createServer((socket) =&gt; {<br><br>  socket.on(&#39;data&#39;, (data) =&gt; {<br>    console.log(&#39;Client sent:&#39;, data.toString());<br>    socket.write(&#39;Echo: &#39; + data);<br>  });<br>});<br><br>server.listen(3000, () =&gt; {<br>  console.log(&#39;Echo server listening on port 3000&#39;);<br>});</pre><p><strong>Transform Streams</strong><br> Transform streams are a special kind of Duplex stream that read data in chunks, modify it, and then write the transformed data in chunks.</p><pre><br>import { Transform } from &#39;stream&#39;;<br><br>const upperCaseTransform = new Transform({<br>  transform(chunk, encoding, callback) {<br><br>    this.push(chunk.toString().toUpperCase());<br>    callback();<br>  }<br>});<br><br><br>process.stdin<br>  .pipe(upperCaseTransform)<br>  .pipe(process.stdout);<br><br>// It reads from the stream, transforms the data to uppercase, then writes it back to the stream</pre><p>That’s all for now. If you have any questions, I’m here to help — just ask after you’ve finished reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=477eb4126f85" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Core Elements in a Relational Database]]></title>
            <link>https://medium.com/@codewithadurintiashok/core-elements-in-a-relational-database-f018b669e72c?source=rss-2f80c64e21f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/f018b669e72c</guid>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[servers]]></category>
            <category><![CDATA[sql]]></category>
            <dc:creator><![CDATA[Adurinti Ashok]]></dc:creator>
            <pubDate>Wed, 10 Jul 2024 11:08:40 GMT</pubDate>
            <atom:updated>2024-07-10T11:08:40.989Z</atom:updated>
            <content:encoded><![CDATA[<p>Have you ever thought about the difference between SQL and MySQL? Yes, there is a difference between them.</p><p><strong>SQL:</strong></p><p>SQL stands for Structured Query Language. The name itself suggests it is a query language used to communicate with databases. SQL itself does not directly interact with databases. Instead, SQL queries are executed by database management systems like MySQL, which interact directly with the database.</p><p><strong>MySQL:</strong></p><p>MySQL is a relational database management system (RDBMS) that uses Structured Query Language (SQL) to manage and manipulate data.</p><p>It is the one that directly interacts with the database stored on the server.</p><p>In summary, SQL provides the language framework for database operations, while MySQL acts as the software that interprets SQL commands and interacts directly with the database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HCsssHuzP4IIbuomaGgjvQ.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f018b669e72c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simplify React Form Validations Using Formik and Yup Libraries]]></title>
            <link>https://medium.com/@codewithadurintiashok/simplify-react-form-validations-using-formik-and-yup-libraries-4f6571fe111f?source=rss-2f80c64e21f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f6571fe111f</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[forms]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Adurinti Ashok]]></dc:creator>
            <pubDate>Fri, 21 Jun 2024 12:37:37 GMT</pubDate>
            <atom:updated>2024-06-21T12:37:37.597Z</atom:updated>
            <content:encoded><![CDATA[<p>Sometimes, implementing validations in React applications can be quite frustrating. I’ve recently explored this area and discovered two libraries: Formik and Yup.</p><p>Formik: Formik is an open-source library that helps manage state (think of it this way: when you modify the field content, it automatically updates the value of the field) and handle form submissions.</p><p>Yup: Yup is another open-source library that simplifies validations efficiently.</p><p>When you consider building any form with validations, achieving this with minimal code can seem impossible compared to other methods. The goal of using these libraries is to leverage existing solutions. If someone has already done the job, why should we start from scratch? Let’s use these tools to make the process simpler and more precise</p><p>Let me explain using the code I implemented for the registration page as follows:</p><pre>import React from &#39;react&#39;;<br>import { Formik, Field, Form, ErrorMessage } from &#39;formik&#39;;<br>import * as Yup from &#39;yup&#39;;<br><br>const RegistrationPage= () =&gt; {<br><br>  const initialValues = {<br>    name: &#39;&#39;,<br>    email: &#39;&#39;,<br>    password: &#39;&#39;,<br>    confirmPassword: &#39;&#39;<br>  };<br><br>  const validationSchema = Yup.object().shape({<br>    name: Yup.string()<br>      .min(2, &#39;Too Short!&#39;)<br>      .max(20, &#39;Too Long!&#39;)<br>      .required(&#39;Required&#39;),<br>    email: Yup.string()<br>      .email(&#39;Invalid email&#39;)<br>      .required(&#39;Required&#39;),<br>    password: Yup.string()<br>      .min(8, &#39;Password must be at least 8 characters&#39;)<br>      .required(&#39;Required&#39;),<br>    confirmPassword: Yup.string()<br>      .oneOf([Yup.ref(&#39;password&#39;), null], &#39;Passwords must match&#39;)<br>      .required(&#39;Required&#39;)<br>  });<br><br>  const handleSubmit = (values, { setSubmitting }) =&gt; {<br>         console.log(values)<br>         setSubmitting(false)<br>  };<br><br>  return (<br>    &lt;div className=&quot;container mt-5&quot;&gt;<br>      &lt;h1&gt;Register&lt;/h1&gt;<br>      &lt;Formik<br>        initialValues={initialValues}<br>        validationSchema={validationSchema}<br>        onSubmit={handleSubmit}<br>      &gt;<br>        {({ isSubmitting }) =&gt; (<br>          &lt;Form&gt;<br>            &lt;div className=&quot;mb-3&quot;&gt;<br>              &lt;label htmlFor=&quot;name&quot; className=&quot;form-label&quot;&gt;Name&lt;/label&gt;<br>              &lt;Field type=&quot;text&quot; name=&quot;name&quot; className=&quot;form-control&quot; /&gt;<br>              &lt;ErrorMessage name=&quot;name&quot;  className=&quot;alert alert-danger&quot; /&gt;<br>            &lt;/div&gt;<br>            &lt;div className=&quot;mb-3&quot;&gt;<br>              &lt;label htmlFor=&quot;email&quot; className=&quot;form-label&quot;&gt;Email&lt;/label&gt;<br>              &lt;Field type=&quot;email&quot; name=&quot;email&quot; className=&quot;form-control&quot; /&gt;<br>              &lt;ErrorMessage name=&quot;email&quot;  className=&quot;alert alert-danger&quot; /&gt;<br>            &lt;/div&gt;<br>            &lt;div className=&quot;mb-3&quot;&gt;<br>              &lt;label htmlFor=&quot;password&quot; className=&quot;form-label&quot;&gt;Password&lt;/label&gt;<br>              &lt;Field type=&quot;password&quot; name=&quot;password&quot; className=&quot;form-control&quot; /&gt;<br>              &lt;ErrorMessage name=&quot;password&quot;  className=&quot;alert alert-danger&quot; /&gt;<br>            &lt;/div&gt;<br>            &lt;div className=&quot;mb-3&quot;&gt;<br>              &lt;label htmlFor=&quot;confirmPassword&quot; className=&quot;form-label&quot;&gt;Confirm Password&lt;/label&gt;<br>              &lt;Field type=&quot;password&quot; name=&quot;confirmPassword&quot; className=&quot;form-control&quot; /&gt;<br>              &lt;ErrorMessage name=&quot;confirmPassword&quot;  className=&quot;alert alert-danger&quot; /&gt;<br>            &lt;/div&gt;<br>            &lt;button type=&quot;submit&quot; className=&quot;btn btn-primary&quot; disabled={isSubmitting}&gt;<br>              Submit<br>            &lt;/button&gt;<br>          &lt;/Form&gt;<br>        )}<br>      &lt;/Formik&gt;<br>    &lt;/div&gt;<br>  );<br>};<br><br>export default RegistrationPage;</pre><p>Now, let me explain the properties and functions I have defined in the code above:</p><p>The Formik tag wraps all the code and manages the state of each field within it. The initialValues sets the default values for all fields. The validationSchema is used to validate each field using Yup. We define a schema in which we write our logic based on our requirements. The handleSubmit function is triggered when the form is submitted. isSubmitting property helps to disable the button when there are issues in the form or if any field is not filled properly.The setSubmitting function is used to change the state that controls whether the submit button is enabled or disabled based on its boolean value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*41yKu7fJopaKXW7ow5yLOw.jpeg" /></figure><p>Note:<strong>Utilize open resources, verify their integrity, and apply them.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f6571fe111f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Integration of Gemini AI In React]]></title>
            <link>https://medium.com/@codewithadurintiashok/integration-of-gemini-ai-in-react-8872025088de?source=rss-2f80c64e21f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/8872025088de</guid>
            <category><![CDATA[gemini]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[front-end-development]]></category>
            <dc:creator><![CDATA[Adurinti Ashok]]></dc:creator>
            <pubDate>Tue, 07 May 2024 15:23:43 GMT</pubDate>
            <atom:updated>2024-05-07T18:53:35.734Z</atom:updated>
            <content:encoded><![CDATA[<p>You all know about Gemini AI tool, If you’re not familiar, Gemini AI is an AI tool developed by Google.In this article, I’ll guide you through the process of integrating Gemini AI into your React application.</p><p>step-1 : Install following npm package in your react application</p><pre>npm i @google/generative-ai</pre><p>We need Developer API key to use Gemini AI in our Application.To generate a developer API key, click on the following link and create one. Once generated, copy it to a secure location within your system for further use in the application.</p><p><a href="https://aistudio.google.com/app/apikey">aistudio.google.com</a></p><pre>import { GoogleGenerativeAI } from &#39;@google/generative-ai&#39;;</pre><p>Import above module in your component at top level and paste following code snippet within your component and pass your API key to it.</p><pre> const genAI = new GoogleGenerativeAI(<br>    &quot;API KEY&quot;<br>  );</pre><p>In the provided code snippet, we’re initializing an instance of GoogleGenerativeAI by passing an API key. Once object is created, we have access to the functionalities it offers.</p><p>Gemini AI Resolves our queries and answers to all our questions. To engage with Gemini AI, we simply need to provide an input message, also known as a prompt.</p><pre>  const [inputValue, setInputValue] = useState(&#39;&#39;); <br><br><br>   const handleInputChange = (e) =&gt; {<br>    setInputValue(e.target.value);<br>  };<br><br>&lt;input<br>       type=&quot;text&quot;<br>       value={inputValue}<br>       onChange={handleInputChange}<br>       placeholder=&quot;Ask Me Something You Want&quot;<br>       className=&quot;input-field&quot;<br>     /&gt;</pre><p>In above code snippet we are reading input from the user and updating it to a state (think like a variable) called inputValue.</p><pre>const [promptResponses, setpromptResponses] = useState([]);<br><br>const getResponseForGivenPrompt= async () =&gt; {<br>try{<br>  const model = genAI.getGenerativeModel({ model: &quot;gemini-pro&quot; });<br>  const result = await model.generateContent(inputValue);<br>  const response = await result.response;<br>  const text = await response.text();<br>  setpromptResponses([<br>    ...promptResponses,<br>    text<br>  ]);<br>}<br>catch(error){<br>  console.log(&quot;Something Went Wrong&quot;);<br>}<br>  }<br>};<br><br>&lt;button onClick={getResponseForGivenPrompt}&gt;Send&lt;/button&gt;</pre><p>When you click on the send button after entering inputMessage or Your Prompt, it triggers a function called getResponseForGivenPrompt. In this function, we get a model and use it to call the generateContent method, passing a prompt or inputMessage to it. This method generates the content or answer for our Prompt or input Message. The result is then updated to a state variable called promptResponses.</p><pre>{promptResponses.map((promptResponse, index) =&gt; (<br>  &lt;div key={index} &gt;<br>    &lt;div &gt;{promptResponse}&lt;/div&gt;<br>  &lt;/div&gt;<br>))}</pre><p>The code snippet iterates through the `promptResponses` array, displaying each response in the UI.</p><p>Here is The Complete Code</p><pre>import React, { useState } from &#39;react&#39;;<br>import { GoogleGenerativeAI } from &#39;@google/generative-ai&#39;;<br>function GeminiInReact() {<br>  const [inputValue, setInputValue] = useState(&#39;&#39;);<br>  const [promptResponses, setpromptResponses] = useState([]);<br>  const [loading, setLoading] = useState(false);<br>  const genAI = new GoogleGenerativeAI(<br>    &quot;API KEY&quot;<br>// add your api key here<br>  );<br>  const handleInputChange = (e) =&gt; {<br>    setInputValue(e.target.value);<br>  };<br>  const getResponseForGivenPrompt = async () =&gt; {<br>    try {<br>      setLoading(true)<br>      const model = genAI.getGenerativeModel({ model: &quot;gemini-pro&quot; });<br>      const result = await model.generateContent(inputValue);<br>      setInputValue(&#39;&#39;)<br>      const response = result.response;<br>      const text = response.text();<br>      console.log(text)<br>      setpromptResponses([...promptResponses,text]);<br>  <br>      setLoading(false)<br>    }<br>    catch (error) {<br>      console.log(error)<br>      console.log(&quot;Something Went Wrong&quot;);<br>      setLoading(false)<br>    }<br>  }<br>    ;<br><br>  return (<br>    &lt;div className=&quot;container&quot;&gt;<br>    &lt;div className=&quot;row&quot;&gt;<br>      &lt;div className=&quot;col&quot;&gt;<br>        &lt;input<br>          type=&quot;text&quot;<br>          value={inputValue}<br>          onChange={handleInputChange}<br>          placeholder=&quot;Ask Me Something You Want&quot;<br>          className=&quot;form-control&quot;<br>        /&gt;<br>      &lt;/div&gt;<br>      &lt;div className=&quot;col-auto&quot;&gt;<br>        &lt;button onClick={getResponseForGivenPrompt} className=&quot;btn btn-primary&quot;&gt;Send&lt;/button&gt;<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>    {loading ? (<br>      &lt;div className=&quot;text-center mt-3&quot;&gt;<br>        &lt;div className=&quot;spinner-border text-primary&quot; role=&quot;status&quot;&gt;<br>          &lt;span className=&quot;visually-hidden&quot;&gt;Loading...&lt;/span&gt;<br>       // This message is shown while your answer to your prompt is being generated<br>        &lt;/div&gt;<br>      &lt;/div&gt;<br>    ) : (<br>      promptResponses.map((promptResponse, index) =&gt; (<br>        &lt;div key={index} &gt;<br>          &lt;div className={`response-text ${index === promptResponses.length - 1 ? &#39;fw-bold&#39; : &#39;&#39;}`}&gt;{promptResponse}&lt;/div&gt;<br>     //the latest response shown in bold letters<br>        &lt;/div&gt;<br>      ))<br>    )}<br>  &lt;/div&gt;<br>  <br>  );<br><br>}<br>export default GeminiInReact;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S5f2cI5dlsDnLYyiIq6bUg.jpeg" /></figure><p>If you have any doubts, feel free to comment on this article, and I’ll be happy to respond to you :)</p><p><strong>— — —Ashok Adurinti</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8872025088de" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>