Spaces:
Running
Running
Implementation Complete β
All phases of the enhanced video generation system have been implemented.
What's New
1. Unified Input Support
- β Text prompts
- β PDF files (base64 encoded)
- β URL scraping (blogs, documentation, etc.)
2. Category-Specific Visual Themes
- β Tech System: Dark blue background (#0a0e27), professional diagrams
- β Product Startup: White background (#ffffff), modern gradients
- β Research/Mathematical: Dark background (#1e1e1e), educational style
3. Robust Code Validation & Auto-Fix
- β Pre-render syntax validation
- β Import checking
- β Structure validation
- β Auto-fix common issues
- β Retry with fallback models
4. Unified API Server
- β Single endpoint for all input types
- β Async job processing
- β Progress tracking
- β Error handling
New Files Created
Core Components
manimator/services/web_scraper.py- Web content scrapingmanimator/api/input_processor.py- Unified input handlermanimator/utils/visual_themes.py- Theme configurationsmanimator/utils/theme_injector.py- Theme code injectionmanimator/utils/code_validator.py- Code validationmanimator/utils/code_fixer.py- Auto-fix functionalitymanimator/utils/validation_pipeline.py- Complete validation pipelineapi_server_unified.py- New unified API server
Modified Files
manimator/api/scene_description.py- Added URL processingmanimator/api/animation_generation.py- Added validation & retry logicmanimator/utils/system_prompts.py- Enhanced with theme instructionspyproject.toml- Added new dependencies
Dependencies Added
beautifulsoup4 = "^4.12.0"
requests = "^2.31.0"
readability-lxml = "^0.8.1"
How to Use
Start the Unified API Server
python api_server_unified.py
Server runs on http://localhost:8000
API Endpoints
Create Video
POST /api/videos
{
"input_type": "text|pdf|url",
"input_data": "...",
"quality": "low|medium|high|ultra",
"category": "tech_system|product_startup|mathematical"
}
Check Job Status
GET /api/jobs/{job_id}
Download Video
GET /api/videos/{job_id}
Example Requests
Text Input:
{
"input_type": "text",
"input_data": "Explain how a distributed system handles requests",
"category": "tech_system",
"quality": "high"
}
URL Input:
{
"input_type": "url",
"input_data": "https://example.com/blog/post",
"category": "product_startup",
"quality": "medium"
}
PDF Input:
{
"input_type": "pdf",
"input_data": "base64_encoded_pdf_string",
"category": "mathematical",
"quality": "high"
}
Features
Visual Themes
Each category has distinct visual styling:
- Tech: Dark professional backgrounds, architecture diagrams
- Product: Light modern backgrounds, UI elements, gradients
- Research: Dark educational backgrounds, mathematical equations
Error Handling
- Automatic code validation before rendering
- Auto-fix for common issues (missing imports, undefined colors, etc.)
- Retry with fallback models if generation fails
- Detailed error messages
Input Processing
- Text: Direct prompt processing
- PDF: Base64 decoding and content extraction
- URL: Web scraping with content extraction
Next Steps
Install new dependencies:
poetry installTest the unified server:
python api_server_unified.pyTry different input types and categories
Monitor job status and video generation
Notes
- The unified server replaces the need for separate 2D/3D servers
- All categories use the same code generation pipeline with different themes
- Web scraping respects robots.txt and handles authentication errors gracefully
- Code validation prevents most rendering failures