Spaces:
Sleeping
Sleeping
updated
Browse files- README.md +150 -2
- app.py +179 -81
- requirements.txt +14 -13
- requirements_hf.txt +7 -27
README.md
CHANGED
|
@@ -13,9 +13,157 @@ python_version: 3.11
|
|
| 13 |
|
| 14 |
# 🎓 Theorem Explanation Agent
|
| 15 |
|
| 16 |
-
|
| 17 |
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
- **Interactive Web Interface**: User-friendly Gradio interface for easy video generation
|
| 21 |
- **Multiple AI Models**: Support for various LLMs including Gemini, GPT-4, and Claude
|
|
|
|
| 13 |
|
| 14 |
# 🎓 Theorem Explanation Agent
|
| 15 |
|
| 16 |
+
**AI-Powered Educational Content Generation**
|
| 17 |
|
| 18 |
+
[](https://huggingface.co/spaces/ManojINaik/menamiai)
|
| 19 |
+
|
| 20 |
+
## 🌟 Overview
|
| 21 |
+
|
| 22 |
+
The Theorem Explanation Agent is an AI-powered system that helps create educational content using Google's Gemini 2.0 Flash model. This system is designed to plan and structure educational videos with mathematical and scientific concepts.
|
| 23 |
+
|
| 24 |
+
## 🎮 Current Status: Demo Mode
|
| 25 |
+
|
| 26 |
+
**This Hugging Face Spaces instance runs in demonstration mode** due to system dependency limitations.
|
| 27 |
+
|
| 28 |
+
### ✅ Available Features:
|
| 29 |
+
- 🤖 **Gemini 2.0 Flash Integration**: Advanced AI for educational content planning
|
| 30 |
+
- 🔄 **Comma-separated API Key Support**: Automatic rotation across multiple API keys
|
| 31 |
+
- 📚 **Educational Content Planning**: Structured lesson planning and curriculum design
|
| 32 |
+
- 🎯 **Learning Objective Design**: AI-assisted educational goal setting
|
| 33 |
+
|
| 34 |
+
### ❌ Currently Not Available:
|
| 35 |
+
- 🎥 **Video Rendering**: Requires Manim system libraries (pangocairo, etc.)
|
| 36 |
+
- 📹 **MP4 Generation**: System dependencies not available in HF Spaces
|
| 37 |
+
- 🎨 **Visual Animations**: Manim-based mathematical visualizations
|
| 38 |
+
|
| 39 |
+
## 🚀 Quick Start
|
| 40 |
+
|
| 41 |
+
1. **Enter an Educational Topic**: e.g., "Pythagorean Theorem", "Newton's Laws"
|
| 42 |
+
2. **Add Learning Context**: Specify target audience, objectives, or focus areas
|
| 43 |
+
3. **Set Content Sections**: Choose number of content sections to plan (1-6)
|
| 44 |
+
4. **Generate**: Click "Generate Educational Content" to see AI planning in action
|
| 45 |
+
|
| 46 |
+
## 🔧 API Key Configuration
|
| 47 |
+
|
| 48 |
+
For enhanced functionality, set your Gemini API key:
|
| 49 |
+
|
| 50 |
+
### Single API Key:
|
| 51 |
+
```bash
|
| 52 |
+
GEMINI_API_KEY=your-gemini-api-key
|
| 53 |
+
```
|
| 54 |
+
|
| 55 |
+
### Multiple Keys (Recommended):
|
| 56 |
+
```bash
|
| 57 |
+
GEMINI_API_KEY=key1,key2,key3,key4
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
Multiple keys enable:
|
| 61 |
+
- ✅ Load balancing across API limits
|
| 62 |
+
- ✅ Automatic failover if one key fails
|
| 63 |
+
- ✅ Cost distribution across billing accounts
|
| 64 |
+
|
| 65 |
+
## 💻 Full Video Generation (Local Setup)
|
| 66 |
+
|
| 67 |
+
For complete video generation capabilities with actual MP4 output:
|
| 68 |
+
|
| 69 |
+
```bash
|
| 70 |
+
# Clone the repository
|
| 71 |
+
git clone https://github.com/your-repo/TheoremExplainAgent
|
| 72 |
+
cd TheoremExplainAgent
|
| 73 |
+
|
| 74 |
+
# Install system dependencies (Ubuntu/Debian)
|
| 75 |
+
sudo apt update
|
| 76 |
+
sudo apt install -y \
|
| 77 |
+
libpangocairo-1.0-0 \
|
| 78 |
+
libpango-1.0-0 \
|
| 79 |
+
libcairo2-dev \
|
| 80 |
+
pkg-config \
|
| 81 |
+
python3-dev
|
| 82 |
+
|
| 83 |
+
# Install Python dependencies
|
| 84 |
+
pip install -r requirements.txt
|
| 85 |
+
|
| 86 |
+
# Set environment variables
|
| 87 |
+
export GEMINI_API_KEY="your-api-key-1,your-api-key-2"
|
| 88 |
+
export DEMO_MODE=false
|
| 89 |
+
|
| 90 |
+
# Run locally
|
| 91 |
+
python app.py
|
| 92 |
+
```
|
| 93 |
+
|
| 94 |
+
## 📚 Example Educational Topics
|
| 95 |
+
|
| 96 |
+
The system works best with specific, educational topics:
|
| 97 |
+
|
| 98 |
+
- **Mathematics**: "Quadratic Formula Derivation", "Calculus Derivatives", "Geometric Proofs"
|
| 99 |
+
- **Physics**: "Newton's Second Law", "Electromagnetic Waves", "Wave-Particle Duality"
|
| 100 |
+
- **Biology**: "DNA Structure", "Photosynthesis Process", "Cellular Respiration"
|
| 101 |
+
- **Chemistry**: "Chemical Bonding", "Atomic Structure", "Periodic Trends"
|
| 102 |
+
|
| 103 |
+
## 🛠️ Technical Architecture
|
| 104 |
+
|
| 105 |
+
### Core Components:
|
| 106 |
+
- **Gemini 2.0 Flash**: Content planning and educational structure generation
|
| 107 |
+
- **LiteLLM**: Multi-provider AI model integration with failover
|
| 108 |
+
- **Gradio**: User-friendly web interface
|
| 109 |
+
- **Manim**: Mathematical animation engine (local setup only)
|
| 110 |
+
|
| 111 |
+
### Key Features:
|
| 112 |
+
- **Intelligent Content Planning**: AI-driven educational curriculum design
|
| 113 |
+
- **Multi-API Key Rotation**: Robust handling of rate limits and failures
|
| 114 |
+
- **Educational Focus**: Optimized for STEM learning objectives
|
| 115 |
+
- **Scalable Architecture**: Supports both demo and full production modes
|
| 116 |
+
|
| 117 |
+
## 🔍 System Capabilities
|
| 118 |
+
|
| 119 |
+
### Content Planning Features:
|
| 120 |
+
- 📋 **Curriculum Structure**: AI-generated lesson plans
|
| 121 |
+
- 🎯 **Learning Objectives**: Automatic educational goal setting
|
| 122 |
+
- 📊 **Content Progression**: Logical topic flow and difficulty scaling
|
| 123 |
+
- 🧠 **Concept Mapping**: Relationship identification between topics
|
| 124 |
+
|
| 125 |
+
### AI Integration:
|
| 126 |
+
- 🤖 **Gemini 2.0 Flash**: Latest Google AI model for educational content
|
| 127 |
+
- 🔄 **Automatic Retry Logic**: Robust error handling and recovery
|
| 128 |
+
- 📝 **Context-Aware Planning**: Audience-specific content adaptation
|
| 129 |
+
- 💡 **Creative Content Generation**: Engaging educational narratives
|
| 130 |
+
|
| 131 |
+
## 📈 Usage Analytics
|
| 132 |
+
|
| 133 |
+
The system provides insights into:
|
| 134 |
+
- ✅ Successful content generation attempts
|
| 135 |
+
- 🔄 API key rotation and usage patterns
|
| 136 |
+
- 📊 Popular educational topics and trends
|
| 137 |
+
- ⚡ Performance metrics and response times
|
| 138 |
+
|
| 139 |
+
## 🤝 Contributing
|
| 140 |
+
|
| 141 |
+
We welcome contributions to improve educational content generation:
|
| 142 |
+
|
| 143 |
+
1. **Content Templates**: Add new educational topic templates
|
| 144 |
+
2. **AI Prompts**: Enhance content planning prompts
|
| 145 |
+
3. **UI Improvements**: Better user experience design
|
| 146 |
+
4. **Documentation**: Clearer setup and usage guides
|
| 147 |
+
|
| 148 |
+
## 📞 Support
|
| 149 |
+
|
| 150 |
+
For questions, issues, or feedback:
|
| 151 |
+
|
| 152 |
+
- 🐛 **Issues**: Report bugs and feature requests
|
| 153 |
+
- 💬 **Discussions**: Community support and ideas
|
| 154 |
+
- 📧 **Contact**: Direct support for urgent matters
|
| 155 |
+
|
| 156 |
+
## 📄 License
|
| 157 |
+
|
| 158 |
+
This project is licensed under the MIT License - see the LICENSE file for details.
|
| 159 |
+
|
| 160 |
+
---
|
| 161 |
+
|
| 162 |
+
**Built with ❤️ for educators and learners worldwide**
|
| 163 |
+
|
| 164 |
+
*Transform complex concepts into engaging educational experiences with AI-powered content generation.*
|
| 165 |
+
|
| 166 |
+
# 🌟 Features
|
| 167 |
|
| 168 |
- **Interactive Web Interface**: User-friendly Gradio interface for easy video generation
|
| 169 |
- **Multiple AI Models**: Support for various LLMs including Gemini, GPT-4, and Claude
|
app.py
CHANGED
|
@@ -16,8 +16,38 @@ import gradio as gr
|
|
| 16 |
# Environment setup
|
| 17 |
DEMO_MODE = os.getenv("DEMO_MODE", "false").lower() == "true"
|
| 18 |
video_generator = None
|
| 19 |
-
CAN_IMPORT_DEPENDENCIES =
|
| 20 |
GRADIO_OUTPUT_DIR = "gradio_outputs"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
def setup_environment():
|
| 23 |
"""Setup environment for HF Spaces."""
|
|
@@ -26,23 +56,30 @@ def setup_environment():
|
|
| 26 |
# Create output directory
|
| 27 |
os.makedirs(GRADIO_OUTPUT_DIR, exist_ok=True)
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
gemini_keys = os.getenv("GEMINI_API_KEY", "")
|
| 30 |
if gemini_keys:
|
| 31 |
key_count = len([k.strip() for k in gemini_keys.split(',') if k.strip()])
|
| 32 |
print(f"✅ Found {key_count} Gemini API key(s)")
|
| 33 |
return True
|
| 34 |
else:
|
| 35 |
-
print("⚠️ No Gemini API keys found
|
| 36 |
return False
|
| 37 |
|
| 38 |
def initialize_video_generator():
|
| 39 |
"""Initialize video generator with proper dependencies."""
|
| 40 |
-
global video_generator, CAN_IMPORT_DEPENDENCIES
|
| 41 |
|
| 42 |
try:
|
| 43 |
if DEMO_MODE:
|
| 44 |
return "⚠️ Demo mode enabled - No video generation"
|
| 45 |
|
|
|
|
|
|
|
|
|
|
| 46 |
gemini_keys = os.getenv("GEMINI_API_KEY", "")
|
| 47 |
if not gemini_keys:
|
| 48 |
return "⚠️ No API keys found - Set GEMINI_API_KEY environment variable"
|
|
@@ -53,9 +90,7 @@ def initialize_video_generator():
|
|
| 53 |
from mllm_tools.litellm import LiteLLMWrapper
|
| 54 |
print("✅ Successfully imported video generation dependencies")
|
| 55 |
except ImportError as e:
|
| 56 |
-
|
| 57 |
-
print(f"❌ Import error: {e}")
|
| 58 |
-
return f"⚠️ Missing dependencies: {str(e)}"
|
| 59 |
|
| 60 |
# Initialize models with comma-separated API key support
|
| 61 |
planner_model = LiteLLMWrapper(
|
|
@@ -86,46 +121,62 @@ def initialize_video_generator():
|
|
| 86 |
return f"❌ Initialization failed: {str(e)}"
|
| 87 |
|
| 88 |
def simulate_video_generation(topic: str, context: str, max_scenes: int, progress_callback=None):
|
| 89 |
-
"""
|
| 90 |
stages = [
|
| 91 |
-
("🔍 Analyzing topic", 15),
|
| 92 |
-
("
|
| 93 |
-
("
|
| 94 |
-
("
|
| 95 |
-
("
|
| 96 |
-
("
|
|
|
|
| 97 |
]
|
| 98 |
|
| 99 |
results = []
|
| 100 |
for stage, progress in stages:
|
| 101 |
if progress_callback:
|
| 102 |
progress_callback(progress, stage)
|
| 103 |
-
time.sleep(random.uniform(0.
|
| 104 |
results.append(f"• {stage}")
|
| 105 |
|
| 106 |
-
|
|
|
|
| 107 |
"success": True,
|
| 108 |
-
"message": f"Demo simulation completed for: {topic}",
|
| 109 |
-
"
|
| 110 |
"processing_steps": results,
|
| 111 |
-
"demo_note": "This is a
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
}
|
|
|
|
|
|
|
| 113 |
|
| 114 |
async def generate_video_async(topic: str, context: str, max_scenes: int, progress_callback=None):
|
| 115 |
-
"""Generate video asynchronously
|
| 116 |
global video_generator
|
| 117 |
|
| 118 |
if not topic.strip():
|
| 119 |
-
return {"success": False, "error": "Please enter
|
| 120 |
|
| 121 |
try:
|
|
|
|
| 122 |
if DEMO_MODE or not CAN_IMPORT_DEPENDENCIES or video_generator is None:
|
| 123 |
return simulate_video_generation(topic, context, max_scenes, progress_callback)
|
| 124 |
|
|
|
|
| 125 |
if progress_callback:
|
| 126 |
progress_callback(10, "🚀 Starting video generation...")
|
| 127 |
|
| 128 |
-
# Use the actual video generation pipeline
|
| 129 |
result = await video_generator.generate_video_pipeline(
|
| 130 |
topic=topic,
|
| 131 |
description=context or f"Educational video about {topic}",
|
|
@@ -145,12 +196,10 @@ async def generate_video_async(topic: str, context: str, max_scenes: int, progre
|
|
| 145 |
video_files = []
|
| 146 |
|
| 147 |
if os.path.exists(output_folder):
|
| 148 |
-
# Look for combined video
|
| 149 |
combined_video = os.path.join(output_folder, f"{file_prefix}_combined.mp4")
|
| 150 |
if os.path.exists(combined_video):
|
| 151 |
video_files.append(combined_video)
|
| 152 |
|
| 153 |
-
# Look for individual scene videos
|
| 154 |
for i in range(1, max_scenes + 1):
|
| 155 |
scene_video = os.path.join(output_folder, f"scene{i}", f"{file_prefix}_scene{i}.mp4")
|
| 156 |
if os.path.exists(scene_video):
|
|
@@ -185,13 +234,13 @@ def generate_video_gradio(topic: str, context: str, max_scenes: int, progress=gr
|
|
| 185 |
loop.close()
|
| 186 |
|
| 187 |
if result["success"]:
|
| 188 |
-
output = f"""# 🎓
|
| 189 |
|
| 190 |
**Topic:** {topic}
|
| 191 |
-
**Context:** {context if context else "
|
| 192 |
-
**Scenes:** {max_scenes}
|
| 193 |
|
| 194 |
-
## ✅
|
| 195 |
{result["message"]}
|
| 196 |
"""
|
| 197 |
|
|
@@ -201,53 +250,84 @@ def generate_video_gradio(topic: str, context: str, max_scenes: int, progress=gr
|
|
| 201 |
for step in result["processing_steps"]:
|
| 202 |
output += f"{step}\n"
|
| 203 |
|
| 204 |
-
# Add
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 205 |
if "demo_note" in result:
|
| 206 |
-
output += f"\n
|
|
|
|
| 207 |
|
| 208 |
-
# Add video file information
|
| 209 |
video_path = None
|
| 210 |
if "video_files" in result and result["video_files"]:
|
| 211 |
output += f"\n## 🎥 Generated Videos\n"
|
| 212 |
for video_file in result["video_files"]:
|
| 213 |
output += f"• {os.path.basename(video_file)}\n"
|
| 214 |
-
video_path = result["video_files"][0]
|
| 215 |
elif "output_folder" in result:
|
| 216 |
output += f"\n📁 **Output folder:** {result['output_folder']}\n"
|
| 217 |
|
| 218 |
-
status = "🎮 Demo
|
| 219 |
return output, status, video_path
|
| 220 |
|
| 221 |
else:
|
| 222 |
-
error_output = f"""# ❌
|
| 223 |
|
| 224 |
**Error:** {result.get("error", "Unknown error")}
|
| 225 |
|
| 226 |
## 💡 Troubleshooting Tips
|
| 227 |
-
1. **Check API Keys:** Ensure GEMINI_API_KEY is set with valid keys
|
| 228 |
-
2. **Topic Clarity:** Use specific, educational topics
|
| 229 |
-
3. **Dependencies:** Make sure all required packages are installed
|
| 230 |
-
4. **Demo Mode:** Set DEMO_MODE=false for real generation
|
| 231 |
|
| 232 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 233 |
```bash
|
| 234 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 235 |
export DEMO_MODE=false
|
|
|
|
|
|
|
|
|
|
| 236 |
```
|
| 237 |
"""
|
| 238 |
-
return error_output, "❌
|
| 239 |
|
| 240 |
def get_examples():
|
| 241 |
-
"""Educational example topics."""
|
| 242 |
return [
|
| 243 |
-
["Pythagorean Theorem", "
|
| 244 |
-
["Newton's Second Law", "F=ma with real-world examples and
|
| 245 |
-
["Derivatives
|
| 246 |
-
["
|
| 247 |
-
["
|
| 248 |
-
["Quadratic Formula", "
|
| 249 |
-
["
|
| 250 |
-
["
|
| 251 |
]
|
| 252 |
|
| 253 |
# Initialize the system
|
|
@@ -264,19 +344,19 @@ with gr.Blocks(
|
|
| 264 |
gr.HTML("""
|
| 265 |
<div style="text-align: center; padding: 25px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); border-radius: 15px; color: white; margin-bottom: 25px; box-shadow: 0 4px 6px rgba(0,0,0,0.1);">
|
| 266 |
<h1 style="margin: 0; font-size: 2.5em;">🎓 Theorem Explanation Agent</h1>
|
| 267 |
-
<p style="margin: 10px 0 0 0; font-size: 1.2em; opacity: 0.9;">
|
| 268 |
-
<p style="margin: 5px 0 0 0; font-size: 0.9em; opacity: 0.8;">Powered by Gemini 2.0 Flash
|
| 269 |
</div>
|
| 270 |
""")
|
| 271 |
|
| 272 |
-
#
|
| 273 |
with gr.Row():
|
| 274 |
with gr.Column():
|
| 275 |
gr.HTML(f"""
|
| 276 |
<div style="background: {'#d4edda' if has_api_keys else '#fff3cd'}; padding: 15px; border-radius: 10px; margin-bottom: 15px; border-left: 4px solid {'#28a745' if has_api_keys else '#ffc107'};">
|
| 277 |
-
<h4 style="margin: 0 0 8px 0;">🔐 API
|
| 278 |
<p style="margin: 0;"><strong>Status:</strong> {"✅ API keys configured" if has_api_keys else "⚠️ No API keys found"}</p>
|
| 279 |
-
<p style="margin: 5px 0 0 0; font-size: 0.9em;">{"Ready for
|
| 280 |
</div>
|
| 281 |
""")
|
| 282 |
|
|
@@ -288,23 +368,37 @@ with gr.Blocks(
|
|
| 288 |
lines=2
|
| 289 |
)
|
| 290 |
|
| 291 |
-
#
|
| 292 |
-
if not
|
| 293 |
gr.HTML("""
|
| 294 |
-
<div style="background: #
|
| 295 |
-
<h4 style="color: #
|
| 296 |
-
<p
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
<
|
| 300 |
-
<
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 304 |
</div>
|
| 305 |
-
<p style="margin-top: 15px; font-size: 0.9em; color: #6c757d;">
|
| 306 |
-
Multiple API keys enable automatic failover and load distribution across different billing accounts.
|
| 307 |
-
</p>
|
| 308 |
</div>
|
| 309 |
""")
|
| 310 |
|
|
@@ -313,36 +407,40 @@ with gr.Blocks(
|
|
| 313 |
with gr.Column(scale=2):
|
| 314 |
topic_input = gr.Textbox(
|
| 315 |
label="📚 Educational Topic",
|
| 316 |
-
placeholder="e.g., Pythagorean Theorem, Newton's Laws,
|
| 317 |
lines=1
|
| 318 |
)
|
| 319 |
|
| 320 |
context_input = gr.Textbox(
|
| 321 |
-
label="📝
|
| 322 |
-
placeholder="Specify
|
| 323 |
lines=3
|
| 324 |
)
|
| 325 |
|
| 326 |
max_scenes_slider = gr.Slider(
|
| 327 |
-
label="🎬
|
| 328 |
minimum=1,
|
| 329 |
maximum=6,
|
| 330 |
value=3,
|
| 331 |
step=1,
|
| 332 |
-
info="
|
| 333 |
)
|
| 334 |
|
| 335 |
-
generate_btn = gr.Button(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 336 |
|
| 337 |
with gr.Column(scale=1):
|
| 338 |
gr.HTML("""
|
| 339 |
<div style="background: #f8f9fa; padding: 20px; border-radius: 10px; height: fit-content;">
|
| 340 |
<h4 style="color: #495057; margin-top: 0;">💡 Tips for Best Results</h4>
|
| 341 |
<ul style="color: #6c757d; font-size: 0.9em; line-height: 1.6;">
|
| 342 |
-
<li><strong>Be Specific:</strong> "
|
| 343 |
-
<li><strong>Educational Focus:</strong>
|
| 344 |
-
<li><strong>
|
| 345 |
-
<li><strong>
|
| 346 |
</ul>
|
| 347 |
</div>
|
| 348 |
""")
|
|
@@ -351,14 +449,14 @@ with gr.Blocks(
|
|
| 351 |
examples = gr.Examples(
|
| 352 |
examples=get_examples(),
|
| 353 |
inputs=[topic_input, context_input],
|
| 354 |
-
label="📖 Example Topics"
|
| 355 |
)
|
| 356 |
|
| 357 |
# Output section
|
| 358 |
with gr.Row():
|
| 359 |
with gr.Column(scale=2):
|
| 360 |
output_display = gr.Markdown(
|
| 361 |
-
value="👋 **Ready to generate!** Enter
|
| 362 |
label="📋 Generation Results"
|
| 363 |
)
|
| 364 |
|
|
|
|
| 16 |
# Environment setup
|
| 17 |
DEMO_MODE = os.getenv("DEMO_MODE", "false").lower() == "true"
|
| 18 |
video_generator = None
|
| 19 |
+
CAN_IMPORT_DEPENDENCIES = False
|
| 20 |
GRADIO_OUTPUT_DIR = "gradio_outputs"
|
| 21 |
+
DEPENDENCY_ERROR = None
|
| 22 |
+
|
| 23 |
+
def check_dependencies():
|
| 24 |
+
"""Check if required dependencies are available."""
|
| 25 |
+
global CAN_IMPORT_DEPENDENCIES, DEPENDENCY_ERROR
|
| 26 |
+
|
| 27 |
+
missing_deps = []
|
| 28 |
+
|
| 29 |
+
try:
|
| 30 |
+
import manim
|
| 31 |
+
except ImportError:
|
| 32 |
+
missing_deps.append("manim")
|
| 33 |
+
|
| 34 |
+
try:
|
| 35 |
+
from generate_video import VideoGenerator
|
| 36 |
+
except ImportError as e:
|
| 37 |
+
missing_deps.append("generate_video")
|
| 38 |
+
DEPENDENCY_ERROR = str(e)
|
| 39 |
+
|
| 40 |
+
try:
|
| 41 |
+
from mllm_tools.litellm import LiteLLMWrapper
|
| 42 |
+
except ImportError:
|
| 43 |
+
missing_deps.append("mllm_tools")
|
| 44 |
+
|
| 45 |
+
if missing_deps:
|
| 46 |
+
CAN_IMPORT_DEPENDENCIES = False
|
| 47 |
+
return f"Missing dependencies: {', '.join(missing_deps)}"
|
| 48 |
+
else:
|
| 49 |
+
CAN_IMPORT_DEPENDENCIES = True
|
| 50 |
+
return "All dependencies available"
|
| 51 |
|
| 52 |
def setup_environment():
|
| 53 |
"""Setup environment for HF Spaces."""
|
|
|
|
| 56 |
# Create output directory
|
| 57 |
os.makedirs(GRADIO_OUTPUT_DIR, exist_ok=True)
|
| 58 |
|
| 59 |
+
# Check dependencies
|
| 60 |
+
dep_status = check_dependencies()
|
| 61 |
+
print(f"📦 Dependencies: {dep_status}")
|
| 62 |
+
|
| 63 |
gemini_keys = os.getenv("GEMINI_API_KEY", "")
|
| 64 |
if gemini_keys:
|
| 65 |
key_count = len([k.strip() for k in gemini_keys.split(',') if k.strip()])
|
| 66 |
print(f"✅ Found {key_count} Gemini API key(s)")
|
| 67 |
return True
|
| 68 |
else:
|
| 69 |
+
print("⚠️ No Gemini API keys found")
|
| 70 |
return False
|
| 71 |
|
| 72 |
def initialize_video_generator():
|
| 73 |
"""Initialize video generator with proper dependencies."""
|
| 74 |
+
global video_generator, CAN_IMPORT_DEPENDENCIES, DEPENDENCY_ERROR
|
| 75 |
|
| 76 |
try:
|
| 77 |
if DEMO_MODE:
|
| 78 |
return "⚠️ Demo mode enabled - No video generation"
|
| 79 |
|
| 80 |
+
if not CAN_IMPORT_DEPENDENCIES:
|
| 81 |
+
return f"⚠️ Missing dependencies - {DEPENDENCY_ERROR or 'Video generation not available'}"
|
| 82 |
+
|
| 83 |
gemini_keys = os.getenv("GEMINI_API_KEY", "")
|
| 84 |
if not gemini_keys:
|
| 85 |
return "⚠️ No API keys found - Set GEMINI_API_KEY environment variable"
|
|
|
|
| 90 |
from mllm_tools.litellm import LiteLLMWrapper
|
| 91 |
print("✅ Successfully imported video generation dependencies")
|
| 92 |
except ImportError as e:
|
| 93 |
+
return f"⚠️ Import error: {str(e)}"
|
|
|
|
|
|
|
| 94 |
|
| 95 |
# Initialize models with comma-separated API key support
|
| 96 |
planner_model = LiteLLMWrapper(
|
|
|
|
| 121 |
return f"❌ Initialization failed: {str(e)}"
|
| 122 |
|
| 123 |
def simulate_video_generation(topic: str, context: str, max_scenes: int, progress_callback=None):
|
| 124 |
+
"""Enhanced simulation for HF Spaces demo."""
|
| 125 |
stages = [
|
| 126 |
+
("🔍 Analyzing educational topic", 15),
|
| 127 |
+
("📚 Planning curriculum structure", 30),
|
| 128 |
+
("🎯 Designing learning objectives", 45),
|
| 129 |
+
("📝 Creating content outline", 60),
|
| 130 |
+
("🎨 Generating visual concepts", 75),
|
| 131 |
+
("🎬 Simulating video production", 90),
|
| 132 |
+
("✅ Demo completed", 100)
|
| 133 |
]
|
| 134 |
|
| 135 |
results = []
|
| 136 |
for stage, progress in stages:
|
| 137 |
if progress_callback:
|
| 138 |
progress_callback(progress, stage)
|
| 139 |
+
time.sleep(random.uniform(0.8, 1.5))
|
| 140 |
results.append(f"• {stage}")
|
| 141 |
|
| 142 |
+
# Create demo information
|
| 143 |
+
demo_content = {
|
| 144 |
"success": True,
|
| 145 |
+
"message": f"Demo simulation completed for educational topic: {topic}",
|
| 146 |
+
"scenes_planned": max_scenes,
|
| 147 |
"processing_steps": results,
|
| 148 |
+
"demo_note": "🎮 This is a demonstration mode",
|
| 149 |
+
"limitations": [
|
| 150 |
+
"Real video generation requires Manim system dependencies",
|
| 151 |
+
"HF Spaces has limited system library support",
|
| 152 |
+
"For full functionality, run locally with complete dependencies"
|
| 153 |
+
],
|
| 154 |
+
"capabilities": [
|
| 155 |
+
"✅ Gemini 2.0 Flash AI integration",
|
| 156 |
+
"✅ Comma-separated API key support",
|
| 157 |
+
"✅ Educational content planning",
|
| 158 |
+
"❌ Video rendering (requires local setup)"
|
| 159 |
+
]
|
| 160 |
}
|
| 161 |
+
|
| 162 |
+
return demo_content
|
| 163 |
|
| 164 |
async def generate_video_async(topic: str, context: str, max_scenes: int, progress_callback=None):
|
| 165 |
+
"""Generate video asynchronously - handles both real and demo modes."""
|
| 166 |
global video_generator
|
| 167 |
|
| 168 |
if not topic.strip():
|
| 169 |
+
return {"success": False, "error": "Please enter an educational topic"}
|
| 170 |
|
| 171 |
try:
|
| 172 |
+
# Always use demo mode on HF Spaces due to dependency limitations
|
| 173 |
if DEMO_MODE or not CAN_IMPORT_DEPENDENCIES or video_generator is None:
|
| 174 |
return simulate_video_generation(topic, context, max_scenes, progress_callback)
|
| 175 |
|
| 176 |
+
# This code would run with full dependencies (local setup)
|
| 177 |
if progress_callback:
|
| 178 |
progress_callback(10, "🚀 Starting video generation...")
|
| 179 |
|
|
|
|
| 180 |
result = await video_generator.generate_video_pipeline(
|
| 181 |
topic=topic,
|
| 182 |
description=context or f"Educational video about {topic}",
|
|
|
|
| 196 |
video_files = []
|
| 197 |
|
| 198 |
if os.path.exists(output_folder):
|
|
|
|
| 199 |
combined_video = os.path.join(output_folder, f"{file_prefix}_combined.mp4")
|
| 200 |
if os.path.exists(combined_video):
|
| 201 |
video_files.append(combined_video)
|
| 202 |
|
|
|
|
| 203 |
for i in range(1, max_scenes + 1):
|
| 204 |
scene_video = os.path.join(output_folder, f"scene{i}", f"{file_prefix}_scene{i}.mp4")
|
| 205 |
if os.path.exists(scene_video):
|
|
|
|
| 234 |
loop.close()
|
| 235 |
|
| 236 |
if result["success"]:
|
| 237 |
+
output = f"""# 🎓 Educational Content Generation
|
| 238 |
|
| 239 |
**Topic:** {topic}
|
| 240 |
+
**Context:** {context if context else "General educational content"}
|
| 241 |
+
**Planned Scenes:** {max_scenes}
|
| 242 |
|
| 243 |
+
## ✅ Generation Results
|
| 244 |
{result["message"]}
|
| 245 |
"""
|
| 246 |
|
|
|
|
| 250 |
for step in result["processing_steps"]:
|
| 251 |
output += f"{step}\n"
|
| 252 |
|
| 253 |
+
# Add capabilities info
|
| 254 |
+
if "capabilities" in result:
|
| 255 |
+
output += "\n## 🛠️ System Capabilities\n"
|
| 256 |
+
for cap in result["capabilities"]:
|
| 257 |
+
output += f"{cap}\n"
|
| 258 |
+
|
| 259 |
+
# Add limitations for demo mode
|
| 260 |
+
if "limitations" in result:
|
| 261 |
+
output += "\n## ⚠️ Current Limitations\n"
|
| 262 |
+
for limit in result["limitations"]:
|
| 263 |
+
output += f"• {limit}\n"
|
| 264 |
+
|
| 265 |
+
# Add demo note if present
|
| 266 |
if "demo_note" in result:
|
| 267 |
+
output += f"\n## {result['demo_note']}\n"
|
| 268 |
+
output += "For full video generation capabilities, set up the system locally with all dependencies."
|
| 269 |
|
| 270 |
+
# Add video file information for real generation
|
| 271 |
video_path = None
|
| 272 |
if "video_files" in result and result["video_files"]:
|
| 273 |
output += f"\n## 🎥 Generated Videos\n"
|
| 274 |
for video_file in result["video_files"]:
|
| 275 |
output += f"• {os.path.basename(video_file)}\n"
|
| 276 |
+
video_path = result["video_files"][0]
|
| 277 |
elif "output_folder" in result:
|
| 278 |
output += f"\n📁 **Output folder:** {result['output_folder']}\n"
|
| 279 |
|
| 280 |
+
status = "🎮 Demo mode active" if (DEMO_MODE or not CAN_IMPORT_DEPENDENCIES) else "✅ Generation completed"
|
| 281 |
return output, status, video_path
|
| 282 |
|
| 283 |
else:
|
| 284 |
+
error_output = f"""# ❌ Generation Failed
|
| 285 |
|
| 286 |
**Error:** {result.get("error", "Unknown error")}
|
| 287 |
|
| 288 |
## 💡 Troubleshooting Tips
|
|
|
|
|
|
|
|
|
|
|
|
|
| 289 |
|
| 290 |
+
### For Demo Mode Issues:
|
| 291 |
+
1. **Topic Clarity:** Use specific educational topics
|
| 292 |
+
2. **Context:** Provide clear learning objectives
|
| 293 |
+
3. **Scope:** Keep scenes reasonable (2-4 for demos)
|
| 294 |
+
|
| 295 |
+
### For Full Video Generation:
|
| 296 |
+
1. **Local Setup:** Clone the repository locally
|
| 297 |
+
2. **Dependencies:** Install all required packages including Manim
|
| 298 |
+
3. **API Keys:** Set GEMINI_API_KEY with valid keys
|
| 299 |
+
4. **System Requirements:** Ensure Manim system dependencies are installed
|
| 300 |
+
|
| 301 |
+
## 🔧 Local Development Setup
|
| 302 |
```bash
|
| 303 |
+
# Clone repository
|
| 304 |
+
git clone <repository-url>
|
| 305 |
+
cd TheoremExplainAgent
|
| 306 |
+
|
| 307 |
+
# Install full dependencies
|
| 308 |
+
pip install -r requirements.txt
|
| 309 |
+
|
| 310 |
+
# Set environment variables
|
| 311 |
+
export GEMINI_API_KEY="your-key-1,your-key-2"
|
| 312 |
export DEMO_MODE=false
|
| 313 |
+
|
| 314 |
+
# Run locally
|
| 315 |
+
python app.py
|
| 316 |
```
|
| 317 |
"""
|
| 318 |
+
return error_output, "❌ Failed", None
|
| 319 |
|
| 320 |
def get_examples():
|
| 321 |
+
"""Educational example topics optimized for AI processing."""
|
| 322 |
return [
|
| 323 |
+
["Pythagorean Theorem", "Visual proof with geometric demonstrations for high school students"],
|
| 324 |
+
["Newton's Second Law", "F=ma explained with real-world examples and mathematical derivations"],
|
| 325 |
+
["Calculus Derivatives", "Rate of change concept with graphical interpretations and applications"],
|
| 326 |
+
["DNA Structure", "Double helix model with chemical bonds and biological significance"],
|
| 327 |
+
["Photosynthesis Process", "Step-by-step biochemical pathway with energy transformations"],
|
| 328 |
+
["Quadratic Formula", "Derivation, applications, and graphical representation"],
|
| 329 |
+
["Electromagnetic Waves", "Properties, spectrum, and everyday applications"],
|
| 330 |
+
["Cellular Respiration", "ATP production pathway with molecular details"]
|
| 331 |
]
|
| 332 |
|
| 333 |
# Initialize the system
|
|
|
|
| 344 |
gr.HTML("""
|
| 345 |
<div style="text-align: center; padding: 25px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); border-radius: 15px; color: white; margin-bottom: 25px; box-shadow: 0 4px 6px rgba(0,0,0,0.1);">
|
| 346 |
<h1 style="margin: 0; font-size: 2.5em;">🎓 Theorem Explanation Agent</h1>
|
| 347 |
+
<p style="margin: 10px 0 0 0; font-size: 1.2em; opacity: 0.9;">AI-Powered Educational Content Generation</p>
|
| 348 |
+
<p style="margin: 5px 0 0 0; font-size: 0.9em; opacity: 0.8;">Powered by Gemini 2.0 Flash</p>
|
| 349 |
</div>
|
| 350 |
""")
|
| 351 |
|
| 352 |
+
# System status section
|
| 353 |
with gr.Row():
|
| 354 |
with gr.Column():
|
| 355 |
gr.HTML(f"""
|
| 356 |
<div style="background: {'#d4edda' if has_api_keys else '#fff3cd'}; padding: 15px; border-radius: 10px; margin-bottom: 15px; border-left: 4px solid {'#28a745' if has_api_keys else '#ffc107'};">
|
| 357 |
+
<h4 style="margin: 0 0 8px 0;">🔐 API Configuration</h4>
|
| 358 |
<p style="margin: 0;"><strong>Status:</strong> {"✅ API keys configured" if has_api_keys else "⚠️ No API keys found"}</p>
|
| 359 |
+
<p style="margin: 5px 0 0 0; font-size: 0.9em;">{"Ready for content generation" if has_api_keys else "Limited to demo capabilities"}</p>
|
| 360 |
</div>
|
| 361 |
""")
|
| 362 |
|
|
|
|
| 368 |
lines=2
|
| 369 |
)
|
| 370 |
|
| 371 |
+
# Dependency information
|
| 372 |
+
if not CAN_IMPORT_DEPENDENCIES:
|
| 373 |
gr.HTML("""
|
| 374 |
+
<div style="background: #e3f2fd; padding: 20px; border-radius: 10px; margin: 15px 0; border: 1px solid #2196f3;">
|
| 375 |
+
<h4 style="color: #1976d2; margin-top: 0;">🎮 Demo Mode Active</h4>
|
| 376 |
+
<p>This HF Spaces instance runs in demonstration mode due to system dependency limitations.</p>
|
| 377 |
+
|
| 378 |
+
<div style="background: #fff; padding: 15px; border-radius: 8px; margin: 15px 0;">
|
| 379 |
+
<h5 style="color: #333; margin-top: 0;">✅ Available Features:</h5>
|
| 380 |
+
<ul style="margin: 10px 0; color: #666;">
|
| 381 |
+
<li>🤖 Gemini 2.0 Flash AI integration</li>
|
| 382 |
+
<li>🔄 Comma-separated API key rotation</li>
|
| 383 |
+
<li>📚 Educational content planning</li>
|
| 384 |
+
<li>🎯 Learning objective design</li>
|
| 385 |
+
</ul>
|
| 386 |
+
|
| 387 |
+
<h5 style="color: #333; margin-top: 15px;">❌ Not Available:</h5>
|
| 388 |
+
<ul style="margin: 10px 0; color: #666;">
|
| 389 |
+
<li>🎥 Actual video rendering (requires Manim system libraries)</li>
|
| 390 |
+
<li>📹 MP4 file generation</li>
|
| 391 |
+
<li>🎨 Visual animations</li>
|
| 392 |
+
</ul>
|
| 393 |
+
</div>
|
| 394 |
+
|
| 395 |
+
<div style="background: #f5f5f5; padding: 15px; border-radius: 5px; font-family: monospace; font-size: 0.9em;">
|
| 396 |
+
<strong>For Full Video Generation:</strong><br>
|
| 397 |
+
1. Clone repository locally<br>
|
| 398 |
+
2. Install system dependencies (pangocairo, manim)<br>
|
| 399 |
+
3. Set GEMINI_API_KEY environment variable<br>
|
| 400 |
+
4. Run: python app.py
|
| 401 |
</div>
|
|
|
|
|
|
|
|
|
|
| 402 |
</div>
|
| 403 |
""")
|
| 404 |
|
|
|
|
| 407 |
with gr.Column(scale=2):
|
| 408 |
topic_input = gr.Textbox(
|
| 409 |
label="📚 Educational Topic",
|
| 410 |
+
placeholder="e.g., Pythagorean Theorem, Newton's Laws, DNA Structure...",
|
| 411 |
lines=1
|
| 412 |
)
|
| 413 |
|
| 414 |
context_input = gr.Textbox(
|
| 415 |
+
label="📝 Learning Context (Optional)",
|
| 416 |
+
placeholder="Specify target audience, learning objectives, or focus areas...",
|
| 417 |
lines=3
|
| 418 |
)
|
| 419 |
|
| 420 |
max_scenes_slider = gr.Slider(
|
| 421 |
+
label="🎬 Content Sections",
|
| 422 |
minimum=1,
|
| 423 |
maximum=6,
|
| 424 |
value=3,
|
| 425 |
step=1,
|
| 426 |
+
info="Number of content sections to plan"
|
| 427 |
)
|
| 428 |
|
| 429 |
+
generate_btn = gr.Button(
|
| 430 |
+
"🚀 Generate Educational Content",
|
| 431 |
+
variant="primary",
|
| 432 |
+
size="lg"
|
| 433 |
+
)
|
| 434 |
|
| 435 |
with gr.Column(scale=1):
|
| 436 |
gr.HTML("""
|
| 437 |
<div style="background: #f8f9fa; padding: 20px; border-radius: 10px; height: fit-content;">
|
| 438 |
<h4 style="color: #495057; margin-top: 0;">💡 Tips for Best Results</h4>
|
| 439 |
<ul style="color: #6c757d; font-size: 0.9em; line-height: 1.6;">
|
| 440 |
+
<li><strong>Be Specific:</strong> "Quadratic formula derivation" vs "Math"</li>
|
| 441 |
+
<li><strong>Educational Focus:</strong> Include learning objectives</li>
|
| 442 |
+
<li><strong>Target Audience:</strong> Specify grade level or background</li>
|
| 443 |
+
<li><strong>Clear Context:</strong> Mention key concepts to cover</li>
|
| 444 |
</ul>
|
| 445 |
</div>
|
| 446 |
""")
|
|
|
|
| 449 |
examples = gr.Examples(
|
| 450 |
examples=get_examples(),
|
| 451 |
inputs=[topic_input, context_input],
|
| 452 |
+
label="📖 Example Educational Topics"
|
| 453 |
)
|
| 454 |
|
| 455 |
# Output section
|
| 456 |
with gr.Row():
|
| 457 |
with gr.Column(scale=2):
|
| 458 |
output_display = gr.Markdown(
|
| 459 |
+
value="👋 **Ready to generate educational content!** Enter a topic above and click 'Generate' to begin planning.",
|
| 460 |
label="📋 Generation Results"
|
| 461 |
)
|
| 462 |
|
requirements.txt
CHANGED
|
@@ -8,22 +8,23 @@ pandas>=1.3.0
|
|
| 8 |
# AI/ML dependencies
|
| 9 |
openai>=1.0.0
|
| 10 |
litellm>=1.0.0
|
|
|
|
| 11 |
|
| 12 |
-
#
|
| 13 |
-
|
| 14 |
-
|
|
|
|
| 15 |
pillow>=8.3.0
|
| 16 |
-
pydub>=0.25.0
|
| 17 |
-
moviepy>=1.0.3
|
| 18 |
|
| 19 |
-
# Text-to-speech
|
| 20 |
-
elevenlabs>=1.0.0
|
| 21 |
|
| 22 |
-
#
|
| 23 |
-
|
| 24 |
|
| 25 |
-
#
|
| 26 |
-
|
| 27 |
|
| 28 |
-
#
|
| 29 |
-
|
|
|
|
|
|
| 8 |
# AI/ML dependencies
|
| 9 |
openai>=1.0.0
|
| 10 |
litellm>=1.0.0
|
| 11 |
+
tqdm>=4.62.0
|
| 12 |
|
| 13 |
+
# Google Gemini support
|
| 14 |
+
google-generativeai>=0.8.0
|
| 15 |
+
|
| 16 |
+
# Lightweight video processing dependencies
|
| 17 |
pillow>=8.3.0
|
|
|
|
|
|
|
| 18 |
|
| 19 |
+
# Text-to-speech (optional)
|
| 20 |
+
elevenlabs>=1.0.0
|
| 21 |
|
| 22 |
+
# Audio processing (lightweight)
|
| 23 |
+
soundfile>=0.12.0
|
| 24 |
|
| 25 |
+
# Additional utilities
|
| 26 |
+
tiktoken>=0.4.0
|
| 27 |
|
| 28 |
+
# Note: Heavy dependencies like manim, moviepy, pydub are excluded
|
| 29 |
+
# to prevent build failures on HF Spaces. The app will gracefully
|
| 30 |
+
# handle missing dependencies and show appropriate messages.
|
requirements_hf.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
# Essential dependencies for Gradio
|
| 2 |
gradio==4.44.0
|
| 3 |
python-dotenv>=0.19.0
|
| 4 |
requests>=2.25.0
|
|
@@ -13,38 +13,18 @@ tqdm>=4.62.0
|
|
| 13 |
# Google Gemini support
|
| 14 |
google-generativeai>=0.8.0
|
| 15 |
|
| 16 |
-
#
|
| 17 |
pillow>=8.3.0
|
| 18 |
-
moviepy>=1.0.3
|
| 19 |
|
| 20 |
-
#
|
| 21 |
-
manim>=0.18.0
|
| 22 |
-
|
| 23 |
-
# Text-to-speech
|
| 24 |
elevenlabs>=1.0.0
|
| 25 |
|
| 26 |
-
# Audio processing
|
| 27 |
-
pydub>=0.25.0
|
| 28 |
soundfile>=0.12.0
|
| 29 |
|
| 30 |
# Additional utilities
|
| 31 |
-
langchain>=0.1.0
|
| 32 |
-
chromadb>=0.4.0
|
| 33 |
tiktoken>=0.4.0
|
| 34 |
|
| 35 |
-
#
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
# Audio processing (optional, for TTS)
|
| 39 |
-
# elevenlabs>=1.0.0
|
| 40 |
-
|
| 41 |
-
# Utility libraries
|
| 42 |
-
tqdm>=4.62.0
|
| 43 |
-
|
| 44 |
-
# Video processing dependencies (only install when needed)
|
| 45 |
-
# Comment out these lines to prevent heavy downloads on Hugging Face Spaces
|
| 46 |
-
# manim; python_version>="3.8"
|
| 47 |
-
# manim-voiceover; python_version>="3.8"
|
| 48 |
-
# pydub>=0.25.0; python_version>="3.8"
|
| 49 |
-
# moviepy>=1.0.3; python_version>="3.8"
|
| 50 |
-
# soundfile>=0.12.0; python_version>="3.8"
|
|
|
|
| 1 |
+
# Essential dependencies for Gradio interface
|
| 2 |
gradio==4.44.0
|
| 3 |
python-dotenv>=0.19.0
|
| 4 |
requests>=2.25.0
|
|
|
|
| 13 |
# Google Gemini support
|
| 14 |
google-generativeai>=0.8.0
|
| 15 |
|
| 16 |
+
# Lightweight video processing dependencies
|
| 17 |
pillow>=8.3.0
|
|
|
|
| 18 |
|
| 19 |
+
# Text-to-speech (optional)
|
|
|
|
|
|
|
|
|
|
| 20 |
elevenlabs>=1.0.0
|
| 21 |
|
| 22 |
+
# Audio processing (lightweight)
|
|
|
|
| 23 |
soundfile>=0.12.0
|
| 24 |
|
| 25 |
# Additional utilities
|
|
|
|
|
|
|
| 26 |
tiktoken>=0.4.0
|
| 27 |
|
| 28 |
+
# Note: Heavy dependencies like manim, moviepy, pydub are excluded
|
| 29 |
+
# to prevent build failures on HF Spaces. The app will gracefully
|
| 30 |
+
# handle missing dependencies and show appropriate messages.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|