<?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 Aqsa Hussain on Medium]]></title>
        <description><![CDATA[Stories by Aqsa Hussain on Medium]]></description>
        <link>https://medium.com/@aqsahussain214_90367?source=rss-512e66c5e4ee------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Qh30jBGVhY-_tgYyZT_8-A.jpeg</url>
            <title>Stories by Aqsa Hussain on Medium</title>
            <link>https://medium.com/@aqsahussain214_90367?source=rss-512e66c5e4ee------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 16:38:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@aqsahussain214_90367/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[SOLID PRINCIPLES]]></title>
            <link>https://medium.com/@aqsahussain214_90367/solid-principles-0edd57d6e794?source=rss-512e66c5e4ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/0edd57d6e794</guid>
            <dc:creator><![CDATA[Aqsa Hussain]]></dc:creator>
            <pubDate>Sun, 26 Jan 2025 14:21:12 GMT</pubDate>
            <atom:updated>2025-01-26T14:29:11.768Z</atom:updated>
            <content:encoded><![CDATA[<p>Designing robust, maintainable, and scalable software is a challenge that every developer faces. The SOLID principles, a cornerstone of object-oriented programming, provide a proven framework for achieving these goals. In this article, we’ll explore how these principles can help you write cleaner and more flexible code.</p><h4>S: Single Responsibility Principle (SRP)</h4><p>Each class should focus on a single responsibility or functionality. If a class has multiple responsibilities, changes to one responsibility may affect the others, leading to fragile code.</p><p>In the example below, each class is handling exactly one task which fulfills the single responsibility principle.</p><pre>public class ReportGenerator<br>{<br>    public void GenerateReport() { Console.WriteLine(&quot;Report Generated&quot;); }<br>}<br><br>public class ReportSaver<br>{<br>    public void SaveToDatabase() { Console.WriteLine(&quot;Report Saved&quot;); }<br>}<br><br>public class ReportPrinter<br>{<br>    public void PrintReport() { Console.WriteLine(&quot;Report Printed&quot;); }<br>}</pre><h4><strong>O: Open-Closed Principle (OCP)</strong></h4><p>Software entities (classes, modules, functions) should be open for extension but closed for modification.</p><p>In the example below, we are close for any modification to existing shapes and open for adding any new shapes with their implementation.</p><pre>public abstract class Shape<br>{<br>    public abstract double CalculateArea();<br>}<br><br>public class Circle : Shape<br>{<br>    private readonly double _radius;<br><br>    public Circle(double radius)<br>    {<br>        _radius = radius;<br>    }<br><br>    public override double CalculateArea()<br>    {<br>        return Math.PI * _radius * _radius; <br>    }<br>}<br><br>public class Rectangle : Shape<br>{<br>    private readonly double _length;<br>    private readonly double _width;<br><br>    public Rectangle(double length, double width)<br>    {<br>        _length = length;<br>        _width = width;<br>    }<br><br>    public override double CalculateArea()<br>    {<br>        return _length * _width; <br>    }<br>}<br><br>public class AreaCalculator<br>{<br>    public double CalculateArea(Shape shape) =&gt; shape.CalculateArea();<br>}</pre><h4>L: Liskov Substitution Principle (LSP)</h4><p>Subtypes must be substitutable for their base types without altering the correctness of the program.</p><p><strong><em>Incorrect:</em></strong></p><pre>public class Bird<br>{<br>    public virtual void Fly() { /* Flying logic */ }<br>}<br><br>public class Ostrich : Bird<br>{<br>    public override void Fly() { throw new NotImplementedException(); }<br>}</pre><p><strong><em>Correct:</em></strong></p><pre>public abstract class Bird<br>{<br>    public abstract void Move();<br>}<br><br>public class Sparrow : Bird<br>{<br>    public override void Move()<br>    {<br>        Console.WriteLine(&quot;The sparrow is flying gracefully in the sky.&quot;);<br>    }<br>}<br><br>public class Ostrich : Bird<br>{<br>    public override void Move()<br>    {<br>        Console.WriteLine(&quot;The ostrich is running swiftly across the ground.&quot;);<br>    }<br>}<br><br>public class BirdMover<br>{<br>    public void MoveBird(Bird bird)<br>    {<br>        bird.Move();<br>    }<br>}</pre><h4><strong>I: Interface Segregation Principle (ISP)</strong></h4><p>A class should not be forced to implement interfaces it does not use.</p><pre>public interface ISwimmingAnimal<br>{<br>    void Swim();<br>}<br><br>public interface IFlyingAnimal<br>{<br>    void Fly();<br>}<br><br>public class Dog : ISwimmingAnimal<br>{<br>    public void Swim() { Console.WriteLine(&quot;Swimming&quot;); }<br>}</pre><h4><strong>D: Dependency Inversion Principle (DIP)</strong></h4><p>The <strong>Dependency Inversion Principle (DIP)</strong> is about decoupling high-level modules (business logic) from low-level modules (details like database or third-party services). Instead of the high-level module directly depending on the implementation details, both should depend on abstractions, typically defined through interfaces or abstract classes.</p><ul><li><strong>High-Level Modules</strong>: These are classes or components that contain the core business logic of your application. They define the “what” of the system.</li></ul><p>Example: A NotificationService that sends notifications.</p><ul><li><strong>Low-Level Modules</strong>: These are classes or components that deal with implementation details, like connecting to a database, sending emails, or making API calls. They define the “how.”</li><li>Example: An EmailService or SmsService.</li></ul><pre>// Abstraction (Interface)<br>public interface INotificationSender<br>{<br>    void Send(string message);<br>}<br><br>// Low-Level Module: EmailService<br>public class EmailService : INotificationSender<br>{<br>    public void Send(string message)<br>    {<br>        Console.WriteLine($&quot;Email sent: {message}&quot;);<br>    }<br>}<br><br>// Low-Level Module: SmsService<br>public class SmsService : INotificationSender<br>{<br>    public void Send(string message)<br>    {<br>        Console.WriteLine($&quot;SMS sent: {message}&quot;);<br>    }<br>}<br><br>// High-Level Module: NotificationService<br>public class NotificationService<br>{<br>    private readonly INotificationSender _notificationSender;<br><br>    public NotificationService(INotificationSender notificationSender)<br>    {<br>        _notificationSender = notificationSender;<br>    }<br><br>    public void Notify(string message)<br>    {<br>        _notificationSender.Send(message);<br>    }<br>}</pre><p>Thankyou!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0edd57d6e794" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Repository Pattern with a Step-by-Step Code Walkthrough]]></title>
            <link>https://medium.com/@aqsahussain214_90367/understanding-repository-pattern-with-a-step-by-step-code-walkthrough-1adc451bbfa4?source=rss-512e66c5e4ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/1adc451bbfa4</guid>
            <dc:creator><![CDATA[Aqsa Hussain]]></dc:creator>
            <pubDate>Sat, 25 Jan 2025 15:43:13 GMT</pubDate>
            <atom:updated>2025-01-25T15:43:13.621Z</atom:updated>
            <content:encoded><![CDATA[<p>The <strong>Repository Pattern</strong> is a common design pattern in software development used to separate the data access logic from the business logic of an application. Let’s break down the provided code step-by-step to understand its components and how they interact.</p><h4><strong>Step 1: The Repository Interface</strong></h4><p>It defines the contract for any repository implementation handling Product data.</p><pre>public interface IProductRepository<br>{<br>    Product GetProductById(int id);<br>    IEnumerable&lt;Product&gt; GetAllProducts();<br>}</pre><h4>Step 2: The Repository Implementation</h4><p>It implements IProductRepository interface by adding dependency of DbContext for db calls.</p><pre>public class ProductRepository : IProductRepository<br>{<br>    private readonly DbContext _context;<br><br>    public ProductRepository(DbContext context)<br>    {<br>        _context = context;<br>    }<br><br>    public Product GetProductById(int id)<br>    {<br>        return _context.Products.Find(id);<br>    }<br><br>    public IEnumerable&lt;Product&gt; GetAllProducts()<br>    {<br>        return _context.Products.ToList();<br>    }<br>}</pre><h4><strong>Step 3: Using the Repository in a Service</strong></h4><p>The ProductService consumes the repository to retrieve product data and focuses on business logic, such as displaying product names, without concerning itself with database operations.</p><pre>public class ProductService<br>{<br>    private readonly IProductRepository _productRepository;<br><br>    public ProductService(IProductRepository productRepository)<br>    {<br>        _productRepository = productRepository;<br>    }<br><br>    public void DisplayAllProducts()<br>    {<br>        var products = _productRepository.GetAllProducts();<br>        foreach (var product in products)<br>        {<br>            Console.WriteLine(product.Name);<br>        }<br>    }<br>}</pre><h4>Bringing Everything Together</h4><p>The ProductRepository and ProductService are instantiated and used together to display product names. The design ensures a clean separation between data access (ProductRepository) and business logic (ProductService), while leveraging dependency injection for flexibility.</p><pre>class Program<br>{<br>    static void Main(string[] args)<br>    {<br>        var context = new DbContext();<br>        IProductRepository productRepository = new ProductRepository(context);<br>        var productService = new ProductService(productRepository);<br>        productService.DisplayAllProducts();<br>    }<br>}</pre><p>Thankyou!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1adc451bbfa4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Agentic AI: The Future of Decision-Making Machines]]></title>
            <link>https://medium.com/@aqsahussain214_90367/agentic-ai-the-future-of-decision-making-machines-b5e199917851?source=rss-512e66c5e4ee------2</link>
            <guid isPermaLink="false">https://medium.com/p/b5e199917851</guid>
            <category><![CDATA[phidata]]></category>
            <category><![CDATA[llama-3]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Aqsa Hussain]]></dc:creator>
            <pubDate>Sun, 19 Jan 2025 14:59:37 GMT</pubDate>
            <atom:updated>2025-01-19T15:44:19.328Z</atom:updated>
            <content:encoded><![CDATA[<p>Agentic AI is all about action — it adapts to challenges, pursues goals on its own, and gets things done. It’s a big leap toward a future where machines don’t just help us out but actually make decisions and take action in complex, ever-changing environments.</p><p>Several widely used frameworks for creating agents include:</p><ul><li><strong>CreAI</strong>: Independent tool for building autonomous agents, focused on ease of use and integration.</li><li><strong>LangChain</strong>: Framework by LangChain Inc. for building AI agents with LLMs and modular components.</li><li><strong>Microsoft Autogen</strong>: A Microsoft tool for creating enterprise-level autonomous agents, leveraging Azure and OpenAI.</li><li><strong>Phidata API</strong>: API-driven platform by Phaidata Inc. for data-centric autonomous agents focused on structured and unstructured data.</li></ul><h4>Let’s jump in and make our first agent splash!</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hJ1RZkc42feqAKMK" /><figcaption>Photo by <a href="https://unsplash.com/@nate_dumlao?utm_source=medium&amp;utm_medium=referral">Nathan Dumlao</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Prerequisites</h3><ul><li>Python installed on your system</li><li>PyCharm IDE (or any preferred Python IDE)</li><li>Basic understanding of Python</li></ul><h3>Step-by-Step Guide</h3><h3>1. Environment Setup</h3><p>Create a new environment in PyCharm and install the Phidata library. Phidata is a framework that simplifies working with various AI models through straightforward API calls:</p><pre>pip install phidata<br>pip install duckduckgo-search<br>pip install yfinance<br>pip install groq</pre><h3>2. API Key Setup</h3><ol><li>Visit <a href="https://console.groq.com/keys">Groq’s Console</a> to generate your API key</li><li>Create a .env file in your project directory</li><li>Add your API key:</li></ol><pre>GROQ_API_KEY=your_api_key_here</pre><h3>3. Project Structure</h3><p>Create a new Python file (e.g., stock_agent.py) and import the necessary dependencies:</p><pre>from phi.agent import Agent<br>from phi.model.groq import Groq<br>from dotenv import load_dotenv<br>from phi.storage.agent.base import AgentStorage<br>from phi.tools.yfinance import YFinanceTools</pre><h3>4. Creating the Financial Agent</h3><p>Now, let’s build our agent that uses Llama 3.3 through Groq’s API:</p><pre>load_dotenv()<br><br>agent = Agent(<br>    model=Groq(id=&quot;llama-3.3-70b-versatile&quot;),<br>    tools=[YFinanceTools(<br>        stock_price=True,<br>        analyst_recommendations=True,<br>        stock_fundamentals=True<br>    )],<br>    show_tool_calls=True,<br>    markdown=True,<br>    instructions=[&quot;Use tables to display data.&quot;],<br>    debug_mode=True<br>)<br><br>agent.print_response(<br>    &quot;Summarize and compare analyst recommendations and fundamentals for TSLA and NVIDIA&quot;<br>)</pre><p>Let’s break down the key components:</p><ul><li>load_dotenv(): Loads our environment variables, including the API key</li><li>Agent: The main class that coordinates between the model and tools</li><li>Groq: Specifies we&#39;re using Llama 3.3 through Groq&#39;s API</li><li>YFinanceTools: Provides access to Yahoo Finance data</li><li>show_tool_calls: Displays API calls for transparency</li><li>markdown: Formats output in markdown</li><li>debug_mode: Shows detailed execution information</li></ul><p>Llama leverages function docstrings as a guide to match user queries with the most relevant function capabilities. These built-in descriptions help the model understand and choose the right tool for each task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*GAatk0rKC_pVYrlMdeELJA.png" /></figure><h3>5. Running the Agent</h3><p>On running the agent.py file, we get detailed logs of step by step execution as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yMJF1h7_8RY109jV_aMRVA.png" /><figcaption>get_analyst_recommendations is the function in YFinanceTools class that is called by the agent</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*FkWTc58jZkHpzjiy4N4xjA.png" /><figcaption>JSON data response</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*olZEsTu9LUSd_oKdC96ziA.png" /><figcaption>Output</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/1*HLACc3v3gQ2O0CvozpBjAg.png" /><figcaption>Output</figcaption></figure><h3><strong>Create a team of agents</strong></h3><p>This code creates a collaborative agent system where a lead agent_team coordinates between two specialists: finance_agent for stock analysis and web_agent for news gathering. When queried about NVIDIA, it seamlessly combines financial insights and current news by directing tasks to the appropriate specialized agent.</p><pre>from phi.agent import Agent<br>from phi.model.groq import Groq<br>from phi.tools.duckduckgo import DuckDuckGo<br>from phi.tools.yfinance import YFinanceTools<br>from dotenv import load_dotenv<br><br>load_dotenv()<br><br>web_agent = Agent(<br>    name=&quot;Web Agent&quot;,<br>    model=Groq(id=&quot;llama-3.3-70b-versatile&quot;),<br>    tools=[DuckDuckGo()],<br>    instructions=[&quot;Always include sources&quot;],<br>    show_tool_calls=True,<br>    markdown=True<br>)<br><br>finance_agent = Agent(<br>    name=&quot;Finance Agent&quot;,<br>    role=&quot;Get financial data&quot;,<br>    model=Groq(id=&quot;llama-3.3-70b-versatile&quot;),<br>    tools=[YFinanceTools(stock_price=True, analyst_recommendations=True, company_info=True)],<br>    instructions=[&quot;Use tables to display data&quot;],<br>    show_tool_calls=True,<br>    markdown=True,<br>)<br><br>agent_team = Agent(<br>    model=Groq(id=&quot;llama-3.3-70b-versatile&quot;),<br>    team=[web_agent, finance_agent],<br>    instructions=[&quot;Always include sources&quot;, &quot;Use tables to display data&quot;],<br>    show_tool_calls=True,<br>    markdown=True,<br>)<br><br>agent_team.print_response(&quot;Summarize analyst recommendations and share the latest news for NVIDA&quot;, stream=True)</pre><h3>Conclusion:</h3><p>AI agents are undoubtedly powerful, but their performance heavily depends on the LLM model being utilized. In my case, I used Llama 3.3, an open-source model, which wasn’t consistently accurate. Other LLM models could potentially serve as better alternatives.</p><p><strong><em>Credits:</em></strong><em> This project was inspired by AI Agents Tutorial by codebasics on YouTube </em><a href="https://www.youtube.com/watch?v=EUey9L9sgzE"><em>https://www.youtube.com/watch?v=EUey9L9sgzE</em></a><em>.</em></p><p><strong><em>Other resources:</em></strong></p><ul><li><a href="https://docs.phidata.com/agent-ui">Agent UI - Phidata</a></li><li><a href="https://console.groq.com/playground">GroqCloud</a></li></ul><p><strong>Thank you!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b5e199917851" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>