Skip to content

bhakthan/houston-ai-tour

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

houston-ai-tour

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.

Table of Contents

Overview

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.

Notebooks Overview

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.

Python Files Overview

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.

Setup and Configuration

  1. Clone the Repo:

    git clone https://github.com/yourusername/houston-ai-tour.git
    cd houston-ai-tour
  2. Environment Variables:

    • Create a .env file in the repository root.

    • Add your Azure OpenAI API key:

      AZURE_OPENAI_API_KEY=your-api-key
      AZURE_OPENAI_DEPLOYMENT=your-deployment-name
      
  3. Install Dependencies:

    • Use pip to install required packages:

      pip install -r requirements.txt
    • Ensure nest_asyncio is installed as it is used to run asynchronous code in a notebook-style environment.

Directory Structure

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

Running the Sample Code

To run the test script for generating agents:

python 12_test_agent_generator.py

This 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.

Agent Generator Guide

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.

How It Works

  1. 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
  2. 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.
  3. File Generation: The generated code is saved to a dedicated directory along with individual files for tools, output types, guardrails, and runner code.

Agent Testing

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.

Troubleshooting

  • API Key Issues: Ensure that AZURE_OPENAI_API_KEY is set in your environment or .env file.
  • 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.

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Write tests to cover your changes.
  4. Submit a pull request with a detailed description.

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

Houston AI Tour Demo Assets, Notebooks, Code

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors