Capstone: Build an AI Agent

30 min Advanced Prerequisite: Deployment

Kyun seekhna hai?

Capstone project se sab kuch apply karo � complete AI agent banao with tools, memory, planning. Ye tumhara final project hai!

Agent Components

FULL AGENT

Complete system jisme sab kuch ho � tools, memory, planning, aur response generation.

TOOLS

Real capabilities jo agent ke paas hain � search, calculate, teach jaise functions.

MEMORY

Persistent storage jo past conversations yaad rakhta hai context ke liye.

DEPLOY

Production ready banana � real users tak pahunchana apne agent ko.

Code Example

Ye hai complete AI Agent implementation:

# Complete AI Agent
class DSWallahAgent:
 def __init__(self):
 self.name = "DSWallah Bot"
 self.memory = []
 self.tools = {
 "search": self.search,
 "calculate": self.calculate,
 "teach": self.teach
 }
 
 def search(self, query):
 return f"Searching for: {query}"
 
 def calculate(self, expr):
 try:
 return str(eval(expr))
 except:
 return "Invalid expression"
 
 def teach(self, topic):
 return f"Teaching about: {topic}"
 
 def think(self, task):
 # Simple planning
 if "search" in task:
 return "search"
 elif "calculate" in task:
 return "calculate"
 elif "teach" in task or "learn" in task:
 return "teach"
 return None
 
 def respond(self, message):
 self.memory.append({"user": message})
 tool = self.think(message.lower())
 if tool and tool in self.tools:
 result = self.tools[tool](message)
 self.memory.append({"bot": result})
 return result
 return "I can search, calculate, or teach. What would you like?"
 
 def get_history(self):
 return self.memory

# Test agent
agent = DSWallahAgent()
print(agent.respond("Search for Python tutorials"))
print(agent.respond("Calculate 2 + 2"))
print(agent.respond("Teach me about AI"))
print(agent.get_history())

Interactive Editor

Apna khud ka AI agent build karo � components add karo aur test karo!


 

Exercise

Complete agent ke 4 components batao.