How I built an AI Python tutor with the GitHub Copilot SDK
By GitHub
Key Concepts
- GitHub Copilot SDK: A software development kit allowing integration of AI coding assistance into applications.
- Large Language Models (LLMs): AI models like Claude Sonnet 4.5 and GPT-5 used for generating text and code.
- System Message: A prompt defining the behavior and persona of an AI agent. Crucial for controlling the AI’s responses.
- AI Tutor/Coding Assistant: An AI designed to help users learn to code through guidance, hints, and debugging assistance, rather than providing direct solutions.
- UI/UX Best Practices: Guidelines for designing user interfaces and user experiences that are intuitive, efficient, and enjoyable.
- Column-Based UI Structure: The platform's UI is structured into columns, with one for the code editor and another for the AI tutor interface.
Integrating AI Tutoring into a Python Learning Platform
This project details the development of a practice platform for Python learners, leveraging the GitHub Copilot SDK to integrate an AI coding assistant. The goal is to provide support to viewers of Python tutorials who practice exercises independently and encounter difficulties without immediate access to the instructor.
The Problem & Proposed Solution
April, a Python livestream instructor, observed that viewers often get stuck while practicing exercises after her streams. Without immediate assistance, this can hinder the learning process. To address this, she is building a platform with pre-loaded exercises and integrating an AI tutor using the GitHub Copilot SDK to provide on-demand support.
Initial Prototype & Error Scenario
The initial prototype features a task – writing a function find_max to return the largest number in a list. A deliberately flawed solution, initializing max_num to zero, is presented. Running this code with negative numbers demonstrates the error: it incorrectly identifies zero as the maximum. This scenario highlights the need for an AI assistant to guide learners through debugging and problem-solving. As April states, “I’m trying to fill that gap by providing this AI tutor assistant.”
Agent Setup & Model Selection
The initial step involved isolating the agent setup to ensure proper functionality. The core components are:
- Client & Session Creation: Establishing a connection to the Copilot service.
- Model Selection: Claude Sonnet 4.5 was chosen as the preferred LLM, but the system is designed to support other models like GPT-5.
- System Message Definition: This is a critical element. The system message instructs the AI to act as a Python tutor, emphasizing guidance through hints and questions rather than direct answers. The prompt specifies a “friendly, encouraging tone.” A sample prompt ("How do I write a function to find the maximum number in a list in Python?") is included for initial evaluation.
- Initial Response Evaluation: The initial response from Claude Sonnet 4.5 provided multiple approaches to finding the maximum number (manual iteration,
reducefunction, and the built-inmaxfunction), along with context and usage information. April appreciated the inclusion of context and the recommendation of the “most pythonic and efficient approach” – the built-inmaxfunction.
Integration into the Platform UI
The platform’s UI is structured with a column-based layout: column one for the code editor and column two for the AI tutor interface. The integration process involved replacing a placeholder in column two with a functional chat interface for the AI tutor.
Leveraging GitHub Copilot for Code Integration
To expedite the integration process, April utilized GitHub Copilot in “agent mode” with the following instructions:
- Code Transfer: Transfer the AI tutor logic from the isolated
main.pyfile to the platform’scodelearn_app.pyfile. - Placeholder Replacement: Replace the placeholder in column two with the functional chat interface.
- UI/UX Alignment: Ensure the new interface aligns with the existing app’s styling.
- AI Chat UI/UX Best Practices: Adhere to established guidelines for designing effective AI chat interfaces.
- Contextual Awareness: The AI tutor should consider both the code in the editor (input) and the output of running the code before generating responses.
Copilot successfully edited the codelearn_app.py file, adding necessary imports, functions, and building the chat interface with professional UI styling, even referencing specific hex codes used in the app’s design.
Testing & Results
The updated platform now features buttons for “Explain my code,” “Help debug,” and a direct chat interface. Testing with the flawed find_max function confirmed that the AI tutor provides guidance rather than solutions. When asked, “What’s wrong with my code?”, the tutor responded with a debugging-focused approach, offering hints and guiding questions like, “What assumptions does your code make?” and “What would be a safer starting value for max_num?” April described this as a “win” and a “great starting point.”
Future Plans & Recommendations
April plans to integrate this platform into her livestream workflow, providing viewers with a link to access AI-powered support during practice exercises. She recommends the GitHub Copilot SDK to anyone creating educational or developer content, noting that it significantly simplified the development process. As she stated, “It’s made building this way more straightforward than I expected.”
Data & Statistics
While specific usage statistics weren't provided, the project aims to address a clear need identified through April's experience with her livestream viewers – the lack of immediate support during independent practice. The success of the integration is measured by the AI tutor's ability to provide helpful guidance without simply giving away answers.
Logical Connections
The video follows a logical progression: identifying a problem (lack of support for independent learners), proposing a solution (AI-powered tutoring), implementing the solution (integrating the GitHub Copilot SDK), testing the solution, and outlining future plans. Each step builds upon the previous one, demonstrating a clear and coherent development process.
Chat with this Video
AI-PoweredHi! I can answer questions about this video "How I built an AI Python tutor with the GitHub Copilot SDK". What would you like to know?