This Val Town project generates comprehensive course structures from user prompts using OpenAI.
/course-generator.ts
- Core logic for generating course structures using OpenAI/frontend-handler.ts
- HTTP handler that serves the frontend and processes API requests/frontend/index.html
- Web interface for the course generatorYou can also use the course generator as an API:
// Example API call
const response = await fetch('YOUR_VAL_TOWN_URL', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ prompt: 'Introduction to Machine Learning' }),
});
const courseStructure = await response.json();
The API returns a JSON object with the following structure:
{ "courseTitle": "Title of the course", "courseDescription": "A paragraph describing the course", "targetAudience": "Description of who this course is for", "prerequisites": ["Prerequisite 1", "Prerequisite 2", ...], "learningOutcomes": ["Outcome 1", "Outcome 2", ...], "modules": [ { "title": "Module title", "description": "Module description", "lessons": [ { "title": "Lesson title", "description": "Brief description of the lesson", "keyPoints": ["Key point 1", "Key point 2", ...] }, ...more lessons ] }, ...more modules ] }
OPENAI_API_KEY
with your OpenAI API keyIf the application isn't generating any responses, check the following:
OPENAI_API_KEY
environment variable in Val Town