0
0
Agentic_aiml~5 mins

Why agents represent the next AI paradigm in Agentic Ai

Choose your learning style8 modes available
Introduction

Agents are smart programs that can think and act on their own. They help AI do more complex tasks by making decisions step-by-step, like a helpful assistant.

When you want AI to handle tasks that need planning and adapting, like booking a trip with many steps.
When AI needs to interact with people or other systems over time, like a chatbot that remembers past talks.
When solving problems that change or have many parts, like managing a smart home with many devices.
When you want AI to learn from experience and improve its actions, like a game-playing AI that gets better each time.
Syntax
Agentic_ai
class Agent:
    def __init__(self, environment):
        self.environment = environment

    def perceive(self):
        # Get information from environment
        pass

    def decide(self):
        # Choose an action based on perception
        pass

    def act(self):
        # Perform the chosen action
        pass

    def run(self):
        while not self.environment.is_done():
            self.perceive()
            self.decide()
            self.act()

An agent works by perceiving its surroundings, deciding what to do, and then acting.

This loop continues until the task is complete or stopped.

Examples
This example shows the basic steps an agent takes: see, decide, and act.
Agentic_ai
class SimpleAgent:
    def perceive(self):
        print('Seeing environment')

    def decide(self):
        print('Deciding next step')

    def act(self):
        print('Taking action')

agent = SimpleAgent()
agent.perceive()
agent.decide()
agent.act()
This agent learns from new information and decides actions based on what it learned.
Agentic_ai
class LearningAgent:
    def __init__(self):
        self.knowledge = []

    def perceive(self, data):
        self.knowledge.append(data)

    def decide(self):
        return 'action based on ' + str(self.knowledge[-1])

    def act(self, action):
        print(f'Performing {action}')

agent = LearningAgent()
agent.perceive('new info')
action = agent.decide()
agent.act(action)
Sample Program

This program shows a simple agent interacting with an environment. The agent perceives the state, decides an action, and acts. It repeats this until the environment signals it is done.

Agentic_ai
class Environment:
    def __init__(self):
        self.steps = 0
        self.max_steps = 3

    def is_done(self):
        return self.steps >= self.max_steps

    def get_state(self):
        return f'State at step {self.steps}'

    def update(self):
        self.steps += 1

class Agent:
    def __init__(self, environment):
        self.environment = environment

    def perceive(self):
        state = self.environment.get_state()
        print(f'Perceiving: {state}')
        return state

    def decide(self, state):
        action = f'Action based on {state}'
        print(f'Deciding: {action}')
        return action

    def act(self, action):
        print(f'Acting: {action}')
        self.environment.update()

    def run(self):
        while not self.environment.is_done():
            state = self.perceive()
            action = self.decide(state)
            self.act(action)

env = Environment()
agent = Agent(env)
agent.run()
OutputSuccess
Important Notes

Agents help AI handle tasks that need multiple steps and decisions.

They can learn and adapt, making AI smarter over time.

Understanding agents is key to building advanced AI systems.

Summary

Agents are programs that perceive, decide, and act to solve tasks.

They represent a new way AI can work by planning and adapting.

Using agents helps AI handle complex, changing problems better.