learn agentic ai panaverseagentic ai in urdu

New to Agentic AI? This course is your complete guide to building intelligent agents using Python and FastAPI. Explore the DACA (Dapr Agentic Cloud Ascent) pattern in simple terms, and build real-world AI-powered apps step-by-step. No prior experience needed — just your curiosity and a willingness to build smart systems from scratch to scale.

openai agents sdk quiz answers


the above quiz contains openai agents sdk quiz answers helpful for giaic and piaic students specially designed by sir zia khan panaversity.

Topic 1: Agentic AI Hello World + FastAPI Setup | GET & POST API

✨ Introduction

Aaj hum seekhne wale hain ke FastAPI ke zariye web APIs kaise banai jaati hain, aur unmein GET aur POST method ka kya role hota hai.

Ye tutorial bilkul beginner level students ke liye hai jo programming ya web development ka safar shuru kar rahe hain.

📌 FastAPI Kya Hai?

FastAPI ek modern aur fast Python framework hai jo web APIs banane ke liye use hota hai. Ye asynchronous hota hai, isliye kaafi fast kaam karta hai.


📁 Folder Structure

Aap ka project folder kuch is tarah ka hoga:

fastapi-project/
└── main.py

▶️ Server Ko Run Karna

Terminal mein jaake yeh command likhein: uvicorn main:app --reload

Phir browser mein open karein: http://127.0.0.1:8000

✅ GET Method Kya Karta Hai?

  • Jab bhi aap kisi URL ko browser mein likhte hain, aap ek GET request bhej rahe hote hain.
  • Hamare example mein:
GET http://127.0.0.1:8000/

Response:

{
  "message": "Hello World."
}

🧾 main.py ka Full Code video sy dekheya.

agentic ai in urdu

Aaj ki video mein hum dekhein ge ke Pydantic kya hota hai, ye FastAPI ke sath kaise use hota hai, aur kaise hum nested models, validation, aur response schemas define karte hain using Pydantic.

Topic 2: FastAPI + Pydantic Step-by-Step Tutorial

Ye tutorial specially un logon ke liye hai jo Agentic AI ya FastAPI projects par kaam kar rahe hain, jaise ke DACA chatbot. Chaliye shuru karte hain

🛠️ Step 1: Pydantic ka Introduction

Sab se pehle, Pydantic ek Python library hai jo data validation aur type safety ke liye use hoti hai.

Iska kaam hai ke jo bhi data hamare API mein aaye, usko check kare — kya sahi type ka hai, required fields hain ya nahi, aur agar koi galti hai to error throw kare

🔍 Key Features:

✔️ Type-Safe Validation (str, int, list etc.)
✔️ Automatic Type Conversion
✔️ Detailed Error Handling
✔️ Nested Models ka support
✔️ JSON Serialization
✔️ Custom Validators

🧪 Step 2: Setup aur Example 1

Ab hum code example se samjhte hain. Pehle hum ek project create karein

uv init fastdca_p1
cd fastdca_p1
uv venv
source .venv/bin/activate
uv add "fastapi[standard]"

Phir ek file banayein: pydantic_example_1.py

from pydantic import BaseModel, ValidationError

# Ek simple model define kar rahe hain
class User(BaseModel):
    id: int
    name: str
    email: str
    age: int | None = None  # Optional field

# ✅ Valid data
user_data = {"id": 1, "name": "Alice", "email": "alice@example.com", "age": 25}
user = User(**user_data)
print(user)
print(user.model_dump())

# ❌ Invalid data
try:
    invalid_user = User(id="not_an_int", name="Bob", email="bob@example.com")
except ValidationError as e:
    print(e)

Jab aap uv run python pydantic_example_1.py run karein, aapko valid data ka output milega, aur invalid data par ek validation error dikhai dega.

🧱 Step 3: Nested Models ka Example

Pydantic mein hum complex ya nested models bhi define kar sakte hain. Let’s try this:

from pydantic import BaseModel, EmailStr

# Address ek nested model hai
class Address(BaseModel):
    street: str
    city: str
    zip_code: str

# User ke andar Address ka list aa raha hai
class UserWithAddress(BaseModel):
    id: int
    name: str
    email: EmailStr
    addresses: list[Address]

# ✅ Valid nested data
user_data = {
    "id": 2,
    "name": "Bob",
    "email": "bob@example.com",
    "addresses": [
        {"street": "123 Main St", "city": "New York", "zip_code": "10001"},
        {"street": "456 Oak Ave", "city": "Los Angeles", "zip_code": "90001"},
    ],
}
user = UserWithAddress.model_validate(user_data)
print(user.model_dump())

Aap dekh rahe hain ke hum easily list of objects handle kar rahe hain — ye AI workflows mein bohat useful hota hai.


🛑 Step 4: Custom Validator

Ab ek custom validation lagate hain ke user ka name kam az kam 2 characters ka ho:

from pydantic import BaseModel, EmailStr, validator, ValidationError
from typing import List

class Address(BaseModel):
    street: str
    city: str
    zip_code: str

class UserWithAddress(BaseModel):
    id: int
    name: str
    email: EmailStr
    addresses: List[Address]

    @validator("name")
    def name_must_be_at_least_two_chars(cls, v):
        if len(v) < 2:
            raise ValueError("Name must be at least 2 characters long")
        return v

# ❌ Invalid name test
try:
    invalid_user = UserWithAddress(
        id=3,
        name="A",
        email="charlie@example.com",
        addresses=[{"street": "789 Pine Rd", "city": "Chicago", "zip_code": "60601"}],
    )
except ValidationError as e:
    print(e)

Output mein aapko custom error message dikhai dega. Ye validation AI agents ke liye zaroori hai jahan user input strict hona chahiye.


🤖 Step 5: Final FastAPI App — Agentic Chatbot

Ab hum full FastAPI app banate hain jahan nested metadata aur message models hain:

📁 File: main.py

from fastapi import FastAPI, HTTPException
from pydantic import BaseModel, Field
from datetime import datetime, UTC
from uuid import uuid4

app = FastAPI(
    title="DACA Chatbot API",
    description="A FastAPI-based API for a chatbot in the DACA tutorial series",
    version="0.1.0",
)

# Metadata model with timestamp and UUID
class Metadata(BaseModel):
    timestamp: datetime = Field(default_factory=lambda: datetime.now(tz=UTC))
    session_id: str = Field(default_factory=lambda: str(uuid4()))

# Request message model
class Message(BaseModel):
    user_id: str
    text: str
    metadata: Metadata
    tags: list[str] | None = None

# Response model
class Response(BaseModel):
    user_id: str
    reply: str
    metadata: Metadata

# Root endpoint
@app.get("/")
async def root():
    return {"message": "Welcome to the DACA Chatbot API! Access /docs for the API documentation."}

# GET endpoint
@app.get("/users/{user_id}")
async def get_user(user_id: str, role: str | None = None):
    return {"user_id": user_id, "role": role if role else "guest"}

# POST endpoint
@app.post("/chat/", response_model=Response)
async def chat(message: Message):
    if not message.text.strip():
        raise HTTPException(status_code=400, detail="Message text cannot be empty")
    reply_text = f"Hello, {message.user_id}! You said: '{message.text}'. How can I assist you today?"
    return Response(user_id=message.user_id, reply=reply_text, metadata=Metadata())

Jab aap fastapi dev main.py chalate hain, aap /docs par Swagger UI mein apna API dekh sakte hain — proper validation ke sath.

To students, aapne dekha kaise humne basic Pydantic se le kar FastAPI ke andar nested models tak ka complete flow cover kiya. Ye agentic AI apps jaise DACA mein backbone ka kaam karta hai.

Topic 3: Python Uv + FastAPI: Python Variables se Task Tracker Banayein (Step-by-Step Guide)

Agentic AI mein agents apni state ko variables ke zariye track karte hain. Agar aap beginner hain aur FastAPI seekh rahe hain, to aaj hum ek simple project karenge jisme Python variables se tasks ka status track karenge aur FastAPI endpoints se unhe complete karenge.

Step 1: FastAPI Install Karna

Sab se pehle apne system mein FastAPI aur Uvicorn install karen:

pip install fastapi uvicorn
  • FastAPI: Python framework APIs banane ke liye
  • Uvicorn: Server chalane ke liye

Step 2: Python Code Likhein (Task Tracker API)

Ab ek Python file banayen, jaise agentic_task_tracker.py, aur niche code likhein:

from fastapi import FastAPI

app = FastAPI()

# Agent ke tasks ko track karne ke liye variables
task1_completed = False
task2_completed = False
task3_completed = False

@app.get("/")
def read_root():
    return {"message": "Welcome to Agentic AI Task Tracker!"}

@app.get("/status")
def get_status():
    return {
        "task1_completed": task1_completed,
        "task2_completed": task2_completed,
        "task3_completed": task3_completed,
    }

@app.post("/complete_task/{task_id}")
def complete_task(task_id: int):
    global task1_completed, task2_completed, task3_completed

    if task_id == 1:
        task1_completed = True
        return {"message": "Task 1 completed."}
    elif task_id == 2:
        if not task1_completed:
            return {"error": "Task 1 must be completed first."}
        task2_completed = True
        return {"message": "Task 2 completed."}
    elif task_id == 3:
        if not task2_completed:
            return {"error": "Task 2 must be completed first."}
        task3_completed = True
        return {"message": "Task 3 completed."}
    else:
        return {"error": "Invalid task ID."}

Explanation:

  • Humne 3 variables banaye jo tasks ke completion ko track karte hain.
  • /status endpoint current completion status batata hai.
  • /complete_task/{task_id} POST request se specific task complete hota hai.
  • Tasks ko sequence mein complete karna zaroori hai, warna error aati hai.

Step 3: Server Chalana

Terminal mein yeh command run karein:

uvicorn agentic_task_tracker:app --reload
  • agentic_task_tracker Python file ka naam hai.
  • app FastAPI instance ka naam hai.
  • --reload se code mein changes par server automatically reload hoga.

Step 4: API Endpoints Test Karna

1. Welcome message

Browser ya Postman mein URL dal kar GET request bhejein: http://127.0.0.1:8000

Tasks ka status check karna

GET request: http://127.0.0.1:8000/status

Conclusion

Aaj humne seekha:

  • Python variables se Agentic AI ke tasks track karna
  • FastAPI mein GET aur POST endpoints banana
  • Sequence mein tasks complete karna aur validation karna
  • Common error aur uska solution

Aap is project ko extend karke zyada tasks ya complex logic add kar sakte hain!

agenti ai n urdu

Project 1: Translator Agent using Gemini 1.5 Flash and Chainlit – Build Your Own AI Translator

In this exciting project, we build a real-time Translator Agent using Gemini 1.5 Flash, Chainlit, and Python. This AI-powered chatbot can translate any text into multiple languages with the help of Google’s Gemini model, offering speed and accuracy like never before.

🚀 Why This Project?

  • ✅ Uses the powerful Gemini 1.5 Flash model via LiteLLM
  • ✅ Built with Chainlit for a sleek and interactive chat interface
  • ✅ Supports chat history and saves it as JSON
  • ✅ Simple, fast, and customizable for beginners and pros

🛠️ Key Features:

  • 🌍 Multi-language Translation
  • 💬 Real-time Chat UI with Chainlit
  • 🔐 Secure API key handling with .env
  • 💾 Automatic chat history saving
  • ⚡ Fast responses powered by Gemini Flash model

👨‍💻 Tech Stack:

  • Python
  • Chainlit
  • Gemini 1.5 Flash
  • LiteLLM
  • dotenv

This project is perfect for anyone interested in building real-world AI tools using the latest LLMs. Whether you’re a student, AI enthusiast, or developer, this is a great hands-on way to explore the power of Google Gemini in your own applications.

📂 Use Case: Ideal for learning AI integration, building NLP tools, or enhancing multilingual apps.

Project 2: Build a Gemini AI Agent Using UV

Objective

  • Initialize a UV Python project (as in Task 1).
  • Use Google’s Gemini API through the openai-agents client.
  • Create a simple agent that responds to basic questions.

1. Initialize the UV Project

Follow the steps from Task 1 to create and activate a new UV project.

uv init my-gemini-agent
cd my-gemini-agent

2. Install Dependencies

Install the required Python packages:

uv add openai-agents
uv add python-dotenv
  • openai-agents: Structured framework for building AI agents (compatible with Gemini).
  • python-dotenv: Loads environment variables from a .env file.

3. Configure Environment Variables

Create a .env file in the project root and add your Gemini API key:

GEMINI_API_KEY=your_api_key_here

4. Create the Agent Script

Create a new file (e.g., main.py) with the following content:

base_url=”https://generativelanguage.googleapis.com/v1beta/openai/”,

5. Run the Script

Execute your script with UV

uv run main.py

6. Code Explanation

  • dotenv.load_dotenv(): Loads environment variables from .env.
  • AsyncOpenAI: Connects to the Gemini API endpoint with your key.
  • OpenAIChatCompletionsModel: Wraps the Gemini model (gemini-2.0-flash-exp).
  • Agent: Defines a conversational agent with given name and behavior.
  • Runner.run_sync(): Runs the agent synchronously and returns the final output.

Feel free to customize the instructions, model choice, or input prompts to explore more advanced use cases.

Topic : Runner in OpenAI Agents SDK | Step-by-Step Tutorial with Real Example

n this video, we’ll break down the Runner in the OpenAI Agents SDK — the most essential function to run your AI agents.

You’ll learn:
✅ What Runner.run() does
✅ How it powers your agents behind the scenes
✅ How to pass input, get output, and manage agent context

Topic : OpenAI Agents SDK: Master the handoff() Function with Real Example

In this video, you’ll learn what handoff() is, how it works in multi-agent systems, and why it’s crucial for building smart, modular AI workflows. We’ll break everything down in a simple, beginner-friendly way with a real code example — explained line-by-line in plain language.

💡 What you’ll learn:

  • What is the handoff() function?
  • How does it transfer tasks between agents?
  • What is the difference between parent and child agents?
  • Complete working code with easy explanations

Topic : guardrails in openai agents sdk | input & output guardrails with example

Want to secure your OpenAI agents from malicious or unwanted inputs?
In this tutorial, we explain Guardrails in the OpenAI Agents SDK — both Input Guardrails and Output Guardrails — in a simple, beginner-friendly way!

You’ll learn:
✅ What Guardrails are
✅ What are Tripwires
✅ How to block math questions using input guardrails
✅ How to monitor agent output using output guardrails

Unlock the Power of AI: Build Your Personal Study Assistant in Just 20 Minutes

For students of GIAIC and PIAIC, mastering the integration of AI into everyday tasks can be a game-changer. Our latest tutorial, “Build Your Own Personal Study AI Assistant in 20 Minutes,” is designed to equip you with the skills to create a powerful AI tool using Python, FastAPI, and OpenAI Agents

OpenAI Agents SDK Projects

Project 1: Personal Study Assistant

Description: Build an AI agent system that helps students manage their study schedules, find relevant resources, and summarize academic content. The system will consist of multiple agents working together: a scheduler, a web researcher, and a summarizer.

Directions for Students:

  1. Define the Agents:
    • Create a “Scheduler Agent” to take user input (e.g., study topics and deadlines) and generate a study plan.
    • Create a “Research Agent” to search the web for articles, videos, or papers related to the study topics.
    • Create a “Summarizer Agent” to condense the research findings into concise notes.
  2. Set Up Inputs:
    • Design a simple interface (e.g., command-line or text-based) where users can input their study goals and time constraints.
  3. Configure Tools:
    • Use the built-in web search tool in the Responses API to enable the Research Agent to fetch real-time information.
    • Allow the Summarizer Agent to process text from web results or uploaded files (e.g., PDFs).
  4. Implement Handoffs:
    • Ensure the Scheduler Agent passes the study topics to the Research Agent, which then hands off the collected data to the Summarizer Agent.
  5. Add Guardrails:
    • Add checks to ensure the web search results are relevant (e.g., filter out non-academic sources) and the summaries are concise (e.g., limit word count).
  6. Test and Debug:
    • Test the system with sample inputs like “Learn about machine learning by next week” and use the SDK’s tracing tools to monitor agent interactions.
  7. Enhance the Project:
    • Add a feature to save the study plan and summaries to a file for later use.

Who Should Watch:

This tutorial is ideal for students and developers eager to expand their knowledge in AI and web development. Whether you’re looking to enhance your study sessions or explore new tech integrations, this guide offers valuable insights and hands-on experience.

Leave a Reply

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.