Here's a structured short course to teach this code in an easy, interactive way:
- Demo the final MetaLearn AI Assistant
- Explain features: Student ID validation, question answering, conversation logging
- Python basics refresher
- Tkinter for GUIs
- Gemini API for AI responses
- Environment variables for security
pip install python-dotenv google-generativeai requests- Get Gemini API key from Google AI Studio
- Create
.envfile:
GEMINI_API_KEY=your_key_here# 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
# Student ID Entry
id_entry = tk.Entry(font=FONT_INPUT)
# Question Textbox
question_input = tk.Text(height=5)log_output = tk.Text(state=tk.DISABLED, wrap=tk.WORD)Interactive Task: Add a "Clear Chat" button
def call_gemini_api(prompt):
response = model.generate_content(prompt)
return response.texttry:
# API call
except Exception as e:
return f"Error: {str(e)}"Debugging Exercise: Simulate API failure
def validate_student_id(sid):
return sid in VALID_IDSlog_output.insert(tk.END, f"🤖: {response}\n\n")Interactive Task: Add timestamps to logs
- Add a "loading" animation during API calls
- Implement conversation history saving
- Create a settings panel to change colors/fonts
- Live Coding: Build components step-by-step
- Breakpoints: Pause after each module for Q&A
- Debugging Sessions: Intentionally break code and fix together
- 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)?