Skip to content

Latest commit

 

History

History
112 lines (86 loc) · 2.64 KB

File metadata and controls

112 lines (86 loc) · 2.64 KB

Here's a structured short course to teach this code in an easy, interactive way:

Course: Building an AI Assistant with Python & Gemini API

Module 1: Introduction (15 mins)

Lesson 1.1: What We're Building

  • Demo the final MetaLearn AI Assistant
  • Explain features: Student ID validation, question answering, conversation logging

Lesson 1.2: Tools Overview

  • Python basics refresher
  • Tkinter for GUIs
  • Gemini API for AI responses
  • Environment variables for security

Module 2: Setup (20 mins)

Lesson 2.1: Installation

pip install python-dotenv google-generativeai requests

Lesson 2.2: API Setup

  1. Get Gemini API key from Google AI Studio
  2. Create .env file:
GEMINI_API_KEY=your_key_here

Lesson 3.1: Core Components

# Basic app skeleton
app = tk.Tk()
app.title(APP_TITLE)
app.geometry(WINDOW_SIZE)
app.configure(bg=BG_COLOR)

Interactive Task: Change window size and background color


Module 4: Building the Interface (30 mins)

Lesson 4.1: Input Fields

# Student ID Entry
id_entry = tk.Entry(font=FONT_INPUT)

# Question Textbox
question_input = tk.Text(height=5)

Lesson 4.2: Conversation Log

log_output = tk.Text(state=tk.DISABLED, wrap=tk.WORD)

Interactive Task: Add a "Clear Chat" button


Module 5: Adding Intelligence (30 mins)

Lesson 5.1: Gemini API Integration

def call_gemini_api(prompt):
    response = model.generate_content(prompt)
    return response.text

Lesson 5.2: Error Handling

try:
    # API call
except Exception as e:
    return f"Error: {str(e)}"

Debugging Exercise: Simulate API failure


Module 6: Final Touches (20 mins)

Lesson 6.1: Validation

def validate_student_id(sid):
    return sid in VALID_IDS

Lesson 6.2: Logging System

log_output.insert(tk.END, f"🤖: {response}\n\n")

Interactive Task: Add timestamps to logs


Project Challenges

  1. Add a "loading" animation during API calls
  2. Implement conversation history saving
  3. Create a settings panel to change colors/fonts

Teaching Tips

  1. Live Coding: Build components step-by-step
  2. Breakpoints: Pause after each module for Q&A
  3. Debugging Sessions: Intentionally break code and fix together
  4. Extension Ideas: "How would you add [feature]?"

Would you like me to adapt any part of this course structure for a specific audience (beginners, students, professionals)?