Today I Learned

2025

Decorators in Python

Python Decorators

Decorators are a way we can use higher order functions to modify other functions. Typically they are used to wrap a function with another function.


def hello(name="Ian"):
    def greeting(func):
        def wrapper(*args, **kwargs):
            print("A man is sitting at the bar, you go up and greet him.")

            if name == "Ian":
                print("My name is Ian, what's yours?")
            else:
                print(f"My name is {name}, what's yours?")

            print("The man glances your way momentarily, then moves to the other end of the bar.")
            result = func(*args, **kwargs)
            return result
        return wrapper
    return greeting

@hello("Alice")
def bar_talk():
    print("You start a conversation about the weather with the bartender instead.")

@hello()
def another_chat():
    print("You shrug your shoulders and ask the bartender about the local sports team.")


print("=== First Interaction ===")
bar_talk()

print("\n=== Second Interaction ===")
another_chat()

In the example above, you would get the following print out:

Read more →

RAG

What is RAG?

If you’ve been trying to keep up with AI, there’s a good chance you’ve come across the term RAG. When I first learned heard the term, I wasn’t exactly sure what it meant form the context of the discussion.

Retrieval-Augmented Generation (RAG) is a technique that enhances the accuracy of large language models (LLMs) by giving them a wider context window and including external (from the LLM’s database) knowledge sources.

Read more →

Agentic AI

Agentic AI

Agentic AI is essentially giving AI a specific job that it will execute on a regular basis and giving it the autonomy to do so.

There are five main categories of agentic AI today:

  1. Simple Reflex
  2. Model-Based Reflex
  3. Goal-Based
  4. Utility-Based
  5. Learning

Simple Reflex Agents

The most basic agentic AI models are reactive and are built to analyze an input from the environment then use condition based logic/rules to make a decision on what to do next. For instance, your thermostat has a sensor that evaluates the temperature of the air (environmental input) and checks it against the conditional rules (if the temp is above 72 degrees F, then turn on cooling until it reaches 72 degrees). Once it evaluates the data against the conditional logic, it performs an action.

Read more →