This document provides a comprehensive overview of the courseware_autogen 4 codebase, detailing the purpose and functionality of each file and module.
Courseware AutoGen 4 is an AI-powered platform for automating the creation of workforce training documents. It leverages Large Language Models (LLMs) via AutoGen and Streamlit to generate:
- Course Proposals (CP): Detailed course structures and justifications.
- Assessment Plans (AP): Assessment strategies and matrices.
- Learner Guides (LG): Educational content for students.
- Lesson Plans (LP): Instructor guides for delivery.
- Facilitator Guides (FG): Comprehensive guides for trainers.
- Assessments: Question papers (SAQ), Suggested Answers (WA), Presentation/Project (PP) briefs, and Case Studies (CS).
- Brochures: Information pamphlets derived from web content.
The main entry point for the Streamlit application.
- Navigation: Uses
streamlit_option_menuto switch between modules. - Lazy Loading: Imports modules (e.g.,
generate_assessment,generate_cp) only when selected to optimize startup time. - Company Context: Manages the selected company in
st.session_state(defaulting to "Tertiary Infotech") and displays the corresponding logo.
The primary user guide.
- Installation: Instructions for
pipanduvsetup. - Configuration: How to set API keys and secrets.
- Usage: Step-by-step guides for generating each document type.
Shared resources used across the application.
common.py: General utilities.parse_json_content(content): Robustly extracts JSON from LLM responses (handles markdown blocks).save_uploaded_file(uploaded_file): Saves Streamlit uploads to disk.
company_manager.py: Handles multi-tenancy for company branding.get_company_template(): finding company-specific templates or valid fallbacks.apply_company_branding(): Injecting company details into documents.
prompt_loader.py: Centralized prompt management system.- Loads
.txtprompts fromprompts/. - Supports variable substitution (
{{ variable }}). - Caches prompts for performance.
- Loads
Configuration and API management.
settings.py: The UI for the Settings page.- API Keys: Manage keys for OpenAI, Gemini, DeepSeek, etc.
- Models: Add/Edit/Remove custom LLM models (via OpenRouter).
- Company: CRUD operations for client companies (Logo, UEN, Address).
api_manager.py: Backend logic for API keys and models.- Persists keys/models to
settings/config/JSON files. - Dynamically updates
st.session_state.
- Persists keys/models to
Generates the foundational Course Proposal document.
main.py: The orchestration engine.- Takes a TSC (Technical Skills Competency) document.
- Runs a chain of AutoGen agents:
- Inital Analysis (TSC Agent)
- Information Extraction (Extraction Team)
- Content Research (Research Team)
- Validation (Course Validation Team)
app.py: The Streamlit UI for CP generation.- Handles file uploads (TSC DOCX).
- Toggles between "New CP" (Excel-based) and "Old CP" (Word-based).
agents/: Specific AutoGen agent implementations.tsc_agent.py: Analyzes the input TSC PDF/DOCX.extraction_team.py: Extracts key parameters (Duration, Cost, TGS Code).
Generates the core teaching materials based on the Course Proposal.
courseware_generation.py: The main logic hub.- Parses the uploaded CP (Word or Excel).
- Scrapes TGS data from MySkillsFuture if needed.
- Orchestrates the generation of LG, AP, LP, and FG.
utils/: Specialized generators.agentic_LG.py: Generates Learner Guides using content expansion agents.agentic_AP.py: Creates Assessment Plans, mapping assessment methods to learning outcomes.timetable_generator.py: Calculates course schedules and durations.
Creates the actual test papers.
assessment_generation.py: The UI and Controller.- Inputs: Facilitator Guide (FG) and Slides (PDF).
- Logic: Parses FG to understand what to test. Generates questions matching the LO (Learning Outcome) requirements.
utils/:agentic_SAQ.py: Agents specifically for Short Answer Questions.agentic_PP.py: Agents for Project/Presentation assessments.Templates/:.docxtemplates for question/answer papers.
Generates marketing brochures.
brochure_generation_v2.py:- Web Scraping: Uses Selenium/Browserless to scrape course details from a URL.
- Template Filling: Populates a brochure template with course title, fees, funding, and modules.
- PDF Generation: Converts the result to PDF.
A compliance tool.
sup_doc.py:- Reads uploaded PDFs/Images (NRIC, Company content).
- Extracts entities (Name, UEN, ID) using Gemini.
- Matches against a Google Sheet (SSG API data) to verify trainee funding eligibility.
annex_assessment_v2.py: A utility to physically merge generated Assessment Question/Answer papers into the main Assessment Plan DOCX as Annexes.
Streamlit apps can be slow if everything is imported at start. This project uses local imports inside app() functions.
Example: generate_cp is only imported when the user clicks the "Course Proposal" menu item.
Complex tasks are broken down into agents.
- UserProxy: Acts as the requester.
- Assistant: The LLM that generates content.
- GroupChat: Coordinates multiple experts (e.g., a "Research Team" and a "Writer").
- Pydantic: Used extensively to force LLMs to output structured JSON data (e.g.,
CourseDatamodel). - Jinja2 / DocxTpl: Used to render extracted data into Word templates, ensuring consistent formatting.
- Secrets: API keys are stored in
.streamlit/secrets.tomlor managed via the UI (saved to local JSON insettings/config/). - Model Abstraction: The system supports OpenAI, Gemini, Anthropic, etc., abstracted via
api_manager.pyso the rest of the code just asks for a "completion".