Notebooks
M
Microsoft
01 Python Agent Framework

01 Python Agent Framework

agentic-ai01-intro-to-ai-agentsai-agents-frameworkcode_samplesagentic-RAGagentic-frameworksemantic-kernelmicrosoft-ai-agents-for-beginnersgenerative-aiai-agentsautogen

🐍 AI Travel Agent with Microsoft Agent Framework (Python)

πŸ“‹ Scenario Overview

This notebook demonstrates how to build an intelligent travel planning agent using the Microsoft Agent Framework for Python. The agent leverages GitHub Models to automatically generate personalized day-trip itineraries for random destinations worldwide.

Key Features:

  • 🎲 Smart Destination Selection: Custom tool function for random destination picking
  • πŸ—ΊοΈ Detailed Itinerary Generation: AI-powered travel planning with local recommendations
  • πŸ”„ Async Processing: Uses asyncio for efficient API communication
  • πŸ› οΈ Tool Integration: Demonstrates function calling capabilities in AI agents

πŸ—οΈ Technical Implementation

Core Components

  • Agent Framework: Python implementation of Microsoft's agent orchestration system
  • GitHub Models API: Access to state-of-the-art language models via GitHub's inference service
  • OpenAI Compatibility: Uses OpenAI client patterns with GitHub Models backend
  • Environment Management: Secure credential handling with python-dotenv

Architecture Flow

User Request β†’ ChatAgent β†’ GitHub Models API ↔ get_random_destination()
                     ↓
              Travel Itinerary Response

Key Classes & Methods

  • ChatAgent: Main conversational agent orchestrator
  • OpenAIChatClient: GitHub Models API client wrapper
  • get_random_destination(): Custom tool function for destination selection
  • Environment variables: Secure API configuration management

βš™οΈ Prerequisites & Setup

Required Dependencies:


pip install agent-framework-core -U

Environment Configuration (.env file):

GITHUB_TOKEN=your_github_personal_access_token
GITHUB_ENDPOINT=https://models.inference.ai.azure.com
GITHUB_MODEL_ID=gpt-4o-mini

GitHub Models Access:

  1. Sign up for GitHub Models access
  2. Generate a personal access token
  3. Configure environment variables as shown above

πŸš€ Usage Instructions

Execute the cells below in sequence to:

  1. Import required libraries and load environment variables
  2. Define the random destination generator tool
  3. Create and configure the AI agent
  4. Run travel planning requests and view results

Let's build an intelligent travel planning assistant! 🌟

[ ]
[ ]
[ ]
[ ]
[ ]
[ ]
[ ]
[ ]
[ ]
[ ]