houston-ai-tour is a repository that demonstrates the generation and deployment of agents using the Azure OpenAI Agents SDK. This project includes multiple agent examples to get started with AI Foundry. Start using Semantic Kernel for building agents. Example also includes a Agent Generator that creates agents based on natural language specifications and provides sample implementations for various agent types such as basic hello world, Research, and Customer Service agents. Extend it with tools, enterprise APIs and Azure AI services.
- Overview
- Setup and Configuration
- Directory Structure
- Running the Sample Code
- Agent Generator Guide
- Agent Testing
- Troubleshooting
- Contributing
- License
This repository provides:
- Interactive Notebooks: Jupyter Notebooks that offer a step-by-step, interactive experience to explore and understand the agent generation process and underlying code.
- Agent Generator: A meta agent capable of generating code for various specialized agents based on specifications.
- Sample Agents: Example agents such as the WeatherAgent, ResearchAgent, and CustomerServiceAgent which demonstrate usage of the generator.
- Testing Scripts: Automated tests (e.g.,
12_test_agent_generator.py) that verify the correct generation and functionality of the agents.
The repository includes interactive Jupyter Notebooks that help you:
- Explore the agent generation process in a hands-on manner.
- See live demonstrations of how the Agent Generator and sample agents work.
- Modify and execute code in an interactive environment to better understand the functionalities of each component.
Key Python files in the repository include:
- agent_generator.py: Contains the core logic for parsing specifications and generating agent code.
- 12_test_agent_generator.py: A test script designed to validate and test the generated agents under multiple scenarios.
- Other Python files are either generated as samples (e.g.,
weather_agent.py,research_agent.py,customer_service_agent.py) or provide supporting functionality for agent tasks and guardrails.
-
Clone the Repo:
git clone https://github.com/yourusername/houston-ai-tour.git cd houston-ai-tour -
Environment Variables:
-
Create a
.envfile in the repository root. -
Add your Azure OpenAI API key:
AZURE_OPENAI_API_KEY=your-api-key AZURE_OPENAI_DEPLOYMENT=your-deployment-name
-
-
Install Dependencies:
-
Use pip to install required packages:
pip install -r requirements.txt
-
Ensure
nest_asynciois installed as it is used to run asynchronous code in a notebook-style environment.
-
houston-ai-tour/
├── 12_test_agent_generator.py # Test script to validate agent generation
├── agent_generator.py # Core code for generating agents based on specifications
├── readme.md # This file
└── ... # Other sample files, tools, and agents
To run the test script for generating agents:
python 12_test_agent_generator.pyThis script will execute tests for different agent specifications (Weather, Research, Customer Service). Successful tests will save the generated agent code to corresponding Python files (e.g., weather_agent.py) and print a summary of the results.
The Agent Generator (agent_generator.py) takes a natural language specification and produces:
- Main Code: The core implementation (
main_code) for the generated agent. - Additional Files: Tools, output types, and guardrails that are stored in separate files.
- Runner Code: A script to execute and interact with the generated agent.
- Specification Parsing: The generator reads the specification and extracts:
- Agent name
- Instructions
- Tools required (e.g.,
get_weather,get_forecast) - Output type definition and guardrails
- Code Generation: Based on the parsed specification, the generator creates:
- Tool implementations
- Output type classes (using Pydantic’s
BaseModel) - Guardrail functions to validate input/output
- Agent creation code which wires everything together using the Azure OpenAI Agents SDK.
- File Generation: The generated code is saved to a dedicated directory along with individual files for tools, output types, guardrails, and runner code.
The test script (12_test_agent_generator.py) runs through multiple agent generation scenarios:
- Weather Agent: Validates the generated weather agent and saves the generated code to
weather_agent.py. - Research and Customer Service Agents: Additional tests ensure the robustness of the generation process.
If you encounter errors mentioning missing attributes (e.g., additional_files), verify that the AgentCode class in agent_generator.py includes all required attributes and that you’re returning a complete AgentCode instance.
- API Key Issues: Ensure that
AZURE_OPENAI_API_KEYis set in your environment or.envfile. - Syntax Errors: If you face any syntax errors, double-check the generated code sections referenced by line numbers in the error trace.
- Agent Handoff: If handoffs between agents aren’t working as expected, review the instructions in the triage agent.
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Write tests to cover your changes.
- Submit a pull request with a detailed description.
This project is licensed under the MIT License. See the LICENSE file for details.