01 Python Agent Framework
agentic-ai01-intro-to-ai-agentsai-agents-frameworkcode_samplesagentic-RAGagentic-frameworksemantic-kernelmicrosoft-ai-agents-for-beginnersgenerative-aiai-agentsautogen
Export
π 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 orchestratorOpenAIChatClient: GitHub Models API client wrapperget_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:
- Sign up for GitHub Models access
- Generate a personal access token
- Configure environment variables as shown above
π Usage Instructions
Execute the cells below in sequence to:
- Import required libraries and load environment variables
- Define the random destination generator tool
- Create and configure the AI agent
- Run travel planning requests and view results
Let's build an intelligent travel planning assistant! π
[ ]
[ ]
[ ]
[ ]
[ ]
[ ]
[ ]
[ ]
[ ]
[ ]