Repository navigation
Fix code_generator.py to produce unique, tutorial-specific output instead of identical boilerplate - #79
Closed
groupthinking with Claude wants to merge 3 commits into
Closed
Fix code_generator.py to produce unique, tutorial-specific output instead of identical boilerplate#79groupthinking with Claude wants to merge 3 commits into
groupthinking with Claude wants to merge 3 commits into
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
- Enhanced React component generation with tutorial-specific implementations - Added step-by-step code generation based on tutorial actions (create, state, API, event, form, list, style) - Updated vanilla JS to generate unique functions per tutorial step with real implementations - Enhanced FastAPI generator with tutorial-specific endpoints - Improved CSS with styles for interactive tutorial elements - Updated README generation to highlight tutorial-specific nature of code - Each video now produces unique code based on extracted tutorial_steps instead of identical boilerplate Co-authored-by: groupthinking <154503486+groupthinking@users.noreply.github.com>
- Added test suite verifying unique output per tutorial - Tests validate React, vanilla JS, and FastAPI generation - Added detailed solution summary documenting changes - All tests passing successfully Co-authored-by: groupthinking <154503486+groupthinking@users.noreply.github.com>
| "description": "This API was generated by UVAI from a YouTube tutorial", | ||
| "endpoints": ["/docs", "/api/messages", "/api/health"] | ||
| "description": "This API was generated from a YouTube tutorial with unique implementations", | ||
| "endpoints": [ |
Contributor
| """Generate unique code implementation for each tutorial step""" | ||
|
|
||
| # Generate tutorial-specific code based on the step's action | ||
| if action == 'create': |
Contributor
Comment on lines
+371
to
+374
| component_jsx = f''' <div className="step-card" data-step="{{idx}}" key="{{idx}}"> | ||
| <div className="step-header"> | ||
| <span className="step-number">Step {{idx + 1}}</span> | ||
| <h3>{{completedSteps.includes(idx) ? '✓ ' : ''}}{step[:60]}{{'{step[60:]}' if len(step) > 60 else ''}}</h3> |
Contributor
There was a problem hiding this comment.
Suggested change
| component_jsx = f''' <div className="step-card" data-step="{{idx}}" key="{{idx}}"> | |
| <div className="step-header"> | |
| <span className="step-number">Step {{idx + 1}}</span> | |
| <h3>{{completedSteps.includes(idx) ? '✓ ' : ''}}{step[:60]}{{'{step[60:]}' if len(step) > 60 else ''}}</h3> | |
| # Pre-evaluate Python logic before using in f-string to avoid syntax errors | |
| step_title = step[:60] | |
| step_remainder = step[60:] if len(step) > 60 else '' | |
| component_jsx = f''' <div className="step-card" data-step="{{idx}}" key="{{idx}}"> | |
| <div className="step-header"> | |
| <span className="step-number">Step {{idx + 1}}</span> | |
| <h3>{{completedSteps.includes(idx) ? '✓ ' : ''}}{step_title}{step_remainder}</h3> |
Invalid JSX generation with embedded Python conditional syntax produces malformed JavaScript when rendered
Owner
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The code generator was extracting
tutorial_stepsfrom video analysis but only displaying them as static text. Every video produced identical boilerplate code regardless of tutorial content.Changes
Tutorial Step Analysis
_extract_step_action()to classify tutorial steps by action type (create, state, API, event, form, list, style)React Generation
_generate_step_components_jsx(): Generates interactive step cards with working code demos_generate_step_specific_code(): Creates unique JSX per step based on action typeuseStatehooks and step completion handlersExample output for "Add useState hook" step:
Vanilla JS Generation
_generate_vanilla_step_function(): Generates step-specific init functions with real implementations_generate_step_initializations(): Auto-executes tutorial functions on page loadFastAPI Generation
/api/tutorial/steps,/api/tutorial/progressStyling & Documentation
Verification
Test suite validates unique output across different tutorial types:
Each video now generates code matching its tutorial content rather than generic templates.
Original prompt