• unwind ai
  • Posts
  • Build an AI Teaching Agent Team

Build an AI Teaching Agent Team

Fully functional AI agent app with step-by-step instructions (100% opensource)

LLMs are great at generating educational content and learning roadmaps, but they struggle with complex, multi-step workflows. While you could ask an LLM to create a curriculum, then separately ask it to design exercises, then manually compile resources – this process is tedious and requires constant human coordination.

In this tutorial, we'll solve this by building an AI Teaching Agent Team. Instead of isolated tasks, our AI agents work together like a real teaching faculty: one creates comprehensive knowledge bases, another designs learning paths, a third curates resources, and a fourth develops practice materials.

The user just needs to provide a topic. Everything is automatically saved and organized in Google Docs, creating a seamless learning experience without manual overhead.

We are using Phidata and Composio to build our AI agents. Phidata is specifically designed for building and orchestrating AI agents. It provides the infrastructure for agent communication, memory management, and tool integration.

Composio is a powerful tool that connects AI agents with external services like Google Docs, Gmail, and GitHub. It handles authentication, manages connections, and provides a secure way for our agents to get the work done.

Don’t forget to share this tutorial on your social channels and tag Unwind AI (X, LinkedIn, Threads, Facebook) to support us!

What We’re Building

This Streamlit application brings together a team of specialized AI teaching agents who collaborate like a professional teaching faculty. Each agent acts as a specialized educator: a curriculum designer, learning path expert, resource librarian, and practice instructor - working together to create a complete educational experience through Google Docs.

🪄 Meet your AI Teaching Agent Team
  1. 🧠 Professor Agent

    • Creates fundamental knowledge base in Google Docs

    • Organizes content with proper headings and sections

    • Includes detailed explanations and examples

    • Output: Comprehensive knowledge base document with table of contents

  2. 🗺️ Academic Advisor Agent

    • Designs learning path in a structured Google Doc

    • Creates progressive milestone markers

    • Includes time estimates and prerequisites

    • Output: Visual roadmap document with clear progression paths

  3. 📚 Research Librarian Agent

    • Compiles resources in an organized Google Doc

    • Includes links to academic papers and tutorials

    • Adds descriptions and difficulty levels

    • Output: Categorized resource list with quality ratings

  4. ✍️ Teaching Assistant Agent

    • Develops exercises in an interactive Google Doc

    • Creates structured practice sections

    • Includes solution guides

    • Output: Complete practice workbook with answers

Prerequisites

Before we begin, make sure you have the following:

  1. Python installed on your machine (version 3.10 or higher is recommended)

  2. Your OpenAI and Composio API Key (instructions below)

  3. A code editor of your choice (we recommend VS Code or PyCharm for their excellent Python support)

  4. Basic familiarity with Python programming

Step-by-Step Instructions

Setting Up the Environment

First, let's get our development environment ready:

  1. Clone the GitHub repository:

git clone https://github.com/Shubhamsaboo/awesome-llm-apps.git
  1. Go to the ai_teaching_agent_team folder:

cd ai_agent_tutorials/ai_teaching_agent_team
pip install -r requirements.txt
  1. Get your API Key: You'll need to obtain:

    • OpenAI API key - Create a new account > Go to Dashboard > Navigate to API Keys > Generate a new key

    • Composio API key - Create an account on Composio Platform. (IMPORTANT) To use the app, you need to make a new connection ID with Google Docs and Composio. Follow the steps below:

      • composio add googledocs (in the Terminal)

      • Create a new connection > Select OAUTH2 > Select Google Account > Done.

      • In the Composio Dashboard on the website, go to Apps > Navigate to Googledocs tool > Click create integration (violet button) > click Try connecting default’s googldocs button and we are done.

Creating the Streamlit App

Let’s create our app. Create a new file teaching_agent_team.py and add the following code:

  1. Let's set up our imports:

    • Phidata for creating and orchestrating AI agents

    • Composio for connecting AI agents with Google Docs

    • Streamlit as the UI

    • GPT-4o as the LLM

    • Serp for web search

    • ArXiv toolkit to search for publications on Arxiv

import streamlit as st
from phi.agent import Agent, RunResponse
from phi.model.openai import OpenAIChat
from composio_phidata import Action, ComposioToolSet
import os
from phi.tools.arxiv_toolkit import ArxivToolkit
from phi.utils.pprint import pprint_run_response
from phi.tools.serpapi_tools import SerpApiTools
  1. Initialize session state and API configuration:

st.set_page_config(page_title="👨‍🏫 AI Teaching Agent Team")

# Initialize session state
if 'openai_api_key' not in st.session_state:
    st.session_state['openai_api_key'] = ''
if 'composio_api_key' not in st.session_state:
    st.session_state['composio_api_key'] = ''
if 'serpapi_api_key' not in st.session_state:
    st.session_state['serpapi_api_key'] = ''
  1. Set up Composio tools:

composio_toolset = ComposioToolSet(api_key=st.session_state['composio_api_key'])
google_docs_tool = composio_toolset.get_tools(
    actions=[Action.GOOGLEDOCS_CREATE_DOCUMENT]
)[0]
google_docs_tool_update = composio_toolset.get_tools(
    actions=[Action.GOOGLEDOCS_UPDATE_EXISTING_DOCUMENT]
)[0]
  1. Create the Professor Agent:

professor_agent = Agent(
    name="Professor",
    role="Research and Knowledge Specialist", 
    model=OpenAIChat(id="gpt-4o-mini"),
    tools=[google_docs_tool],
    instructions=[
        "Create comprehensive knowledge base",
        "Explain from first principles",
        "Include key terminology",
        "Create formatted Google Doc"
    ]
)
  1. Create the Academic Advisor Agent:

academic_advisor_agent = Agent(
    name="Academic Advisor",
    role="Learning Path Designer",
    model=OpenAIChat(id="gpt-4o-mini"),
    tools=[google_docs_tool],
    instructions=[
        "Create detailed learning roadmap",
        "Break down into subtopics",
        "Include time estimates",
        "Create formatted Google Doc"
    ]
)
  1. Create the Research Librarian Agent:

research_librarian_agent = Agent(
    name="Research Librarian",
    role="Learning Resource Specialist",
    model=OpenAIChat(id="gpt-4o-mini"),
    tools=[
        google_docs_tool, 
        SerpApiTools(api_key=st.session_state['serpapi_api_key'])
    ],
    instructions=[
        "Find quality learning resources",
        "Use SerpApi for searches",
        "Include various resource types",
        "Create curated Google Doc"
    ]
)
  1. Create the Teaching Assistant Agent:

teaching_assistant_agent = Agent(
    name="Teaching Assistant",
    role="Exercise Creator",
    model=OpenAIChat(id="gpt-4o-mini"),
    tools=[google_docs_tool, SerpApiTools()],
    instructions=[
        "Create practice materials",
        "Include progressive exercises",
        "Add real-world applications",
        "Create Google Doc with solutions"
    ]
)
  1. Set up Streamlit interface:

with st.sidebar:
    st.title("API Keys Configuration")
    st.session_state['openai_api_key'] = st.text_input(
        "OpenAI API Key", 
        type="password"
    )
    st.session_state['composio_api_key'] = st.text_input(
        "Composio API Key",
        type="password"
    )
    st.session_state['serpapi_api_key'] = st.text_input(
        "SerpAPI Key",
        type="password"
    )
  1. Implement topic processing:

topic = st.text_input(
    "Enter topic:",
    placeholder="e.g., Machine Learning"
)

if st.button("Start"):
    with st.spinner("Generating Knowledge Base..."):
        professor_response = professor_agent.run(
            f"topic: {topic}"
        )
    # Similar blocks for other agents
  1. Extract Google Doc links:

def extract_google_doc_link(response_content):
    if "https://docs.google.com" in response_content:
        return response_content.split("https://docs.google.com")[1].split()[0]
    return None

st.markdown("### Google Doc Links:")
if professor_doc_link:
    st.markdown(f"- **Professor Document:** [View](https://docs.google.com{professor_doc_link})")
  1. Display agent responses:

st.markdown("### Professor Response:")
st.markdown(professor_response.content)
pprint_run_response(professor_response, markdown=True)

# Similar blocks for other agents
  1. Error handling and validation:

if not st.session_state['openai_api_key'] or not st.session_state['composio_api_key']:
    st.error("Please enter all required API keys.")
    st.stop()

try:
    composio_toolset = ComposioToolSet(api_key=st.session_state['composio_api_key'])
except Exception as e:
    st.error(f"Error initializing ComposioToolSet: {e}")
    st.stop()
  1. Progress tracking:

with st.spinner("Creating Practice Materials..."):
    teaching_assistant_response = teaching_assistant_agent.run(
        f"topic: {topic}"
    )

Running the App

With our code in place, it's time to launch the app.

  • In your terminal, navigate to the project folder, and run the following command

streamlit run teaching_agent_team.py

Working Application Demo

Conclusion

You've built a powerful AI Teaching Agent Team that can create comprehensive learning materials for any topic.

Consider these enhancements to make your teaching team even more effective:

  • Include interactive coding exercises for technical topics

  • Add support for multiple learning styles

  • Implement progress tracking and analytics

  • Implement version control for Google Docs to track content evolution

Keep experimenting and refining to build smarter AI solutions!

We share hands-on tutorials like this 2-3 times a week, to help you stay ahead in the world of AI. If you're serious about leveling up your AI skills and staying ahead of the curve, subscribe now and be the first to access our latest tutorials.

Don’t forget to share this tutorial on your social channels and tag Unwind AI (X, LinkedIn, Threads, Facebook) to support us!

Reply

or to participate.