aa
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
https://msd--3237eb32329a11f0b1c3569c3dd06744.web.val.run
This Val Town project generates comprehensive course structures from user prompts using OpenAI.
- Takes a course topic as input and generates a complete course structure
- Uses OpenAI's GPT-4o model for high-quality content generation
- Provides a structured output with course title, description, target audience, prerequisites, learning outcomes, modules, and lessons
- Includes a user-friendly web interface
/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 generator
- Visit the frontend URL
- Enter a course topic in the text area (e.g., "Introduction to Machine Learning", "Web Development with React")
- Click "Generate Course"
- View the generated course structure with modules and lessons
You 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 set as an environment variable in Val Town
- In Val Town, go to your account settings
- Add an environment variable named
OPENAI_API_KEY
with your OpenAI API key - Deploy both the course-generator.ts and frontend-handler.ts files with HTTP triggers
If the application isn't generating any responses, check the following:
- OpenAI API Key: Make sure you've set the
OPENAI_API_KEY
environment variable in Val Town - Console Logs: Check the Val Town logs for any error messages
- Browser Console: Open your browser's developer tools to check for any JavaScript errors
- API Limits: If you're using a free OpenAI API key, you might have hit your usage limits